Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / public / platform / Platform.h
blob7d6cb901398636564bbfc20e0ec56b37761aafc2
1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef Platform_h
32 #define Platform_h
34 #ifdef WIN32
35 #include <windows.h>
36 #endif
38 #include "WebAudioDevice.h"
39 #include "WebBatteryStatusListener.h"
40 #include "WebCommon.h"
41 #include "WebData.h"
42 #include "WebDeviceLightListener.h"
43 #include "WebGamepadListener.h"
44 #include "WebGamepads.h"
45 #include "WebGestureDevice.h"
46 #include "WebGraphicsContext3D.h"
47 #include "WebLocalizedString.h"
48 #include "WebPlatformEventType.h"
49 #include "WebSize.h"
50 #include "WebSpeechSynthesizer.h"
51 #include "WebStorageQuotaCallbacks.h"
52 #include "WebStorageQuotaType.h"
53 #include "WebString.h"
54 #include "WebURLError.h"
55 #include "WebVector.h"
56 #include "WebWaitableEvent.h"
58 #include <vector>
60 class GrContext;
62 namespace blink {
64 class WebAudioBus;
65 class WebBlobRegistry;
66 class WebBluetooth;
67 class WebClipboard;
68 class WebCompositorSupport;
69 class WebConvertableToTraceFormat;
70 class WebCookieJar;
71 class WebCrypto;
72 class WebDatabaseObserver;
73 class WebDiscardableMemory;
74 class WebPlatformEventListener;
75 class WebFallbackThemeEngine;
76 class WebFileSystem;
77 class WebFileUtilities;
78 class WebFlingAnimator;
79 class WebGeofencingProvider;
80 class WebGestureCurve;
81 class WebGraphicsContext3DProvider;
82 class WebIDBFactory;
83 class WebMIDIAccessor;
84 class WebMIDIAccessorClient;
85 class WebMediaRecorderHandler;
86 class WebMediaStreamCenter;
87 class WebMediaStreamCenterClient;
88 class WebMemoryDumpProvider;
89 class WebMessagePortChannel;
90 class WebMimeRegistry;
91 class WebNavigatorConnectProvider;
92 class WebNotificationManager;
93 class WebPermissionClient;
94 class WebPluginListBuilder;
95 class WebPrescientNetworking;
96 class WebProcessMemoryDump;
97 class WebPublicSuffixList;
98 class WebPushProvider;
99 class WebRTCPeerConnectionHandler;
100 class WebRTCPeerConnectionHandlerClient;
101 class WebSandboxSupport;
102 class WebScrollbarBehavior;
103 class WebSecurityOrigin;
104 class WebServicePortProvider;
105 class WebServicePortProviderClient;
106 class WebServiceWorkerCacheStorage;
107 class WebSocketHandle;
108 class WebSpeechSynthesizer;
109 class WebSpeechSynthesizerClient;
110 class WebStorageNamespace;
111 class WebSyncProvider;
112 struct WebFloatPoint;
113 class WebThemeEngine;
114 class WebThread;
115 class WebURL;
116 class WebURLLoader;
117 class WebUnitTestSupport;
118 struct WebLocalizedString;
119 struct WebSize;
121 class Platform {
122 public:
123 // HTML5 Database ------------------------------------------------------
125 #ifdef WIN32
126 typedef HANDLE FileHandle;
127 #else
128 typedef int FileHandle;
129 #endif
131 BLINK_PLATFORM_EXPORT static void initialize(Platform*);
132 BLINK_PLATFORM_EXPORT static void shutdown();
133 BLINK_PLATFORM_EXPORT static Platform* current();
135 // May return null.
136 virtual WebCookieJar* cookieJar() { return nullptr; }
138 // Must return non-null.
139 virtual WebClipboard* clipboard() { return nullptr; }
141 // Must return non-null.
142 virtual WebFileUtilities* fileUtilities() { return nullptr; }
144 // Must return non-null.
145 virtual WebMimeRegistry* mimeRegistry() { return nullptr; }
147 // May return null if sandbox support is not necessary
148 virtual WebSandboxSupport* sandboxSupport() { return nullptr; }
150 // May return null on some platforms.
151 virtual WebThemeEngine* themeEngine() { return nullptr; }
153 virtual WebFallbackThemeEngine* fallbackThemeEngine() { return nullptr; }
155 // May return null.
156 virtual WebSpeechSynthesizer* createSpeechSynthesizer(WebSpeechSynthesizerClient*) { return nullptr; }
159 // Audio --------------------------------------------------------------
161 virtual double audioHardwareSampleRate() { return 0; }
162 virtual size_t audioHardwareBufferSize() { return 0; }
163 virtual unsigned audioHardwareOutputChannels() { return 0; }
165 // Creates a device for audio I/O.
166 // Pass in (numberOfInputChannels > 0) if live/local audio input is desired.
167 virtual WebAudioDevice* createAudioDevice(size_t bufferSize, unsigned numberOfInputChannels, unsigned numberOfChannels, double sampleRate, WebAudioDevice::RenderCallback*, const WebString& deviceId) { return nullptr; }
170 // MIDI ----------------------------------------------------------------
172 // Creates a platform dependent WebMIDIAccessor. MIDIAccessor under platform
173 // creates and owns it.
174 virtual WebMIDIAccessor* createMIDIAccessor(WebMIDIAccessorClient*) { return nullptr; }
177 // Blob ----------------------------------------------------------------
179 // Must return non-null.
180 virtual WebBlobRegistry* blobRegistry() { return nullptr; }
182 // Database ------------------------------------------------------------
184 // Opens a database file; dirHandle should be 0 if the caller does not need
185 // a handle to the directory containing this file
186 virtual FileHandle databaseOpenFile(const WebString& vfsFileName, int desiredFlags) { return FileHandle(); }
188 // Deletes a database file and returns the error code
189 virtual int databaseDeleteFile(const WebString& vfsFileName, bool syncDir) { return 0; }
191 // Returns the attributes of the given database file
192 virtual long databaseGetFileAttributes(const WebString& vfsFileName) { return 0; }
194 // Returns the size of the given database file
195 virtual long long databaseGetFileSize(const WebString& vfsFileName) { return 0; }
197 // Returns the space available for the given origin
198 virtual long long databaseGetSpaceAvailableForOrigin(const WebString& originIdentifier) { return 0; }
200 // Set the size of the given database file
201 virtual bool databaseSetFileSize(const WebString& vfsFileName, long long size) { return false; }
204 // DOM Storage --------------------------------------------------
206 // Return a LocalStorage namespace
207 virtual WebStorageNamespace* createLocalStorageNamespace() { return nullptr; }
210 // FileSystem ----------------------------------------------------------
212 // Must return non-null.
213 virtual WebFileSystem* fileSystem() { return nullptr; }
216 // IDN conversion ------------------------------------------------------
218 virtual WebString convertIDNToUnicode(const WebString& host, const WebString& languages) { return host; }
221 // IndexedDB ----------------------------------------------------------
223 // Must return non-null.
224 virtual WebIDBFactory* idbFactory() { return nullptr; }
227 // Cache Storage ----------------------------------------------------------
229 // The caller is responsible for deleting the returned object.
230 virtual WebServiceWorkerCacheStorage* cacheStorage(const WebString& originIdentifier) { return nullptr; }
232 // Gamepad -------------------------------------------------------------
234 virtual void sampleGamepads(WebGamepads& into) { into.length = 0; }
236 // History -------------------------------------------------------------
238 // Returns the hash for the given canonicalized URL for use in visited
239 // link coloring.
240 virtual unsigned long long visitedLinkHash(
241 const char* canonicalURL, size_t length) { return 0; }
243 // Returns whether the given link hash is in the user's history. The
244 // hash must have been generated by calling VisitedLinkHash().
245 virtual bool isLinkVisited(unsigned long long linkHash) { return false; }
248 // Keygen --------------------------------------------------------------
250 // Handle the <keygen> tag for generating client certificates
251 // Returns a base64 encoded signed copy of a public key from a newly
252 // generated key pair and the supplied challenge string. keySizeindex
253 // specifies the strength of the key.
254 virtual WebString signedPublicKeyAndChallengeString(unsigned keySizeIndex,
255 const WebString& challenge,
256 const WebURL& url) { return WebString(); }
259 // Memory --------------------------------------------------------------
261 // Returns the current space allocated for the pagefile, in MB.
262 // That is committed size for Windows and virtual memory size for POSIX
263 virtual size_t memoryUsageMB() { return 0; }
265 // Same as above, but always returns actual value, without any caches.
266 virtual size_t actualMemoryUsageMB() { return 0; }
268 // Return the physical memory of the current machine, in MB.
269 virtual size_t physicalMemoryMB() { return 0; }
271 // Return the available virtual memory of the current machine, in MB. Or
272 // zero, if there is no limit.
273 virtual size_t virtualMemoryLimitMB() { return 0; }
275 // True when Blink runs on low end devices.
276 virtual bool isLowEndDeviceMode() { return false; }
278 // Return the number of of processors of the current machine.
279 virtual size_t numberOfProcessors() { return 0; }
281 // Returns private and shared usage, in bytes. Private bytes is the amount of
282 // memory currently allocated to this process that cannot be shared. Returns
283 // false on platform specific error conditions.
284 virtual bool processMemorySizesInBytes(size_t* privateBytes, size_t* sharedBytes) { return false; }
286 // Reports number of bytes used by memory allocator for internal needs.
287 // Returns true if the size has been reported, or false otherwise.
288 virtual bool memoryAllocatorWasteInBytes(size_t*) { return false; }
290 // Allocates discardable memory. May return nullptr, even if the platform supports
291 // discardable memory. If nonzero, however, then the WebDiscardableMmeory is
292 // returned in an locked state. You may use its underlying data() member
293 // directly, taking care to unlock it when you are ready to let it become
294 // discardable.
295 virtual WebDiscardableMemory* allocateAndLockDiscardableMemory(size_t bytes) { return nullptr; }
297 static const size_t noDecodedImageByteLimit = static_cast<size_t>(-1);
299 // Returns the maximum amount of memory a decoded image should be allowed.
300 // See comments on ImageDecoder::m_maxDecodedBytes.
301 virtual size_t maxDecodedImageBytes() { return noDecodedImageByteLimit; }
303 // Process -------------------------------------------------------------
305 // Returns a unique identifier for a process. This may not necessarily be
306 // the process's process ID.
307 virtual uint32_t getUniqueIdForProcess() { return 0; }
310 // Message Ports -------------------------------------------------------
312 // Creates a Message Port Channel pair. This can be called on any thread.
313 // The returned objects should only be used on the thread they were created on.
314 virtual void createMessageChannel(WebMessagePortChannel** channel1, WebMessagePortChannel** channel2) { *channel1 = 0; *channel2 = 0; }
317 // Network -------------------------------------------------------------
319 // Returns a new WebURLLoader instance.
320 virtual WebURLLoader* createURLLoader() { return nullptr; }
322 // May return null.
323 virtual WebPrescientNetworking* prescientNetworking() { return nullptr; }
325 // Returns a new WebSocketHandle instance.
326 virtual WebSocketHandle* createWebSocketHandle() { return nullptr; }
328 // Returns the User-Agent string.
329 virtual WebString userAgent() { return WebString(); }
331 // A suggestion to cache this metadata in association with this URL.
332 virtual void cacheMetadata(const WebURL&, int64 responseTime, const char* data, size_t dataSize) { }
334 // Returns the decoded data url if url had a supported mimetype and parsing was successful.
335 virtual WebData parseDataURL(const WebURL&, WebString& mimetype, WebString& charset) { return WebData(); }
337 virtual WebURLError cancelledError(const WebURL&) const { return WebURLError(); }
339 virtual bool isReservedIPAddress(const WebString& host) const { return false; }
341 virtual bool portAllowed(const WebURL&) const { return false; }
343 // Plugins -------------------------------------------------------------
345 // If refresh is true, then cached information should not be used to
346 // satisfy this call.
347 virtual void getPluginList(bool refresh, WebPluginListBuilder*) { }
350 // Public Suffix List --------------------------------------------------
352 // May return null on some platforms.
353 virtual WebPublicSuffixList* publicSuffixList() { return nullptr; }
356 // Resources -----------------------------------------------------------
358 // Returns a localized string resource (with substitution parameters).
359 virtual WebString queryLocalizedString(WebLocalizedString::Name) { return WebString(); }
360 virtual WebString queryLocalizedString(WebLocalizedString::Name, const WebString& parameter) { return WebString(); }
361 virtual WebString queryLocalizedString(WebLocalizedString::Name, const WebString& parameter1, const WebString& parameter2) { return WebString(); }
364 // Threads -------------------------------------------------------
366 // Creates an embedder-defined thread.
367 virtual WebThread* createThread(const char* name) { return nullptr; }
369 // Returns an interface to the current thread. This is owned by the
370 // embedder.
371 virtual WebThread* currentThread() { return nullptr; }
373 // Yield the current thread so another thread can be scheduled.
374 virtual void yieldCurrentThread() { }
376 // WaitableEvent -------------------------------------------------------
378 // Creates an embedder-defined waitable event object.
379 WebWaitableEvent* createWaitableEvent() { return createWaitableEvent(WebWaitableEvent::ResetPolicy::Auto, WebWaitableEvent::InitialState::NonSignaled); }
380 virtual WebWaitableEvent* createWaitableEvent(WebWaitableEvent::ResetPolicy, WebWaitableEvent::InitialState) { return nullptr; }
382 // Waits on multiple events and returns the event object that has been
383 // signaled. This may return nullptr if it fails to wait events.
384 // Any event objects given to this method must not deleted while this
385 // wait is happening.
386 virtual WebWaitableEvent* waitMultipleEvents(const WebVector<WebWaitableEvent*>& events) { return nullptr; }
389 // Profiling -----------------------------------------------------------
391 virtual void decrementStatsCounter(const char* name) { }
392 virtual void incrementStatsCounter(const char* name) { }
395 // Resources -----------------------------------------------------------
397 // Returns a blob of data corresponding to the named resource.
398 virtual WebData loadResource(const char* name) { return WebData(); }
400 // Decodes the in-memory audio file data and returns the linear PCM audio data in the destinationBus.
401 // A sample-rate conversion to sampleRate will occur if the file data is at a different sample-rate.
402 // Returns true on success.
403 virtual bool loadAudioResource(WebAudioBus* destinationBus, const char* audioFileData, size_t dataSize) { return false; }
405 // Screen -------------------------------------------------------------
407 // Supplies the system monitor color profile.
408 virtual void screenColorProfile(WebVector<char>* profile) { }
411 // Scrollbar ----------------------------------------------------------
413 // Must return non-null.
414 virtual WebScrollbarBehavior* scrollbarBehavior() { return nullptr; }
417 // Sudden Termination --------------------------------------------------
419 // Disable/Enable sudden termination on a process level. When possible, it
420 // is preferable to disable sudden termination on a per-frame level via
421 // WebFrameClient::suddenTerminationDisablerChanged.
422 virtual void suddenTerminationChanged(bool enabled) { }
425 // System --------------------------------------------------------------
427 // Returns a value such as "en-US".
428 virtual WebString defaultLocale() { return WebString(); }
430 // Wall clock time in seconds since the epoch.
431 virtual double currentTime() { return 0; }
433 // Monotonically increasing time in seconds from an arbitrary fixed point in the past.
434 // This function is expected to return at least millisecond-precision values. For this reason,
435 // it is recommended that the fixed point be no further in the past than the epoch.
436 virtual double monotonicallyIncreasingTime() { return 0; }
438 // System trace time in seconds. For example, on Chrome OS, this timestamp should be
439 // synchronized with ftrace timestamps.
440 virtual double systemTraceTime() { return 0; }
442 // WebKit clients must implement this funcion if they use cryptographic randomness.
443 virtual void cryptographicallyRandomValues(unsigned char* buffer, size_t length) = 0;
445 // Returns an interface to the main thread. Can be null if blink was initialized on a thread without a message loop.
446 BLINK_PLATFORM_EXPORT WebThread* mainThread() const;
448 // Vibration -----------------------------------------------------------
450 // Starts a vibration for the given duration in milliseconds. If there is currently an active
451 // vibration it will be cancelled before the new one is started.
452 virtual void vibrate(unsigned time) { }
454 // Cancels the current vibration, if there is one.
455 virtual void cancelVibration() { }
458 // Testing -------------------------------------------------------------
460 // Get a pointer to testing support interfaces. Will not be available in production builds.
461 virtual WebUnitTestSupport* unitTestSupport() { return nullptr; }
464 // Tracing -------------------------------------------------------------
466 // Get a pointer to the enabled state of the given trace category. The
467 // embedder can dynamically change the enabled state as trace event
468 // recording is started and stopped by the application. Only long-lived
469 // literal strings should be given as the category name. The implementation
470 // expects the returned pointer to be held permanently in a local static. If
471 // the unsigned char is non-zero, tracing is enabled. If tracing is enabled,
472 // addTraceEvent is expected to be called by the trace event macros.
473 virtual const unsigned char* getTraceCategoryEnabledFlag(const char* categoryName) { return nullptr; }
475 typedef intptr_t TraceEventAPIAtomicWord;
477 // Get a pointer to a global state of the given thread. An embedder is
478 // expected to update the global state as the state of the embedder changes.
479 // A sampling thread in the Chromium side reads the global state periodically
480 // and reflects the sampling profiled results into about:tracing.
481 virtual TraceEventAPIAtomicWord* getTraceSamplingState(const unsigned bucketName) { return nullptr; }
483 typedef uint64_t TraceEventHandle;
485 // Add a trace event to the platform tracing system. Depending on the actual
486 // enabled state, this event may be recorded or dropped.
487 // - phase specifies the type of event:
488 // - BEGIN ('B'): Marks the beginning of a scoped event.
489 // - END ('E'): Marks the end of a scoped event.
490 // - COMPLETE ('X'): Marks the beginning of a scoped event, but doesn't
491 // need a matching END event. Instead, at the end of the scope,
492 // updateTraceEventDuration() must be called with the TraceEventHandle
493 // returned from addTraceEvent().
494 // - INSTANT ('I'): Standalone, instantaneous event.
495 // - START ('S'): Marks the beginning of an asynchronous event (the end
496 // event can occur in a different scope or thread). The id parameter is
497 // used to match START/FINISH pairs.
498 // - FINISH ('F'): Marks the end of an asynchronous event.
499 // - COUNTER ('C'): Used to trace integer quantities that change over
500 // time. The argument values are expected to be of type int.
501 // - METADATA ('M'): Reserved for internal use.
502 // - categoryEnabled is the pointer returned by getTraceCategoryEnabledFlag.
503 // - name is the name of the event. Also used to match BEGIN/END and
504 // START/FINISH pairs.
505 // - id optionally allows events of the same name to be distinguished from
506 // each other. For example, to trace the consutruction and destruction of
507 // objects, specify the pointer as the id parameter.
508 // - numArgs specifies the number of elements in argNames, argTypes, and
509 // argValues.
510 // - argNames is the array of argument names. Use long-lived literal strings
511 // or specify the COPY flag.
512 // - argTypes is the array of argument types:
513 // - BOOL (1): bool
514 // - UINT (2): unsigned long long
515 // - INT (3): long long
516 // - DOUBLE (4): double
517 // - POINTER (5): void*
518 // - STRING (6): char* (long-lived null-terminated char* string)
519 // - COPY_STRING (7): char* (temporary null-terminated char* string)
520 // - CONVERTABLE (8): WebConvertableToTraceFormat
521 // - argValues is the array of argument values. Each value is the unsigned
522 // long long member of a union of all supported types.
523 // - convertableValues is the array of WebConvertableToTraceFormat classes
524 // that may be converted to trace format by calling asTraceFormat method.
525 // ConvertableToTraceFormat interface.
526 // convertableValues can be moved to another object by
527 // WebConvertableToTraceFormat::moveFrom() in addTraceEvent(), and thus
528 // should not be dereferenced (e.g. asTraceFormat() should not be called)
529 // after return from addTraceEvent().
530 // - thresholdBeginId optionally specifies the value returned by a previous
531 // call to addTraceEvent with a BEGIN phase.
532 // - threshold is used on an END phase event in conjunction with the
533 // thresholdBeginId of a prior BEGIN event. The threshold is the minimum
534 // number of microseconds that must have passed since the BEGIN event. If
535 // less than threshold microseconds has passed, the BEGIN/END pair is
536 // dropped.
537 // - flags can be 0 or one or more of the following, ORed together:
538 // - COPY (0x1): treat all strings (name, argNames and argValues of type
539 // string) as temporary so that they will be copied by addTraceEvent.
540 // - HAS_ID (0x2): use the id argument to uniquely identify the event for
541 // matching with other events of the same name.
542 // - MANGLE_ID (0x4): specify this flag if the id parameter is the value
543 // of a pointer.
544 virtual TraceEventHandle addTraceEvent(
545 char phase,
546 const unsigned char* categoryEnabledFlag,
547 const char* name,
548 unsigned long long id,
549 double timestamp,
550 int numArgs,
551 const char** argNames,
552 const unsigned char* argTypes,
553 const unsigned long long* argValues,
554 WebConvertableToTraceFormat* convertableValues,
555 unsigned char flags)
557 return 0;
560 // Set the duration field of a COMPLETE trace event.
561 virtual void updateTraceEventDuration(const unsigned char* categoryEnabledFlag, const char* name, TraceEventHandle) { }
563 // Callbacks for reporting histogram data.
564 // CustomCounts histogram has exponential bucket sizes, so that min=1, max=1000000, bucketCount=50 would do.
565 virtual void histogramCustomCounts(const char* name, int sample, int min, int max, int bucketCount) { }
566 // Enumeration histogram buckets are linear, boundaryValue should be larger than any possible sample value.
567 virtual void histogramEnumeration(const char* name, int sample, int boundaryValue) { }
568 // Unlike enumeration histograms, sparse histograms only allocate memory for non-empty buckets.
569 virtual void histogramSparse(const char* name, int sample) { }
571 // Record to a RAPPOR privacy-preserving metric, see: https://www.chromium.org/developers/design-documents/rappor.
572 // recordRappor records a sample string, while recordRapporURL records the domain and registry of a url.
573 virtual void recordRappor(const char* metric, const WebString& sample) { }
574 virtual void recordRapporURL(const char* metric, const blink::WebURL& url) { }
576 // Registers a memory dump provider. The WebMemoryDumpProvider::onMemoryDump
577 // method will be called on the same thread that called the
578 // registerMemoryDumpProvider() method.
579 // See crbug.com/458295 for design docs.
580 virtual void registerMemoryDumpProvider(blink::WebMemoryDumpProvider*) { }
582 // Must be called on the thread that called registerMemoryDumpProvider().
583 virtual void unregisterMemoryDumpProvider(blink::WebMemoryDumpProvider*) { }
585 // Returns a newly allocated WebProcessMemoryDump instance.
586 virtual blink::WebProcessMemoryDump* createProcessMemoryDump() { return nullptr; }
588 typedef uint64_t WebMemoryAllocatorDumpGuid;
590 // Returns guid corresponding to the given string (the hash value) for
591 // creating a WebMemoryAllocatorDump.
592 virtual WebMemoryAllocatorDumpGuid createWebMemoryAllocatorDumpGuid(const WebString& guidStr) { return 0; }
594 // GPU ----------------------------------------------------------------
596 // May return null if GPU is not supported.
597 // Returns newly allocated and initialized offscreen WebGraphicsContext3D instance.
598 // Passing an existing context to shareContext will create the new context in the same share group as the passed context.
599 virtual WebGraphicsContext3D* createOffscreenGraphicsContext3D(const WebGraphicsContext3D::Attributes&, WebGraphicsContext3D* shareContext) { return nullptr; }
600 virtual WebGraphicsContext3D* createOffscreenGraphicsContext3D(const WebGraphicsContext3D::Attributes&, WebGraphicsContext3D* shareContext, WebGLInfo* glInfo) { return nullptr; }
601 virtual WebGraphicsContext3D* createOffscreenGraphicsContext3D(const WebGraphicsContext3D::Attributes&) { return nullptr; }
603 // Returns a newly allocated and initialized offscreen context provider. The provider may return a null
604 // graphics context if GPU is not supported.
605 virtual WebGraphicsContext3DProvider* createSharedOffscreenGraphicsContext3DProvider() { return nullptr; }
607 // Returns true if the platform is capable of producing an offscreen context suitable for accelerating 2d canvas.
608 // This will return false if the platform cannot promise that contexts will be preserved across operations like
609 // locking the screen or if the platform cannot provide a context with suitable performance characteristics.
611 // This value must be checked again after a context loss event as the platform's capabilities may have changed.
612 virtual bool canAccelerate2dCanvas() { return false; }
614 virtual bool isThreadedCompositingEnabled() { return false; }
615 virtual bool isThreadedAnimationEnabled() { return true; }
617 virtual WebCompositorSupport* compositorSupport() { return nullptr; }
619 virtual WebFlingAnimator* createFlingAnimator() { return nullptr; }
621 // Creates a new fling animation curve instance for device |deviceSource|
622 // with |velocity| and already scrolled |cumulativeScroll| pixels.
623 virtual WebGestureCurve* createFlingAnimationCurve(WebGestureDevice deviceSource, const WebFloatPoint& velocity, const WebSize& cumulativeScroll) { return nullptr; }
625 // WebRTC ----------------------------------------------------------
627 // Creates an WebRTCPeerConnectionHandler for RTCPeerConnection.
628 // May return null if WebRTC functionality is not avaliable or out of resources.
629 virtual WebRTCPeerConnectionHandler* createRTCPeerConnectionHandler(WebRTCPeerConnectionHandlerClient*) { return nullptr; }
631 // Creates an WebMediaRecorderHandler to record MediaStreams.
632 // May return null if the functionality is not available or out of resources.
633 virtual WebMediaRecorderHandler* createMediaRecorderHandler() { return nullptr; }
635 // May return null if WebRTC functionality is not avaliable or out of resources.
636 virtual WebMediaStreamCenter* createMediaStreamCenter(WebMediaStreamCenterClient*) { return nullptr; }
638 // WebWorker ----------------------------------------------------------
640 virtual void didStartWorkerRunLoop() { }
641 virtual void didStopWorkerRunLoop() { }
643 // WebCrypto ----------------------------------------------------------
645 virtual WebCrypto* crypto() { return nullptr; }
648 // Platform events -----------------------------------------------------
649 // Device Orientation, Device Motion, Device Light, Battery, Gamepad.
651 // Request the platform to start listening to the events of the specified
652 // type and notify the given listener (if not null) when there is an update.
653 virtual void startListening(WebPlatformEventType type, WebPlatformEventListener* listener) { }
655 // Request the platform to stop listening to the specified event and no
656 // longer notify the listener, if any.
657 virtual void stopListening(WebPlatformEventType type) { }
659 // This method converts from the supplied DOM code enum to the
660 // embedder's DOM code value for the key pressed. |domCode| values are
661 // based on the value defined in ui/events/keycodes/dom4/keycode_converter_data.h.
662 // Returns null string, if DOM code value is not found.
663 virtual WebString domCodeStringFromEnum(int domCode) { return WebString(); }
665 // This method converts from the suppled DOM code value to the
666 // embedder's DOM code enum for the key pressed. |codeString| is defined in
667 // ui/events/keycodes/dom4/keycode_converter_data.h.
668 // Returns 0, if DOM code enum is not found.
669 virtual int domEnumFromCodeString(const WebString& codeString) { return 0; }
671 // This method converts from the supplied DOM |key| enum to the
672 // corresponding DOM |key| string value for the key pressed. |domKey| values are
673 // based on the value defined in ui/events/keycodes/dom3/dom_key_data.h.
674 // Returns empty string, if DOM key value is not found.
675 virtual WebString domKeyStringFromEnum(int domKey) { return WebString(); }
677 // This method converts from the suppled DOM |key| value to the
678 // embedder's DOM |key| enum for the key pressed. |keyString| is defined in
679 // ui/events/keycodes/dom3/dom_key_data.h.
680 // Returns 0 if DOM key enum is not found.
681 virtual int domKeyEnumFromString(const WebString& keyString) { return 0; }
683 // Quota -----------------------------------------------------------
685 // Queries the storage partition's storage usage and quota information.
686 // WebStorageQuotaCallbacks::didQueryStorageUsageAndQuota will be called
687 // with the current usage and quota information for the partition. When
688 // an error occurs WebStorageQuotaCallbacks::didFail is called with an
689 // error code.
690 virtual void queryStorageUsageAndQuota(
691 const WebURL& storagePartition,
692 WebStorageQuotaType,
693 WebStorageQuotaCallbacks) { }
696 // WebDatabase --------------------------------------------------------
698 virtual WebDatabaseObserver* databaseObserver() { return nullptr; }
701 // Web Notifications --------------------------------------------------
703 virtual WebNotificationManager* notificationManager() { return nullptr; }
706 // Geofencing ---------------------------------------------------------
708 virtual WebGeofencingProvider* geofencingProvider() { return nullptr; }
711 // Bluetooth ----------------------------------------------------------
713 // Returns pointer to client owned WebBluetooth implementation.
714 virtual WebBluetooth* bluetooth() { return nullptr; }
717 // Push API------------------------------------------------------------
719 virtual WebPushProvider* pushProvider() { return nullptr; }
722 // navigator.connect --------------------------------------------------
724 virtual WebNavigatorConnectProvider* navigatorConnectProvider() { return nullptr; }
726 // Returns pointer to a new blink owned WebServicePortProvider instance,
727 // associated with a particular ServicePortCollection (identified by the
728 // WebServicePortProviderClient passed in).
729 virtual WebServicePortProvider* createServicePortProvider(WebServicePortProviderClient*) { return nullptr; }
731 // Permissions --------------------------------------------------------
733 virtual WebPermissionClient* permissionClient() { return nullptr; }
736 // Background Sync API------------------------------------------------------------
738 virtual WebSyncProvider* backgroundSyncProvider() { return nullptr; }
740 protected:
741 BLINK_PLATFORM_EXPORT Platform();
742 virtual ~Platform() { }
744 WebThread* m_mainThread;
747 } // namespace blink
749 #endif