Update UnusedResources lint suppressions.
[chromium-blink-merge.git] / content / child / blink_platform_impl.h
blob6b120c043b9e033823175b9d1e96e82cd22becf6
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 virtual blink::WebWaitableEvent* waitMultipleEvents(
99 const blink::WebVector<blink::WebWaitableEvent*>& events);
100 virtual void decrementStatsCounter(const char* name);
101 virtual void incrementStatsCounter(const char* name);
102 virtual void histogramCustomCounts(
103 const char* name, int sample, int min, int max, int bucket_count);
104 virtual void histogramEnumeration(
105 const char* name, int sample, int boundary_value);
106 virtual void histogramSparse(const char* name, int sample);
107 virtual const unsigned char* getTraceCategoryEnabledFlag(
108 const char* category_name);
109 virtual TraceEventAPIAtomicWord* getTraceSamplingState(
110 const unsigned thread_bucket);
111 virtual TraceEventHandle addTraceEvent(
112 char phase,
113 const unsigned char* category_group_enabled,
114 const char* name,
115 unsigned long long id,
116 double timestamp,
117 int num_args,
118 const char** arg_names,
119 const unsigned char* arg_types,
120 const unsigned long long* arg_values,
121 unsigned char flags);
122 virtual TraceEventHandle addTraceEvent(
123 char phase,
124 const unsigned char* category_group_enabled,
125 const char* name,
126 unsigned long long id,
127 double timestamp,
128 int num_args,
129 const char** arg_names,
130 const unsigned char* arg_types,
131 const unsigned long long* arg_values,
132 blink::WebConvertableToTraceFormat* convertable_values,
133 unsigned char flags);
134 virtual void updateTraceEventDuration(
135 const unsigned char* category_group_enabled,
136 const char* name,
137 TraceEventHandle);
138 virtual void registerMemoryDumpProvider(blink::WebMemoryDumpProvider* wmdp);
139 virtual void unregisterMemoryDumpProvider(blink::WebMemoryDumpProvider* wmdp);
140 virtual blink::WebProcessMemoryDump* createProcessMemoryDump();
141 virtual blink::Platform::WebMemoryAllocatorDumpGuid
142 createWebMemoryAllocatorDumpGuid(const blink::WebString& guidStr);
144 virtual blink::WebData loadResource(const char* name);
145 virtual blink::WebString queryLocalizedString(
146 blink::WebLocalizedString::Name name);
147 virtual blink::WebString queryLocalizedString(
148 blink::WebLocalizedString::Name name, int numeric_value);
149 virtual blink::WebString queryLocalizedString(
150 blink::WebLocalizedString::Name name, const blink::WebString& value);
151 virtual blink::WebString queryLocalizedString(
152 blink::WebLocalizedString::Name name,
153 const blink::WebString& value1, const blink::WebString& value2);
154 virtual void suddenTerminationChanged(bool enabled) { }
155 virtual double currentTime();
156 virtual double monotonicallyIncreasingTime();
157 virtual double systemTraceTime();
158 virtual void cryptographicallyRandomValues(
159 unsigned char* buffer, size_t length);
160 virtual blink::WebGestureCurve* createFlingAnimationCurve(
161 blink::WebGestureDevice device_source,
162 const blink::WebFloatPoint& velocity,
163 const blink::WebSize& cumulative_scroll);
164 virtual void didStartWorkerRunLoop();
165 virtual void didStopWorkerRunLoop();
166 virtual blink::WebCrypto* crypto();
167 virtual blink::WebGeofencingProvider* geofencingProvider();
168 virtual blink::WebBluetooth* bluetooth();
169 virtual blink::WebNotificationManager* notificationManager();
170 virtual blink::WebPushProvider* pushProvider();
171 virtual blink::WebServicePortProvider* createServicePortProvider(
172 blink::WebServicePortProviderClient*);
173 virtual blink::WebPermissionClient* permissionClient();
174 virtual blink::WebSyncProvider* backgroundSyncProvider();
176 virtual blink::WebString domCodeStringFromEnum(int dom_code);
177 virtual int domEnumFromCodeString(const blink::WebString& codeString);
179 private:
180 void InternalInit();
181 void UpdateWebThreadTLS(blink::WebThread* thread);
183 bool IsMainThread() const;
185 scoped_refptr<base::SingleThreadTaskRunner> MainTaskRunnerForCurrentThread();
187 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
188 WebThemeEngineImpl native_theme_engine_;
189 WebFallbackThemeEngineImpl fallback_theme_engine_;
190 base::ThreadLocalStorage::Slot current_thread_slot_;
191 webcrypto::WebCryptoImpl web_crypto_;
192 scoped_ptr<WebGeofencingProviderImpl> geofencing_provider_;
193 scoped_ptr<WebBluetoothImpl> bluetooth_;
194 base::ScopedPtrHashMap<blink::WebMemoryDumpProvider*,
195 scoped_ptr<WebMemoryDumpProviderAdapter>>
196 memory_dump_providers_;
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_;
202 scoped_ptr<BackgroundSyncProvider> sync_provider_;
205 } // namespace content
207 #endif // CONTENT_CHILD_BLINK_PLATFORM_IMPL_H_