Record MTU discovery packets in net-internals log.
[chromium-blink-merge.git] / content / child / blink_platform_impl.h
blobbea5759871daebaf800588760c051c1aa5f898eb
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/containers/scoped_ptr_hash_map.h"
10 #include "base/threading/thread_local_storage.h"
11 #include "base/timer/timer.h"
12 #include "base/trace_event/trace_event.h"
13 #include "components/webcrypto/webcrypto_impl.h"
14 #include "content/child/webfallbackthemeengine_impl.h"
15 #include "content/common/content_export.h"
16 #include "third_party/WebKit/public/platform/Platform.h"
17 #include "third_party/WebKit/public/platform/WebGestureDevice.h"
18 #include "third_party/WebKit/public/platform/WebURLError.h"
19 #include "ui/base/layout.h"
21 #if defined(USE_DEFAULT_RENDER_THEME)
22 #include "content/child/webthemeengine_impl_default.h"
23 #elif defined(OS_WIN)
24 #include "content/child/webthemeengine_impl_win.h"
25 #elif defined(OS_MACOSX)
26 #include "content/child/webthemeengine_impl_mac.h"
27 #elif defined(OS_ANDROID)
28 #include "content/child/webthemeengine_impl_android.h"
29 #endif
31 namespace base {
32 class MessageLoop;
35 namespace content {
36 class BackgroundSyncProvider;
37 class FlingCurveConfiguration;
38 class NotificationDispatcher;
39 class PermissionDispatcher;
40 class PushDispatcher;
41 class ThreadSafeSender;
42 class WebBluetoothImpl;
43 class WebCryptoImpl;
44 class WebGeofencingProviderImpl;
45 class WebMemoryDumpProviderAdapter;
47 class CONTENT_EXPORT BlinkPlatformImpl
48 : NON_EXPORTED_BASE(public blink::Platform) {
49 public:
50 BlinkPlatformImpl();
51 explicit BlinkPlatformImpl(
52 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner);
53 virtual ~BlinkPlatformImpl();
55 // Platform methods (partial implementation):
56 virtual blink::WebThemeEngine* themeEngine();
57 virtual blink::WebFallbackThemeEngine* fallbackThemeEngine();
58 virtual blink::Platform::FileHandle databaseOpenFile(
59 const blink::WebString& vfs_file_name, int desired_flags);
60 virtual int databaseDeleteFile(const blink::WebString& vfs_file_name,
61 bool sync_dir);
62 virtual long databaseGetFileAttributes(
63 const blink::WebString& vfs_file_name);
64 virtual long long databaseGetFileSize(const blink::WebString& vfs_file_name);
65 virtual long long databaseGetSpaceAvailableForOrigin(
66 const blink::WebString& origin_identifier);
67 virtual bool databaseSetFileSize(
68 const blink::WebString& vfs_file_name, long long size);
69 virtual blink::WebString signedPublicKeyAndChallengeString(
70 unsigned key_size_index, const blink::WebString& challenge,
71 const blink::WebURL& url);
72 virtual size_t memoryUsageMB();
73 virtual size_t actualMemoryUsageMB();
74 virtual size_t physicalMemoryMB();
75 virtual size_t virtualMemoryLimitMB();
76 virtual size_t numberOfProcessors();
78 virtual bool processMemorySizesInBytes(size_t* private_bytes,
79 size_t* shared_bytes);
80 virtual bool memoryAllocatorWasteInBytes(size_t* size);
81 virtual blink::WebDiscardableMemory* allocateAndLockDiscardableMemory(
82 size_t bytes);
83 virtual size_t maxDecodedImageBytes();
84 virtual uint32_t getUniqueIdForProcess();
85 virtual blink::WebURLLoader* createURLLoader();
86 virtual blink::WebSocketHandle* createWebSocketHandle();
87 virtual blink::WebString userAgent();
88 virtual blink::WebData parseDataURL(
89 const blink::WebURL& url, blink::WebString& mimetype,
90 blink::WebString& charset);
91 virtual blink::WebURLError cancelledError(const blink::WebURL& url) const;
92 virtual bool isReservedIPAddress(const blink::WebString& host) const;
93 virtual bool portAllowed(const blink::WebURL& url) const;
94 virtual blink::WebThread* createThread(const char* name);
95 virtual blink::WebThread* currentThread();
96 virtual void yieldCurrentThread();
97 virtual blink::WebWaitableEvent* createWaitableEvent(
98 blink::WebWaitableEvent::ResetPolicy policy,
99 blink::WebWaitableEvent::InitialState state);
100 virtual blink::WebWaitableEvent* waitMultipleEvents(
101 const blink::WebVector<blink::WebWaitableEvent*>& events);
102 virtual void decrementStatsCounter(const char* name);
103 virtual void incrementStatsCounter(const char* name);
104 virtual void histogramCustomCounts(
105 const char* name, int sample, int min, int max, int bucket_count);
106 virtual void histogramEnumeration(
107 const char* name, int sample, int boundary_value);
108 virtual void histogramSparse(const char* name, int sample);
109 virtual const unsigned char* getTraceCategoryEnabledFlag(
110 const char* category_name);
111 virtual TraceEventAPIAtomicWord* getTraceSamplingState(
112 const unsigned thread_bucket);
113 virtual TraceEventHandle addTraceEvent(
114 char phase,
115 const unsigned char* category_group_enabled,
116 const char* name,
117 unsigned long long id,
118 double timestamp,
119 int num_args,
120 const char** arg_names,
121 const unsigned char* arg_types,
122 const unsigned long long* arg_values,
123 unsigned char flags);
124 virtual TraceEventHandle addTraceEvent(
125 char phase,
126 const unsigned char* category_group_enabled,
127 const char* name,
128 unsigned long long id,
129 double timestamp,
130 int num_args,
131 const char** arg_names,
132 const unsigned char* arg_types,
133 const unsigned long long* arg_values,
134 blink::WebConvertableToTraceFormat* convertable_values,
135 unsigned char flags);
136 virtual void updateTraceEventDuration(
137 const unsigned char* category_group_enabled,
138 const char* name,
139 TraceEventHandle);
140 virtual void registerMemoryDumpProvider(blink::WebMemoryDumpProvider* wmdp);
141 virtual void unregisterMemoryDumpProvider(blink::WebMemoryDumpProvider* wmdp);
142 virtual blink::WebProcessMemoryDump* createProcessMemoryDump();
143 virtual blink::Platform::WebMemoryAllocatorDumpGuid
144 createWebMemoryAllocatorDumpGuid(const blink::WebString& guidStr);
146 virtual blink::WebData loadResource(const char* name);
147 virtual blink::WebString queryLocalizedString(
148 blink::WebLocalizedString::Name name);
149 virtual blink::WebString queryLocalizedString(
150 blink::WebLocalizedString::Name name, int numeric_value);
151 virtual blink::WebString queryLocalizedString(
152 blink::WebLocalizedString::Name name, const blink::WebString& value);
153 virtual blink::WebString queryLocalizedString(
154 blink::WebLocalizedString::Name name,
155 const blink::WebString& value1, const blink::WebString& value2);
156 virtual void suddenTerminationChanged(bool enabled) { }
157 virtual double currentTime();
158 virtual double monotonicallyIncreasingTime();
159 virtual double systemTraceTime();
160 virtual void cryptographicallyRandomValues(
161 unsigned char* buffer, size_t length);
162 virtual blink::WebGestureCurve* createFlingAnimationCurve(
163 blink::WebGestureDevice device_source,
164 const blink::WebFloatPoint& velocity,
165 const blink::WebSize& cumulative_scroll);
166 virtual void didStartWorkerRunLoop();
167 virtual void didStopWorkerRunLoop();
168 virtual blink::WebCrypto* crypto();
169 virtual blink::WebGeofencingProvider* geofencingProvider();
170 virtual blink::WebBluetooth* bluetooth();
171 virtual blink::WebNotificationManager* notificationManager();
172 virtual blink::WebPushProvider* pushProvider();
173 virtual blink::WebServicePortProvider* createServicePortProvider(
174 blink::WebServicePortProviderClient*);
175 virtual blink::WebPermissionClient* permissionClient();
176 virtual blink::WebSyncProvider* backgroundSyncProvider();
178 virtual blink::WebString domCodeStringFromEnum(int dom_code);
179 virtual int domEnumFromCodeString(const blink::WebString& codeString);
181 private:
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::ThreadLocalStorage::Slot current_thread_slot_;
193 webcrypto::WebCryptoImpl web_crypto_;
194 scoped_ptr<WebGeofencingProviderImpl> geofencing_provider_;
195 scoped_ptr<WebBluetoothImpl> bluetooth_;
196 base::ScopedPtrHashMap<blink::WebMemoryDumpProvider*,
197 scoped_ptr<WebMemoryDumpProviderAdapter>>
198 memory_dump_providers_;
200 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
201 scoped_refptr<NotificationDispatcher> notification_dispatcher_;
202 scoped_refptr<PushDispatcher> push_dispatcher_;
203 scoped_ptr<PermissionDispatcher> permission_client_;
204 scoped_ptr<BackgroundSyncProvider> sync_provider_;
207 } // namespace content
209 #endif // CONTENT_CHILD_BLINK_PLATFORM_IMPL_H_