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