CreateSessionAndGenerateRequest() to use enum for |init_data_type|
[chromium-blink-merge.git] / content / child / blink_platform_impl.h
blob12ecf5e12f68a9ba38245d7314589d7048a3b7c2
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 "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 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 blink::WebString signedPublicKeyAndChallengeString(
65 unsigned key_size_index, const blink::WebString& challenge,
66 const blink::WebURL& url);
67 virtual size_t memoryUsageMB();
68 virtual size_t actualMemoryUsageMB();
69 virtual size_t physicalMemoryMB();
70 virtual size_t virtualMemoryLimitMB();
71 virtual size_t numberOfProcessors();
73 virtual bool processMemorySizesInBytes(size_t* private_bytes,
74 size_t* shared_bytes);
75 virtual bool memoryAllocatorWasteInBytes(size_t* size);
76 virtual blink::WebDiscardableMemory* allocateAndLockDiscardableMemory(
77 size_t bytes);
78 virtual size_t maxDecodedImageBytes();
79 virtual blink::WebURLLoader* createURLLoader();
80 virtual blink::WebSocketHandle* createWebSocketHandle();
81 virtual blink::WebString userAgent();
82 virtual blink::WebData parseDataURL(
83 const blink::WebURL& url, blink::WebString& mimetype,
84 blink::WebString& charset);
85 virtual blink::WebURLError cancelledError(const blink::WebURL& url) const;
86 virtual bool isReservedIPAddress(const blink::WebString& host) const;
87 virtual blink::WebThread* createThread(const char* name);
88 virtual blink::WebThread* currentThread();
89 virtual void yieldCurrentThread();
90 virtual blink::WebWaitableEvent* createWaitableEvent();
91 virtual blink::WebWaitableEvent* waitMultipleEvents(
92 const blink::WebVector<blink::WebWaitableEvent*>& events);
93 virtual void decrementStatsCounter(const char* name);
94 virtual void incrementStatsCounter(const char* name);
95 virtual void histogramCustomCounts(
96 const char* name, int sample, int min, int max, int bucket_count);
97 virtual void histogramEnumeration(
98 const char* name, int sample, int boundary_value);
99 virtual void histogramSparse(const char* name, int sample);
100 virtual const unsigned char* getTraceCategoryEnabledFlag(
101 const char* category_name);
102 virtual long* getTraceSamplingState(const unsigned thread_bucket);
103 virtual TraceEventHandle addTraceEvent(
104 char phase,
105 const unsigned char* category_group_enabled,
106 const char* name,
107 unsigned long long id,
108 double timestamp,
109 int num_args,
110 const char** arg_names,
111 const unsigned char* arg_types,
112 const unsigned long long* arg_values,
113 unsigned char flags);
114 virtual TraceEventHandle addTraceEvent(
115 char phase,
116 const unsigned char* category_group_enabled,
117 const char* name,
118 unsigned long long id,
119 double timestamp,
120 int num_args,
121 const char** arg_names,
122 const unsigned char* arg_types,
123 const unsigned long long* arg_values,
124 const blink::WebConvertableToTraceFormat* convertable_values,
125 unsigned char flags);
126 virtual void updateTraceEventDuration(
127 const unsigned char* category_group_enabled,
128 const char* name,
129 TraceEventHandle);
130 virtual blink::WebData loadResource(const char* name);
131 virtual blink::WebString queryLocalizedString(
132 blink::WebLocalizedString::Name name);
133 virtual blink::WebString queryLocalizedString(
134 blink::WebLocalizedString::Name name, int numeric_value);
135 virtual blink::WebString queryLocalizedString(
136 blink::WebLocalizedString::Name name, const blink::WebString& value);
137 virtual blink::WebString queryLocalizedString(
138 blink::WebLocalizedString::Name name,
139 const blink::WebString& value1, const blink::WebString& value2);
140 virtual void suddenTerminationChanged(bool enabled) { }
141 virtual double currentTime();
142 virtual double monotonicallyIncreasingTime();
143 virtual void cryptographicallyRandomValues(
144 unsigned char* buffer, size_t length);
145 virtual void setSharedTimerFiredFunction(void (*func)());
146 virtual void setSharedTimerFireInterval(double interval_seconds);
147 virtual void stopSharedTimer();
148 virtual void callOnMainThread(void (*func)(void*), void* context);
149 virtual blink::WebGestureCurve* createFlingAnimationCurve(
150 blink::WebGestureDevice device_source,
151 const blink::WebFloatPoint& velocity,
152 const blink::WebSize& cumulative_scroll);
153 virtual void didStartWorkerRunLoop();
154 virtual void didStopWorkerRunLoop();
155 virtual blink::WebCrypto* crypto();
156 virtual blink::WebGeofencingProvider* geofencingProvider();
157 virtual blink::WebBluetooth* bluetooth();
158 virtual blink::WebNotificationManager* notificationManager();
159 virtual blink::WebPushProvider* pushProvider();
160 virtual blink::WebNavigatorConnectProvider* navigatorConnectProvider();
161 virtual blink::WebPermissionClient* permissionClient();
163 void SuspendSharedTimer();
164 void ResumeSharedTimer();
165 virtual void OnStartSharedTimer(base::TimeDelta delay) {}
167 WebBluetoothImpl* BluetoothImplForTesting() { return bluetooth_.get(); }
169 virtual blink::WebString domCodeStringFromEnum(int dom_code);
170 virtual int domEnumFromCodeString(const blink::WebString& codeString);
172 private:
173 void DoTimeout() {
174 if (shared_timer_func_ && !shared_timer_suspended_)
175 shared_timer_func_();
178 void InternalInit();
179 void UpdateWebThreadTLS(blink::WebThread* thread);
181 bool IsMainThread() const;
183 scoped_refptr<base::SingleThreadTaskRunner> MainTaskRunnerForCurrentThread();
185 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
186 WebThemeEngineImpl native_theme_engine_;
187 WebFallbackThemeEngineImpl fallback_theme_engine_;
188 base::OneShotTimer<BlinkPlatformImpl> shared_timer_;
189 void (*shared_timer_func_)();
190 double shared_timer_fire_time_;
191 bool shared_timer_fire_time_was_set_while_suspended_;
192 int shared_timer_suspended_; // counter
193 base::ThreadLocalStorage::Slot current_thread_slot_;
194 WebCryptoImpl web_crypto_;
195 scoped_ptr<WebGeofencingProviderImpl> geofencing_provider_;
196 scoped_ptr<WebBluetoothImpl> bluetooth_;
198 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
199 scoped_refptr<NotificationDispatcher> notification_dispatcher_;
200 scoped_refptr<PushDispatcher> push_dispatcher_;
201 scoped_ptr<PermissionDispatcher> permission_client_;
204 } // namespace content
206 #endif // CONTENT_CHILD_BLINK_PLATFORM_IMPL_H_