Fix max_samples in command buffer capabilities.
[chromium-blink-merge.git] / content / child / blink_platform_impl.h
blob7b7bceb9f57bf0c3336b8f542847f411869d254b
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/threading/thread_local_storage.h"
10 #include "base/timer/timer.h"
11 #include "base/trace_event/trace_event.h"
12 #include "components/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 PermissionDispatcher;
38 class PushDispatcher;
39 class ThreadSafeSender;
40 class WebBluetoothImpl;
41 class WebCryptoImpl;
42 class WebGeofencingProviderImpl;
44 class CONTENT_EXPORT BlinkPlatformImpl
45 : NON_EXPORTED_BASE(public blink::Platform) {
46 public:
47 BlinkPlatformImpl();
48 explicit BlinkPlatformImpl(
49 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner);
50 virtual ~BlinkPlatformImpl();
52 // Platform methods (partial implementation):
53 virtual blink::WebThemeEngine* themeEngine();
54 virtual blink::WebFallbackThemeEngine* fallbackThemeEngine();
55 virtual blink::Platform::FileHandle databaseOpenFile(
56 const blink::WebString& vfs_file_name, int desired_flags);
57 virtual int databaseDeleteFile(const blink::WebString& vfs_file_name,
58 bool sync_dir);
59 virtual long databaseGetFileAttributes(
60 const blink::WebString& vfs_file_name);
61 virtual long long databaseGetFileSize(const blink::WebString& vfs_file_name);
62 virtual long long databaseGetSpaceAvailableForOrigin(
63 const blink::WebString& origin_identifier);
64 virtual bool databaseSetFileSize(
65 const blink::WebString& vfs_file_name, long long size);
66 virtual blink::WebString signedPublicKeyAndChallengeString(
67 unsigned key_size_index, const blink::WebString& challenge,
68 const blink::WebURL& url);
69 virtual size_t memoryUsageMB();
70 virtual size_t actualMemoryUsageMB();
71 virtual size_t physicalMemoryMB();
72 virtual size_t virtualMemoryLimitMB();
73 virtual size_t numberOfProcessors();
75 virtual bool processMemorySizesInBytes(size_t* private_bytes,
76 size_t* shared_bytes);
77 virtual bool memoryAllocatorWasteInBytes(size_t* size);
78 virtual blink::WebDiscardableMemory* allocateAndLockDiscardableMemory(
79 size_t bytes);
80 virtual size_t maxDecodedImageBytes();
81 virtual blink::WebURLLoader* createURLLoader();
82 virtual blink::WebSocketHandle* createWebSocketHandle();
83 virtual blink::WebString userAgent();
84 virtual blink::WebData parseDataURL(
85 const blink::WebURL& url, blink::WebString& mimetype,
86 blink::WebString& charset);
87 virtual blink::WebURLError cancelledError(const blink::WebURL& url) const;
88 virtual bool isReservedIPAddress(const blink::WebString& host) const;
89 virtual bool portAllowed(const blink::WebURL& url) const;
90 virtual blink::WebThread* createThread(const char* name);
91 virtual blink::WebThread* currentThread();
92 virtual void yieldCurrentThread();
93 virtual blink::WebWaitableEvent* createWaitableEvent();
94 virtual blink::WebWaitableEvent* waitMultipleEvents(
95 const blink::WebVector<blink::WebWaitableEvent*>& events);
96 virtual void decrementStatsCounter(const char* name);
97 virtual void incrementStatsCounter(const char* name);
98 virtual void histogramCustomCounts(
99 const char* name, int sample, int min, int max, int bucket_count);
100 virtual void histogramEnumeration(
101 const char* name, int sample, int boundary_value);
102 virtual void histogramSparse(const char* name, int sample);
103 virtual const unsigned char* getTraceCategoryEnabledFlag(
104 const char* category_name);
105 virtual TraceEventAPIAtomicWord* getTraceSamplingState(
106 const unsigned thread_bucket);
107 virtual TraceEventHandle addTraceEvent(
108 char phase,
109 const unsigned char* category_group_enabled,
110 const char* name,
111 unsigned long long id,
112 double timestamp,
113 int num_args,
114 const char** arg_names,
115 const unsigned char* arg_types,
116 const unsigned long long* arg_values,
117 unsigned char flags);
118 virtual TraceEventHandle addTraceEvent(
119 char phase,
120 const unsigned char* category_group_enabled,
121 const char* name,
122 unsigned long long id,
123 double timestamp,
124 int num_args,
125 const char** arg_names,
126 const unsigned char* arg_types,
127 const unsigned long long* arg_values,
128 blink::WebConvertableToTraceFormat* convertable_values,
129 unsigned char flags);
130 virtual void updateTraceEventDuration(
131 const unsigned char* category_group_enabled,
132 const char* name,
133 TraceEventHandle);
134 virtual blink::WebData loadResource(const char* name);
135 virtual blink::WebString queryLocalizedString(
136 blink::WebLocalizedString::Name name);
137 virtual blink::WebString queryLocalizedString(
138 blink::WebLocalizedString::Name name, int numeric_value);
139 virtual blink::WebString queryLocalizedString(
140 blink::WebLocalizedString::Name name, const blink::WebString& value);
141 virtual blink::WebString queryLocalizedString(
142 blink::WebLocalizedString::Name name,
143 const blink::WebString& value1, const blink::WebString& value2);
144 virtual void suddenTerminationChanged(bool enabled) { }
145 virtual double currentTime();
146 virtual double monotonicallyIncreasingTime();
147 virtual double systemTraceTime();
148 virtual void cryptographicallyRandomValues(
149 unsigned char* buffer, size_t length);
150 virtual void setSharedTimerFiredFunction(void (*func)());
151 virtual void setSharedTimerFireInterval(double interval_seconds);
152 virtual void stopSharedTimer();
153 virtual blink::WebGestureCurve* createFlingAnimationCurve(
154 blink::WebGestureDevice device_source,
155 const blink::WebFloatPoint& velocity,
156 const blink::WebSize& cumulative_scroll);
157 virtual void didStartWorkerRunLoop();
158 virtual void didStopWorkerRunLoop();
159 virtual blink::WebCrypto* crypto();
160 virtual blink::WebGeofencingProvider* geofencingProvider();
161 virtual blink::WebBluetooth* bluetooth();
162 virtual blink::WebNotificationManager* notificationManager();
163 virtual blink::WebPushProvider* pushProvider();
164 virtual blink::WebNavigatorConnectProvider* navigatorConnectProvider();
165 virtual blink::WebPermissionClient* permissionClient();
167 void SuspendSharedTimer();
168 void ResumeSharedTimer();
169 virtual void OnStartSharedTimer(base::TimeDelta delay) {}
171 WebBluetoothImpl* BluetoothImplForTesting() { return bluetooth_.get(); }
173 virtual blink::WebString domCodeStringFromEnum(int dom_code);
174 virtual int domEnumFromCodeString(const blink::WebString& codeString);
176 private:
177 void DoTimeout() {
178 if (shared_timer_func_ && !shared_timer_suspended_)
179 shared_timer_func_();
182 void InternalInit();
183 void UpdateWebThreadTLS(blink::WebThread* thread);
185 bool IsMainThread() const;
187 scoped_refptr<base::SingleThreadTaskRunner> MainTaskRunnerForCurrentThread();
189 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
190 WebThemeEngineImpl native_theme_engine_;
191 WebFallbackThemeEngineImpl fallback_theme_engine_;
192 base::OneShotTimer<BlinkPlatformImpl> shared_timer_;
193 void (*shared_timer_func_)();
194 double shared_timer_fire_time_;
195 bool shared_timer_fire_time_was_set_while_suspended_;
196 int shared_timer_suspended_; // counter
197 base::ThreadLocalStorage::Slot current_thread_slot_;
198 webcrypto::WebCryptoImpl web_crypto_;
199 scoped_ptr<WebGeofencingProviderImpl> geofencing_provider_;
200 scoped_ptr<WebBluetoothImpl> bluetooth_;
202 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
203 scoped_refptr<NotificationDispatcher> notification_dispatcher_;
204 scoped_refptr<PushDispatcher> push_dispatcher_;
205 scoped_ptr<PermissionDispatcher> permission_client_;
208 } // namespace content
210 #endif // CONTENT_CHILD_BLINK_PLATFORM_IMPL_H_