Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / content / child / blink_platform_impl.h
blob797aae1c62041f9d2e751b4dc37b366d7bd1fa01
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_CHILD_BLINK_PLATFORM_IMPL_H_
6 #define CONTENT_CHILD_BLINK_PLATFORM_IMPL_H_
8 #include "base/compiler_specific.h"
9 #include "base/debug/trace_event.h"
10 #include "base/threading/thread_local_storage.h"
11 #include "base/timer/timer.h"
12 #include "content/child/webcrypto/webcrypto_impl.h"
13 #include "content/child/webfallbackthemeengine_impl.h"
14 #include "content/common/content_export.h"
15 #include "third_party/WebKit/public/platform/Platform.h"
16 #include "third_party/WebKit/public/platform/WebGestureDevice.h"
17 #include "third_party/WebKit/public/platform/WebURLError.h"
18 #include "ui/base/layout.h"
20 #if defined(USE_DEFAULT_RENDER_THEME)
21 #include "content/child/webthemeengine_impl_default.h"
22 #elif defined(OS_WIN)
23 #include "content/child/webthemeengine_impl_win.h"
24 #elif defined(OS_MACOSX)
25 #include "content/child/webthemeengine_impl_mac.h"
26 #elif defined(OS_ANDROID)
27 #include "content/child/webthemeengine_impl_android.h"
28 #endif
30 namespace base {
31 class MessageLoop;
34 namespace content {
35 class FlingCurveConfiguration;
36 class WebCryptoImpl;
38 class CONTENT_EXPORT BlinkPlatformImpl
39 : NON_EXPORTED_BASE(public blink::Platform) {
40 public:
41 BlinkPlatformImpl();
42 virtual ~BlinkPlatformImpl();
44 // Platform methods (partial implementation):
45 virtual blink::WebThemeEngine* themeEngine();
46 virtual blink::WebFallbackThemeEngine* fallbackThemeEngine();
47 virtual blink::Platform::FileHandle databaseOpenFile(
48 const blink::WebString& vfs_file_name, int desired_flags);
49 virtual int databaseDeleteFile(const blink::WebString& vfs_file_name,
50 bool sync_dir);
51 virtual long databaseGetFileAttributes(
52 const blink::WebString& vfs_file_name);
53 virtual long long databaseGetFileSize(const blink::WebString& vfs_file_name);
54 virtual long long databaseGetSpaceAvailableForOrigin(
55 const blink::WebString& origin_identifier);
56 virtual blink::WebString signedPublicKeyAndChallengeString(
57 unsigned key_size_index, const blink::WebString& challenge,
58 const blink::WebURL& url);
59 virtual size_t memoryUsageMB();
60 virtual size_t actualMemoryUsageMB();
61 virtual size_t physicalMemoryMB();
62 virtual size_t virtualMemoryLimitMB();
63 virtual size_t numberOfProcessors();
65 virtual void startHeapProfiling(const blink::WebString& prefix);
66 virtual void stopHeapProfiling() OVERRIDE;
67 virtual void dumpHeapProfiling(const blink::WebString& reason);
68 virtual blink::WebString getHeapProfile() OVERRIDE;
70 virtual bool processMemorySizesInBytes(size_t* private_bytes,
71 size_t* shared_bytes);
72 virtual bool memoryAllocatorWasteInBytes(size_t* size);
73 virtual blink::WebDiscardableMemory* allocateAndLockDiscardableMemory(
74 size_t bytes);
75 virtual size_t maxDecodedImageBytes() OVERRIDE;
76 virtual blink::WebURLLoader* createURLLoader();
77 virtual blink::WebSocketStreamHandle* createSocketStreamHandle();
78 virtual blink::WebSocketHandle* createWebSocketHandle() OVERRIDE;
79 virtual blink::WebString userAgent();
80 virtual blink::WebData parseDataURL(
81 const blink::WebURL& url, blink::WebString& mimetype,
82 blink::WebString& charset);
83 virtual blink::WebURLError cancelledError(const blink::WebURL& url) const;
84 virtual bool isReservedIPAddress(
85 const blink::WebSecurityOrigin&) const OVERRIDE;
86 virtual bool isReservedIPAddress(const blink::WebURL&) const OVERRIDE;
87 virtual blink::WebThread* createThread(const char* name);
88 virtual blink::WebThread* currentThread();
89 virtual blink::WebWaitableEvent* createWaitableEvent();
90 virtual blink::WebWaitableEvent* waitMultipleEvents(
91 const blink::WebVector<blink::WebWaitableEvent*>& events);
92 virtual void decrementStatsCounter(const char* name);
93 virtual void incrementStatsCounter(const char* name);
94 virtual void histogramCustomCounts(
95 const char* name, int sample, int min, int max, int bucket_count);
96 virtual void histogramEnumeration(
97 const char* name, int sample, int boundary_value);
98 virtual void histogramSparse(const char* name, int sample);
99 virtual const unsigned char* getTraceCategoryEnabledFlag(
100 const char* category_name);
101 virtual long* getTraceSamplingState(const unsigned thread_bucket);
102 virtual TraceEventHandle addTraceEvent(
103 char phase,
104 const unsigned char* category_group_enabled,
105 const char* name,
106 unsigned long long id,
107 int num_args,
108 const char** arg_names,
109 const unsigned char* arg_types,
110 const unsigned long long* arg_values,
111 unsigned char flags);
112 virtual TraceEventHandle addTraceEvent(
113 char phase,
114 const unsigned char* category_group_enabled,
115 const char* name,
116 unsigned long long id,
117 int num_args,
118 const char** arg_names,
119 const unsigned char* arg_types,
120 const unsigned long long* arg_values,
121 const blink::WebConvertableToTraceFormat* convertable_values,
122 unsigned char flags);
123 virtual void updateTraceEventDuration(
124 const unsigned char* category_group_enabled,
125 const char* name,
126 TraceEventHandle);
127 virtual blink::WebData loadResource(const char* name);
128 virtual blink::WebString queryLocalizedString(
129 blink::WebLocalizedString::Name name);
130 virtual blink::WebString queryLocalizedString(
131 blink::WebLocalizedString::Name name, int numeric_value);
132 virtual blink::WebString queryLocalizedString(
133 blink::WebLocalizedString::Name name, const blink::WebString& value);
134 virtual blink::WebString queryLocalizedString(
135 blink::WebLocalizedString::Name name,
136 const blink::WebString& value1, const blink::WebString& value2);
137 virtual void suddenTerminationChanged(bool enabled) { }
138 virtual double currentTime();
139 virtual double monotonicallyIncreasingTime();
140 virtual void cryptographicallyRandomValues(
141 unsigned char* buffer, size_t length);
142 virtual void setSharedTimerFiredFunction(void (*func)());
143 virtual void setSharedTimerFireInterval(double interval_seconds);
144 virtual void stopSharedTimer();
145 virtual void callOnMainThread(void (*func)(void*), void* context);
146 virtual blink::WebGestureCurve* createFlingAnimationCurve(
147 blink::WebGestureDevice device_source,
148 const blink::WebFloatPoint& velocity,
149 const blink::WebSize& cumulative_scroll) OVERRIDE;
150 virtual void didStartWorkerRunLoop(
151 const blink::WebWorkerRunLoop& runLoop) OVERRIDE;
152 virtual void didStopWorkerRunLoop(
153 const blink::WebWorkerRunLoop& runLoop) OVERRIDE;
154 virtual blink::WebCrypto* crypto() OVERRIDE;
156 void SetFlingCurveParameters(const std::vector<float>& new_touchpad,
157 const std::vector<float>& new_touchscreen);
159 void SuspendSharedTimer();
160 void ResumeSharedTimer();
161 virtual void OnStartSharedTimer(base::TimeDelta delay) {}
163 private:
164 static void DestroyCurrentThread(void*);
166 void DoTimeout() {
167 if (shared_timer_func_ && !shared_timer_suspended_)
168 shared_timer_func_();
171 WebThemeEngineImpl native_theme_engine_;
172 WebFallbackThemeEngineImpl fallback_theme_engine_;
173 base::MessageLoop* main_loop_;
174 base::OneShotTimer<BlinkPlatformImpl> shared_timer_;
175 void (*shared_timer_func_)();
176 double shared_timer_fire_time_;
177 bool shared_timer_fire_time_was_set_while_suspended_;
178 int shared_timer_suspended_; // counter
179 scoped_ptr<FlingCurveConfiguration> fling_curve_configuration_;
180 base::ThreadLocalStorage::Slot current_thread_slot_;
181 WebCryptoImpl web_crypto_;
184 } // namespace content
186 #endif // CONTENT_CHILD_BLINK_PLATFORM_IMPL_H_