Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / public / platform / Platform.h
1 /*
2  * Copyright (C) 2012 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
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.
17  *
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.
29  */
30
31 #ifndef Platform_h
32 #define Platform_h
33
34 #ifdef WIN32
35 #include <windows.h>
36 #endif
37
38 #include "WebAudioDevice.h"
39 #include "WebBatteryStatusListener.h"
40 #include "WebCommon.h"
41 #include "WebData.h"
42 #include "WebDeviceLightListener.h"
43 #include "WebDeviceMotionListener.h"
44 #include "WebDeviceOrientationListener.h"
45 #include "WebGamepadListener.h"
46 #include "WebGamepads.h"
47 #include "WebGestureDevice.h"
48 #include "WebGraphicsContext3D.h"
49 #include "WebLocalizedString.h"
50 #include "WebPlatformEventType.h"
51 #include "WebSpeechSynthesizer.h"
52 #include "WebStorageQuotaCallbacks.h"
53 #include "WebStorageQuotaType.h"
54 #include "WebString.h"
55 #include "WebURLError.h"
56 #include "WebVector.h"
57
58 class GrContext;
59
60 namespace blink {
61
62 class WebAudioBus;
63 class WebBlobRegistry;
64 class WebBluetooth;
65 class WebContentDecryptionModule;
66 class WebClipboard;
67 class WebCompositorSupport;
68 class WebConvertableToTraceFormat;
69 class WebCookieJar;
70 class WebCrypto;
71 class WebDatabaseObserver;
72 class WebDiscardableMemory;
73 class WebPlatformEventListener;
74 class WebFallbackThemeEngine;
75 class WebFileSystem;
76 class WebFileUtilities;
77 class WebFlingAnimator;
78 class WebGeofencingProvider;
79 class WebGestureCurveTarget;
80 class WebGestureCurve;
81 class WebGraphicsContext3DProvider;
82 class WebIDBFactory;
83 class WebMIDIAccessor;
84 class WebMIDIAccessorClient;
85 class WebMediaStreamCenter;
86 class WebMediaStreamCenterClient;
87 class WebMessagePortChannel;
88 class WebMimeRegistry;
89 class WebNotificationManager;
90 class WebPluginListBuilder;
91 class WebPrescientNetworking;
92 class WebPublicSuffixList;
93 class WebRTCPeerConnectionHandler;
94 class WebRTCPeerConnectionHandlerClient;
95 class WebSandboxSupport;
96 class WebScheduler;
97 class WebSecurityOrigin;
98 class WebScrollbarBehavior;
99 class WebSocketHandle;
100 class WebSpeechSynthesizer;
101 class WebSpeechSynthesizerClient;
102 class WebStorageNamespace;
103 struct WebFloatPoint;
104 class WebThemeEngine;
105 class WebThread;
106 class WebURL;
107 class WebURLLoader;
108 class WebUnitTestSupport;
109 class WebWaitableEvent;
110 class WebWorkerRunLoop;
111 struct WebLocalizedString;
112 struct WebSize;
113
114 class Platform {
115 public:
116     // HTML5 Database ------------------------------------------------------
117
118 #ifdef WIN32
119     typedef HANDLE FileHandle;
120 #else
121     typedef int FileHandle;
122 #endif
123
124     BLINK_PLATFORM_EXPORT static void initialize(Platform*);
125     BLINK_PLATFORM_EXPORT static void shutdown();
126     BLINK_PLATFORM_EXPORT static Platform* current();
127
128     // May return null.
129     virtual WebCookieJar* cookieJar() { return 0; }
130
131     // Must return non-null.
132     virtual WebClipboard* clipboard() { return 0; }
133
134     // Must return non-null.
135     virtual WebFileUtilities* fileUtilities() { return 0; }
136
137     // Must return non-null.
138     virtual WebMimeRegistry* mimeRegistry() { return 0; }
139
140     // May return null if sandbox support is not necessary
141     virtual WebSandboxSupport* sandboxSupport() { return 0; }
142
143     // May return null on some platforms.
144     virtual WebThemeEngine* themeEngine() { return 0; }
145
146     virtual WebFallbackThemeEngine* fallbackThemeEngine() { return 0; }
147
148     // May return null.
149     virtual WebSpeechSynthesizer* createSpeechSynthesizer(WebSpeechSynthesizerClient*) { return 0; }
150
151
152     // Audio --------------------------------------------------------------
153
154     virtual double audioHardwareSampleRate() { return 0; }
155     virtual size_t audioHardwareBufferSize() { return 0; }
156     virtual unsigned audioHardwareOutputChannels() { return 0; }
157
158     // Creates a device for audio I/O.
159     // Pass in (numberOfInputChannels > 0) if live/local audio input is desired.
160     virtual WebAudioDevice* createAudioDevice(size_t bufferSize, unsigned numberOfInputChannels, unsigned numberOfChannels, double sampleRate, WebAudioDevice::RenderCallback*, const WebString& deviceId) { return 0; }
161
162
163     // MIDI ----------------------------------------------------------------
164
165     // Creates a platform dependent WebMIDIAccessor. MIDIAccessor under platform
166     // creates and owns it.
167     virtual WebMIDIAccessor* createMIDIAccessor(WebMIDIAccessorClient*) { return 0; }
168
169
170     // Blob ----------------------------------------------------------------
171
172     // Must return non-null.
173     virtual WebBlobRegistry* blobRegistry() { return 0; }
174
175     // Database ------------------------------------------------------------
176
177     // Opens a database file; dirHandle should be 0 if the caller does not need
178     // a handle to the directory containing this file
179     virtual FileHandle databaseOpenFile(const WebString& vfsFileName, int desiredFlags) { return FileHandle(); }
180
181     // Deletes a database file and returns the error code
182     virtual int databaseDeleteFile(const WebString& vfsFileName, bool syncDir) { return 0; }
183
184     // Returns the attributes of the given database file
185     virtual long databaseGetFileAttributes(const WebString& vfsFileName) { return 0; }
186
187     // Returns the size of the given database file
188     virtual long long databaseGetFileSize(const WebString& vfsFileName) { return 0; }
189
190     // Returns the space available for the given origin
191     virtual long long databaseGetSpaceAvailableForOrigin(const WebString& originIdentifier) { return 0; }
192
193
194     // DOM Storage --------------------------------------------------
195
196     // Return a LocalStorage namespace
197     virtual WebStorageNamespace* createLocalStorageNamespace() { return 0; }
198
199
200     // FileSystem ----------------------------------------------------------
201
202     // Must return non-null.
203     virtual WebFileSystem* fileSystem() { return 0; }
204
205
206     // IDN conversion ------------------------------------------------------
207
208     virtual WebString convertIDNToUnicode(const WebString& host, const WebString& languages) { return host; }
209
210
211     // IndexedDB ----------------------------------------------------------
212
213     // Must return non-null.
214     virtual WebIDBFactory* idbFactory() { return 0; }
215
216
217     // Gamepad -------------------------------------------------------------
218
219     virtual void sampleGamepads(WebGamepads& into) { into.length = 0; }
220
221
222     // History -------------------------------------------------------------
223
224     // Returns the hash for the given canonicalized URL for use in visited
225     // link coloring.
226     virtual unsigned long long visitedLinkHash(
227         const char* canonicalURL, size_t length) { return 0; }
228
229     // Returns whether the given link hash is in the user's history. The
230     // hash must have been generated by calling VisitedLinkHash().
231     virtual bool isLinkVisited(unsigned long long linkHash) { return false; }
232
233
234     // Keygen --------------------------------------------------------------
235
236     // Handle the <keygen> tag for generating client certificates
237     // Returns a base64 encoded signed copy of a public key from a newly
238     // generated key pair and the supplied challenge string. keySizeindex
239     // specifies the strength of the key.
240     virtual WebString signedPublicKeyAndChallengeString(unsigned keySizeIndex,
241                                                         const WebString& challenge,
242                                                         const WebURL& url) { return WebString(); }
243
244
245     // Memory --------------------------------------------------------------
246
247     // Returns the current space allocated for the pagefile, in MB.
248     // That is committed size for Windows and virtual memory size for POSIX
249     virtual size_t memoryUsageMB() { return 0; }
250
251     // Same as above, but always returns actual value, without any caches.
252     virtual size_t actualMemoryUsageMB() { return 0; }
253
254     // Return the physical memory of the current machine, in MB.
255     virtual size_t physicalMemoryMB() { return 0; }
256
257     // Return the available virtual memory of the current machine, in MB. Or
258     // zero, if there is no limit.
259     virtual size_t virtualMemoryLimitMB() { return 0; }
260
261     // Return the number of of processors of the current machine.
262     virtual size_t numberOfProcessors() { return 0; }
263
264     // Returns private and shared usage, in bytes. Private bytes is the amount of
265     // memory currently allocated to this process that cannot be shared. Returns
266     // false on platform specific error conditions.
267     virtual bool processMemorySizesInBytes(size_t* privateBytes, size_t* sharedBytes) { return false; }
268
269     // Reports number of bytes used by memory allocator for internal needs.
270     // Returns true if the size has been reported, or false otherwise.
271     virtual bool memoryAllocatorWasteInBytes(size_t*) { return false; }
272
273     // Allocates discardable memory. May return 0, even if the platform supports
274     // discardable memory. If nonzero, however, then the WebDiscardableMmeory is
275     // returned in an locked state. You may use its underlying data() member
276     // directly, taking care to unlock it when you are ready to let it become
277     // discardable.
278     virtual WebDiscardableMemory* allocateAndLockDiscardableMemory(size_t bytes) { return 0; }
279
280     // A wrapper for tcmalloc's HeapProfilerStart();
281     virtual void startHeapProfiling(const WebString& /*prefix*/) { }
282     // A wrapper for tcmalloc's HeapProfilerStop();
283     virtual void stopHeapProfiling() { }
284     // A wrapper for tcmalloc's HeapProfilerDump()
285     virtual void dumpHeapProfiling(const WebString& /*reason*/) { }
286     // A wrapper for tcmalloc's GetHeapProfile()
287     virtual WebString getHeapProfile() { return WebString(); }
288
289     static const size_t noDecodedImageByteLimit = static_cast<size_t>(-1);
290
291     // Returns the maximum amount of memory a decoded image should be allowed.
292     // See comments on ImageDecoder::m_maxDecodedBytes.
293     virtual size_t maxDecodedImageBytes() { return noDecodedImageByteLimit; }
294
295
296     // Message Ports -------------------------------------------------------
297
298     // Creates a Message Port Channel pair. This can be called on any thread.
299     // The returned objects should only be used on the thread they were created on.
300     virtual void createMessageChannel(WebMessagePortChannel** channel1, WebMessagePortChannel** channel2) { *channel1 = 0; *channel2 = 0; }
301
302
303     // Network -------------------------------------------------------------
304
305     // Returns a new WebURLLoader instance.
306     virtual WebURLLoader* createURLLoader() { return 0; }
307
308     // May return null.
309     virtual WebPrescientNetworking* prescientNetworking() { return 0; }
310
311     // Returns a new WebSocketHandle instance.
312     virtual WebSocketHandle* createWebSocketHandle() { return 0; }
313
314     // Returns the User-Agent string.
315     virtual WebString userAgent() { return WebString(); }
316
317     // A suggestion to cache this metadata in association with this URL.
318     virtual void cacheMetadata(const WebURL&, double responseTime, const char* data, size_t dataSize) { }
319
320     // Returns the decoded data url if url had a supported mimetype and parsing was successful.
321     virtual WebData parseDataURL(const WebURL&, WebString& mimetype, WebString& charset) { return WebData(); }
322
323     virtual WebURLError cancelledError(const WebURL&) const { return WebURLError(); }
324
325     virtual bool isReservedIPAddress(const WebURL&) const { return false; }
326     virtual bool isReservedIPAddress(const WebSecurityOrigin&) const { return false; }
327
328     // Plugins -------------------------------------------------------------
329
330     // If refresh is true, then cached information should not be used to
331     // satisfy this call.
332     virtual void getPluginList(bool refresh, WebPluginListBuilder*) { }
333
334
335     // Public Suffix List --------------------------------------------------
336
337     // May return null on some platforms.
338     virtual WebPublicSuffixList* publicSuffixList() { return 0; }
339
340
341     // Resources -----------------------------------------------------------
342
343     // Returns a localized string resource (with substitution parameters).
344     virtual WebString queryLocalizedString(WebLocalizedString::Name) { return WebString(); }
345     virtual WebString queryLocalizedString(WebLocalizedString::Name, const WebString& parameter) { return WebString(); }
346     virtual WebString queryLocalizedString(WebLocalizedString::Name, const WebString& parameter1, const WebString& parameter2) { return WebString(); }
347
348
349     // Threads -------------------------------------------------------
350
351     // Creates an embedder-defined thread.
352     virtual WebThread* createThread(const char* name) { return 0; }
353
354     // Returns an interface to the current thread. This is owned by the
355     // embedder.
356     virtual WebThread* currentThread() { return 0; }
357
358     // Yield the current thread so another thread can be scheduled.
359     virtual void yieldCurrentThread() { }
360
361     // May return null.
362     virtual WebScheduler* scheduler() { return 0; }
363
364     // WaitableEvent -------------------------------------------------------
365
366     // Creates an embedder-defined waitable event object.
367     virtual WebWaitableEvent* createWaitableEvent() { return 0; }
368
369     // Waits on multiple events and returns the event object that has been
370     // signaled. This may return 0 if it fails to wait events.
371     // Any event objects given to this method must not deleted while this
372     // wait is happening.
373     virtual WebWaitableEvent* waitMultipleEvents(const WebVector<WebWaitableEvent*>& events) { return 0; }
374
375
376     // Profiling -----------------------------------------------------------
377
378     virtual void decrementStatsCounter(const char* name) { }
379     virtual void incrementStatsCounter(const char* name) { }
380
381
382     // Resources -----------------------------------------------------------
383
384     // Returns a blob of data corresponding to the named resource.
385     virtual WebData loadResource(const char* name) { return WebData(); }
386
387     // Decodes the in-memory audio file data and returns the linear PCM audio data in the destinationBus.
388     // A sample-rate conversion to sampleRate will occur if the file data is at a different sample-rate.
389     // Returns true on success.
390     virtual bool loadAudioResource(WebAudioBus* destinationBus, const char* audioFileData, size_t dataSize) { return false; }
391
392     // Screen -------------------------------------------------------------
393
394     // Supplies the system monitor color profile.
395     virtual void screenColorProfile(WebVector<char>* profile) { }
396
397
398     // Scrollbar ----------------------------------------------------------
399
400     // Must return non-null.
401     virtual WebScrollbarBehavior* scrollbarBehavior() { return 0; }
402
403
404     // Sudden Termination --------------------------------------------------
405
406     // Disable/Enable sudden termination.
407     virtual void suddenTerminationChanged(bool enabled) { }
408
409
410     // System --------------------------------------------------------------
411
412     // Returns a value such as "en-US".
413     virtual WebString defaultLocale() { return WebString(); }
414
415     // Wall clock time in seconds since the epoch.
416     virtual double currentTime() { return 0; }
417
418     // Monotonically increasing time in seconds from an arbitrary fixed point in the past.
419     // This function is expected to return at least millisecond-precision values. For this reason,
420     // it is recommended that the fixed point be no further in the past than the epoch.
421     virtual double monotonicallyIncreasingTime() { return 0; }
422
423     // WebKit clients must implement this funcion if they use cryptographic randomness.
424     virtual void cryptographicallyRandomValues(unsigned char* buffer, size_t length) = 0;
425
426     // Delayed work is driven by a shared timer.
427     typedef void (*SharedTimerFunction)();
428     virtual void setSharedTimerFiredFunction(SharedTimerFunction timerFunction) { }
429     virtual void setSharedTimerFireInterval(double) { }
430     virtual void stopSharedTimer() { }
431
432     // Callable from a background WebKit thread.
433     virtual void callOnMainThread(void (*func)(void*), void* context) { }
434
435
436     // Vibration -----------------------------------------------------------
437
438     // Starts a vibration for the given duration in milliseconds. If there is currently an active
439     // vibration it will be cancelled before the new one is started.
440     virtual void vibrate(unsigned time) { }
441
442     // Cancels the current vibration, if there is one.
443     virtual void cancelVibration() { }
444
445
446     // Testing -------------------------------------------------------------
447
448     // Get a pointer to testing support interfaces. Will not be available in production builds.
449     virtual WebUnitTestSupport* unitTestSupport() { return 0; }
450
451
452     // Tracing -------------------------------------------------------------
453
454     // Get a pointer to the enabled state of the given trace category. The
455     // embedder can dynamically change the enabled state as trace event
456     // recording is started and stopped by the application. Only long-lived
457     // literal strings should be given as the category name. The implementation
458     // expects the returned pointer to be held permanently in a local static. If
459     // the unsigned char is non-zero, tracing is enabled. If tracing is enabled,
460     // addTraceEvent is expected to be called by the trace event macros.
461     virtual const unsigned char* getTraceCategoryEnabledFlag(const char* categoryName) { return 0; }
462
463     typedef long int TraceEventAPIAtomicWord;
464
465     // Get a pointer to a global state of the given thread. An embedder is
466     // expected to update the global state as the state of the embedder changes.
467     // A sampling thread in the Chromium side reads the global state periodically
468     // and reflects the sampling profiled results into about:tracing.
469     virtual TraceEventAPIAtomicWord* getTraceSamplingState(const unsigned bucketName) { return 0; }
470
471     typedef uint64_t TraceEventHandle;
472
473     // Add a trace event to the platform tracing system. Depending on the actual
474     // enabled state, this event may be recorded or dropped.
475     // - phase specifies the type of event:
476     //   - BEGIN ('B'): Marks the beginning of a scoped event.
477     //   - END ('E'): Marks the end of a scoped event.
478     //   - COMPLETE ('X'): Marks the beginning of a scoped event, but doesn't
479     //     need a matching END event. Instead, at the end of the scope,
480     //     updateTraceEventDuration() must be called with the TraceEventHandle
481     //     returned from addTraceEvent().
482     //   - INSTANT ('I'): Standalone, instantaneous event.
483     //   - START ('S'): Marks the beginning of an asynchronous event (the end
484     //     event can occur in a different scope or thread). The id parameter is
485     //     used to match START/FINISH pairs.
486     //   - FINISH ('F'): Marks the end of an asynchronous event.
487     //   - COUNTER ('C'): Used to trace integer quantities that change over
488     //     time. The argument values are expected to be of type int.
489     //   - METADATA ('M'): Reserved for internal use.
490     // - categoryEnabled is the pointer returned by getTraceCategoryEnabledFlag.
491     // - name is the name of the event. Also used to match BEGIN/END and
492     //   START/FINISH pairs.
493     // - id optionally allows events of the same name to be distinguished from
494     //   each other. For example, to trace the consutruction and destruction of
495     //   objects, specify the pointer as the id parameter.
496     // - numArgs specifies the number of elements in argNames, argTypes, and
497     //   argValues.
498     // - argNames is the array of argument names. Use long-lived literal strings
499     //   or specify the COPY flag.
500     // - argTypes is the array of argument types:
501     //   - BOOL (1): bool
502     //   - UINT (2): unsigned long long
503     //   - INT (3): long long
504     //   - DOUBLE (4): double
505     //   - POINTER (5): void*
506     //   - STRING (6): char* (long-lived null-terminated char* string)
507     //   - COPY_STRING (7): char* (temporary null-terminated char* string)
508     //   - CONVERTABLE (8): WebConvertableToTraceFormat
509     // - argValues is the array of argument values. Each value is the unsigned
510     //   long long member of a union of all supported types.
511     // - convertableValues is the array of WebConvertableToTraceFormat classes
512     //   that may be converted to trace format by calling asTraceFormat method.
513     //   ConvertableToTraceFormat interface.
514     // - thresholdBeginId optionally specifies the value returned by a previous
515     //   call to addTraceEvent with a BEGIN phase.
516     // - threshold is used on an END phase event in conjunction with the
517     //   thresholdBeginId of a prior BEGIN event. The threshold is the minimum
518     //   number of microseconds that must have passed since the BEGIN event. If
519     //   less than threshold microseconds has passed, the BEGIN/END pair is
520     //   dropped.
521     // - flags can be 0 or one or more of the following, ORed together:
522     //   - COPY (0x1): treat all strings (name, argNames and argValues of type
523     //     string) as temporary so that they will be copied by addTraceEvent.
524     //   - HAS_ID (0x2): use the id argument to uniquely identify the event for
525     //     matching with other events of the same name.
526     //   - MANGLE_ID (0x4): specify this flag if the id parameter is the value
527     //     of a pointer.
528     virtual TraceEventHandle addTraceEvent(
529         char phase,
530         const unsigned char* categoryEnabledFlag,
531         const char* name,
532         unsigned long long id,
533         int numArgs,
534         const char** argNames,
535         const unsigned char* argTypes,
536         const unsigned long long* argValues,
537         const WebConvertableToTraceFormat* convertableValues,
538         unsigned char flags)
539     {
540         return 0;
541     }
542
543     // Set the duration field of a COMPLETE trace event.
544     virtual void updateTraceEventDuration(const unsigned char* categoryEnabledFlag, const char* name, TraceEventHandle) { }
545
546     // Callbacks for reporting histogram data.
547     // CustomCounts histogram has exponential bucket sizes, so that min=1, max=1000000, bucketCount=50 would do.
548     virtual void histogramCustomCounts(const char* name, int sample, int min, int max, int bucketCount) { }
549     // Enumeration histogram buckets are linear, boundaryValue should be larger than any possible sample value.
550     virtual void histogramEnumeration(const char* name, int sample, int boundaryValue) { }
551     // Unlike enumeration histograms, sparse histograms only allocate memory for non-empty buckets.
552     virtual void histogramSparse(const char* name, int sample) { }
553
554
555     // GPU ----------------------------------------------------------------
556     //
557     // May return null if GPU is not supported.
558     // Returns newly allocated and initialized offscreen WebGraphicsContext3D instance.
559     // Passing an existing context to shareContext will create the new context in the same share group as the passed context.
560     virtual WebGraphicsContext3D* createOffscreenGraphicsContext3D(const WebGraphicsContext3D::Attributes&, WebGraphicsContext3D* shareContext) { return 0; }
561     virtual WebGraphicsContext3D* createOffscreenGraphicsContext3D(const WebGraphicsContext3D::Attributes&, WebGraphicsContext3D* shareContext, WebGLInfo* glInfo) { return 0; }
562     virtual WebGraphicsContext3D* createOffscreenGraphicsContext3D(const WebGraphicsContext3D::Attributes&) { return 0; }
563
564     // Returns a newly allocated and initialized offscreen context provider. The provider may return a null
565     // graphics context if GPU is not supported.
566     virtual WebGraphicsContext3DProvider* createSharedOffscreenGraphicsContext3DProvider() { return 0; }
567
568     // Returns true if the platform is capable of producing an offscreen context suitable for accelerating 2d canvas.
569     // This will return false if the platform cannot promise that contexts will be preserved across operations like
570     // locking the screen or if the platform cannot provide a context with suitable performance characteristics.
571     //
572     // This value must be checked again after a context loss event as the platform's capabilities may have changed.
573     virtual bool canAccelerate2dCanvas() { return false; }
574
575     virtual bool isThreadedCompositingEnabled() { return false; }
576
577     virtual WebCompositorSupport* compositorSupport() { return 0; }
578
579     virtual WebFlingAnimator* createFlingAnimator() { return 0; }
580
581     // Creates a new fling animation curve instance for device |deviceSource|
582     // with |velocity| and already scrolled |cumulativeScroll| pixels.
583     virtual WebGestureCurve* createFlingAnimationCurve(WebGestureDevice deviceSource, const WebFloatPoint& velocity, const WebSize& cumulativeScroll) { return 0; }
584
585     // WebRTC ----------------------------------------------------------
586
587     // Creates an WebRTCPeerConnectionHandler for RTCPeerConnection.
588     // May return null if WebRTC functionality is not avaliable or out of resources.
589     virtual WebRTCPeerConnectionHandler* createRTCPeerConnectionHandler(WebRTCPeerConnectionHandlerClient*) { return 0; }
590
591     // May return null if WebRTC functionality is not avaliable or out of resources.
592     virtual WebMediaStreamCenter* createMediaStreamCenter(WebMediaStreamCenterClient*) { return 0; }
593
594
595     // WebWorker ----------------------------------------------------------
596
597     virtual void didStartWorkerRunLoop(const WebWorkerRunLoop&) { }
598     virtual void didStopWorkerRunLoop(const WebWorkerRunLoop&) { }
599
600     // WebCrypto ----------------------------------------------------------
601
602     virtual WebCrypto* crypto() { return 0; }
603
604
605     // Platform events -----------------------------------------------------
606     // Device Orientation, Device Motion, Device Light, Battery, Gamepad.
607
608     // Request the platform to start listening to the events of the specified
609     // type and notify the given listener (if not null) when there is an update.
610     virtual void startListening(WebPlatformEventType type, WebPlatformEventListener* listener) { }
611
612     // Request the platform to stop listening to the specified event and no
613     // longer notify the listener, if any.
614     virtual void stopListening(WebPlatformEventType type) { }
615
616     // Quota -----------------------------------------------------------
617
618     // Queries the storage partition's storage usage and quota information.
619     // WebStorageQuotaCallbacks::didQueryStorageUsageAndQuota will be called
620     // with the current usage and quota information for the partition. When
621     // an error occurs WebStorageQuotaCallbacks::didFail is called with an
622     // error code.
623     virtual void queryStorageUsageAndQuota(
624         const WebURL& storagePartition,
625         WebStorageQuotaType,
626         WebStorageQuotaCallbacks) { }
627
628
629     // WebDatabase --------------------------------------------------------
630
631     virtual WebDatabaseObserver* databaseObserver() { return 0; }
632
633
634     // Web Notifications --------------------------------------------------
635
636     virtual WebNotificationManager* notificationManager() { return 0; }
637
638
639     // Geofencing ---------------------------------------------------------
640
641     virtual WebGeofencingProvider* geofencingProvider() { return 0; }
642
643     // Bluetooth ----------------------------------------------------------
644
645     // Returns pointer to client owned WebBluetooth implementation.
646     virtual WebBluetooth* bluetooth() { return 0; }
647
648 protected:
649     virtual ~Platform() { }
650 };
651
652 } // namespace blink
653
654 #endif