Delete chrome.mediaGalleriesPrivate because the functionality unique to it has since...
[chromium-blink-merge.git] / content / child / blink_platform_impl.h
blob46f39c426beb94015f20989bf26953e64febb094
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 NotificationDispatcher;
37 class PushDispatcher;
38 class ThreadSafeSender;
39 class WebBluetoothImpl;
40 class WebCryptoImpl;
41 class WebGeofencingProviderImpl;
43 class CONTENT_EXPORT BlinkPlatformImpl
44 : NON_EXPORTED_BASE(public blink::Platform) {
45 public:
46 BlinkPlatformImpl();
47 explicit BlinkPlatformImpl(
48 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner);
49 virtual ~BlinkPlatformImpl();
51 // Platform methods (partial implementation):
52 virtual blink::WebThemeEngine* themeEngine();
53 virtual blink::WebFallbackThemeEngine* fallbackThemeEngine();
54 virtual blink::Platform::FileHandle databaseOpenFile(
55 const blink::WebString& vfs_file_name, int desired_flags);
56 virtual int databaseDeleteFile(const blink::WebString& vfs_file_name,
57 bool sync_dir);
58 virtual long databaseGetFileAttributes(
59 const blink::WebString& vfs_file_name);
60 virtual long long databaseGetFileSize(const blink::WebString& vfs_file_name);
61 virtual long long databaseGetSpaceAvailableForOrigin(
62 const blink::WebString& origin_identifier);
63 virtual blink::WebString signedPublicKeyAndChallengeString(
64 unsigned key_size_index, const blink::WebString& challenge,
65 const blink::WebURL& url);
66 virtual size_t memoryUsageMB();
67 virtual size_t actualMemoryUsageMB();
68 virtual size_t physicalMemoryMB();
69 virtual size_t virtualMemoryLimitMB();
70 virtual size_t numberOfProcessors();
72 virtual bool processMemorySizesInBytes(size_t* private_bytes,
73 size_t* shared_bytes);
74 virtual bool memoryAllocatorWasteInBytes(size_t* size);
75 virtual blink::WebDiscardableMemory* allocateAndLockDiscardableMemory(
76 size_t bytes);
77 virtual size_t maxDecodedImageBytes();
78 virtual blink::WebURLLoader* createURLLoader();
79 virtual blink::WebSocketHandle* createWebSocketHandle();
80 virtual blink::WebString userAgent();
81 virtual blink::WebData parseDataURL(
82 const blink::WebURL& url, blink::WebString& mimetype,
83 blink::WebString& charset);
84 virtual blink::WebURLError cancelledError(const blink::WebURL& url) const;
85 virtual bool isReservedIPAddress(const blink::WebString& host) const;
86 virtual blink::WebThread* createThread(const char* name);
87 virtual blink::WebThread* currentThread();
88 virtual void yieldCurrentThread();
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);
150 virtual void didStartWorkerRunLoop(
151 const blink::WebWorkerRunLoop& runLoop);
152 virtual void didStopWorkerRunLoop(
153 const blink::WebWorkerRunLoop& runLoop);
154 virtual blink::WebCrypto* crypto();
155 virtual blink::WebGeofencingProvider* geofencingProvider();
156 virtual blink::WebBluetooth* bluetooth();
157 virtual blink::WebNotificationManager* notificationManager();
158 virtual blink::WebPushProvider* pushProvider();
159 virtual blink::WebNavigatorConnectProvider* navigatorConnectProvider();
161 void SuspendSharedTimer();
162 void ResumeSharedTimer();
163 virtual void OnStartSharedTimer(base::TimeDelta delay) {}
165 WebBluetoothImpl* BluetoothImplForTesting() { return bluetooth_.get(); }
167 private:
168 static void DestroyCurrentThread(void*);
170 void DoTimeout() {
171 if (shared_timer_func_ && !shared_timer_suspended_)
172 shared_timer_func_();
175 void InternalInit();
177 scoped_refptr<base::SingleThreadTaskRunner> MainTaskRunnerForCurrentThread();
179 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
180 WebThemeEngineImpl native_theme_engine_;
181 WebFallbackThemeEngineImpl fallback_theme_engine_;
182 base::OneShotTimer<BlinkPlatformImpl> shared_timer_;
183 void (*shared_timer_func_)();
184 double shared_timer_fire_time_;
185 bool shared_timer_fire_time_was_set_while_suspended_;
186 int shared_timer_suspended_; // counter
187 base::ThreadLocalStorage::Slot current_thread_slot_;
188 WebCryptoImpl web_crypto_;
189 scoped_ptr<WebGeofencingProviderImpl> geofencing_provider_;
190 scoped_ptr<WebBluetoothImpl> bluetooth_;
192 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
193 scoped_refptr<NotificationDispatcher> notification_dispatcher_;
194 scoped_refptr<PushDispatcher> push_dispatcher_;
197 } // namespace content
199 #endif // CONTENT_CHILD_BLINK_PLATFORM_IMPL_H_