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 WebContentDecryptionModule; 65 class WebClipboard; 66 class WebCompositorSupport; 67 class WebConvertableToTraceFormat; 68 class WebCookieJar; 69 class WebCrypto; 70 class WebDatabaseObserver; 71 class WebDiscardableMemory; 72 class WebPlatformEventListener; 73 class WebFallbackThemeEngine; 74 class WebFileSystem; 75 class WebFileUtilities; 76 class WebFlingAnimator; 77 class WebGeofencingProvider; 78 class WebGestureCurveTarget; 79 class WebGestureCurve; 80 class WebGraphicsContext3DProvider; 81 class WebIDBFactory; 82 class WebMIDIAccessor; 83 class WebMIDIAccessorClient; 84 class WebMediaStreamCenter; 85 class WebMediaStreamCenterClient; 86 class WebMessagePortChannel; 87 class WebMimeRegistry; 88 class WebNotificationPresenter; 89 class WebPluginListBuilder; 90 class WebPrescientNetworking; 91 class WebPublicSuffixList; 92 class WebRTCPeerConnectionHandler; 93 class WebRTCPeerConnectionHandlerClient; 94 class WebSandboxSupport; 95 class WebSecurityOrigin; 96 class WebScrollbarBehavior; 97 class WebSocketHandle; 98 class WebSocketStreamHandle; 99 class WebSpeechSynthesizer; 100 class WebSpeechSynthesizerClient; 101 class WebStorageNamespace; 102 struct WebFloatPoint; 103 class WebThemeEngine; 104 class WebThread; 105 class WebURL; 106 class WebURLLoader; 107 class WebUnitTestSupport; 108 class WebWaitableEvent; 109 class WebWorkerRunLoop; 110 struct WebLocalizedString; 111 struct WebSize; 112 113 class Platform { 114 public: 115 // HTML5 Database ------------------------------------------------------ 116 117 #ifdef WIN32 118 typedef HANDLE FileHandle; 119 #else 120 typedef int FileHandle; 121 #endif 122 123 BLINK_PLATFORM_EXPORT static void initialize(Platform*); 124 BLINK_PLATFORM_EXPORT static void shutdown(); 125 BLINK_PLATFORM_EXPORT static Platform* current(); 126 127 // May return null. cookieJar()128 virtual WebCookieJar* cookieJar() { return 0; } 129 130 // Must return non-null. clipboard()131 virtual WebClipboard* clipboard() { return 0; } 132 133 // Must return non-null. fileUtilities()134 virtual WebFileUtilities* fileUtilities() { return 0; } 135 136 // Must return non-null. mimeRegistry()137 virtual WebMimeRegistry* mimeRegistry() { return 0; } 138 139 // May return null if sandbox support is not necessary sandboxSupport()140 virtual WebSandboxSupport* sandboxSupport() { return 0; } 141 142 // May return null on some platforms. themeEngine()143 virtual WebThemeEngine* themeEngine() { return 0; } 144 fallbackThemeEngine()145 virtual WebFallbackThemeEngine* fallbackThemeEngine() { return 0; } 146 147 // May return null. createSpeechSynthesizer(WebSpeechSynthesizerClient *)148 virtual WebSpeechSynthesizer* createSpeechSynthesizer(WebSpeechSynthesizerClient*) { return 0; } 149 150 151 // Audio -------------------------------------------------------------- 152 audioHardwareSampleRate()153 virtual double audioHardwareSampleRate() { return 0; } audioHardwareBufferSize()154 virtual size_t audioHardwareBufferSize() { return 0; } audioHardwareOutputChannels()155 virtual unsigned audioHardwareOutputChannels() { return 0; } 156 157 // Creates a device for audio I/O. 158 // 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)159 virtual WebAudioDevice* createAudioDevice(size_t bufferSize, unsigned numberOfInputChannels, unsigned numberOfChannels, double sampleRate, WebAudioDevice::RenderCallback*, const WebString& deviceId) { return 0; } 160 161 162 // MIDI ---------------------------------------------------------------- 163 164 // Creates a platform dependent WebMIDIAccessor. MIDIAccessor under platform 165 // creates and owns it. createMIDIAccessor(WebMIDIAccessorClient *)166 virtual WebMIDIAccessor* createMIDIAccessor(WebMIDIAccessorClient*) { return 0; } 167 168 169 // Blob ---------------------------------------------------------------- 170 171 // Must return non-null. blobRegistry()172 virtual WebBlobRegistry* blobRegistry() { return 0; } 173 174 // Database ------------------------------------------------------------ 175 176 // Opens a database file; dirHandle should be 0 if the caller does not need 177 // a handle to the directory containing this file databaseOpenFile(const WebString & vfsFileName,int desiredFlags)178 virtual FileHandle databaseOpenFile(const WebString& vfsFileName, int desiredFlags) { return FileHandle(); } 179 180 // Deletes a database file and returns the error code databaseDeleteFile(const WebString & vfsFileName,bool syncDir)181 virtual int databaseDeleteFile(const WebString& vfsFileName, bool syncDir) { return 0; } 182 183 // Returns the attributes of the given database file databaseGetFileAttributes(const WebString & vfsFileName)184 virtual long databaseGetFileAttributes(const WebString& vfsFileName) { return 0; } 185 186 // Returns the size of the given database file databaseGetFileSize(const WebString & vfsFileName)187 virtual long long databaseGetFileSize(const WebString& vfsFileName) { return 0; } 188 189 // Returns the space available for the given origin databaseGetSpaceAvailableForOrigin(const WebString & originIdentifier)190 virtual long long databaseGetSpaceAvailableForOrigin(const WebString& originIdentifier) { return 0; } 191 192 193 // DOM Storage -------------------------------------------------- 194 195 // Return a LocalStorage namespace createLocalStorageNamespace()196 virtual WebStorageNamespace* createLocalStorageNamespace() { return 0; } 197 198 199 // FileSystem ---------------------------------------------------------- 200 201 // Must return non-null. fileSystem()202 virtual WebFileSystem* fileSystem() { return 0; } 203 204 205 // IDN conversion ------------------------------------------------------ 206 convertIDNToUnicode(const WebString & host,const WebString & languages)207 virtual WebString convertIDNToUnicode(const WebString& host, const WebString& languages) { return host; } 208 209 210 // IndexedDB ---------------------------------------------------------- 211 212 // Must return non-null. idbFactory()213 virtual WebIDBFactory* idbFactory() { return 0; } 214 215 216 // Gamepad ------------------------------------------------------------- 217 sampleGamepads(WebGamepads & into)218 virtual void sampleGamepads(WebGamepads& into) { into.length = 0; } 219 220 221 // History ------------------------------------------------------------- 222 223 // Returns the hash for the given canonicalized URL for use in visited 224 // link coloring. visitedLinkHash(const char * canonicalURL,size_t length)225 virtual unsigned long long visitedLinkHash( 226 const char* canonicalURL, size_t length) { return 0; } 227 228 // Returns whether the given link hash is in the user's history. The 229 // hash must have been generated by calling VisitedLinkHash(). isLinkVisited(unsigned long long linkHash)230 virtual bool isLinkVisited(unsigned long long linkHash) { return false; } 231 232 233 // Keygen -------------------------------------------------------------- 234 235 // Handle the <keygen> tag for generating client certificates 236 // Returns a base64 encoded signed copy of a public key from a newly 237 // generated key pair and the supplied challenge string. keySizeindex 238 // specifies the strength of the key. signedPublicKeyAndChallengeString(unsigned keySizeIndex,const WebString & challenge,const WebURL & url)239 virtual WebString signedPublicKeyAndChallengeString(unsigned keySizeIndex, 240 const WebString& challenge, 241 const WebURL& url) { return WebString(); } 242 243 244 // Memory -------------------------------------------------------------- 245 246 // Returns the current space allocated for the pagefile, in MB. 247 // That is committed size for Windows and virtual memory size for POSIX memoryUsageMB()248 virtual size_t memoryUsageMB() { return 0; } 249 250 // Same as above, but always returns actual value, without any caches. actualMemoryUsageMB()251 virtual size_t actualMemoryUsageMB() { return 0; } 252 253 // Return the physical memory of the current machine, in MB. physicalMemoryMB()254 virtual size_t physicalMemoryMB() { return 0; } 255 256 // Return the available virtual memory of the current machine, in MB. Or 257 // zero, if there is no limit. virtualMemoryLimitMB()258 virtual size_t virtualMemoryLimitMB() { return 0; } 259 260 // Return the number of of processors of the current machine. numberOfProcessors()261 virtual size_t numberOfProcessors() { return 0; } 262 263 // Returns private and shared usage, in bytes. Private bytes is the amount of 264 // memory currently allocated to this process that cannot be shared. Returns 265 // false on platform specific error conditions. processMemorySizesInBytes(size_t * privateBytes,size_t * sharedBytes)266 virtual bool processMemorySizesInBytes(size_t* privateBytes, size_t* sharedBytes) { return false; } 267 268 // Reports number of bytes used by memory allocator for internal needs. 269 // Returns true if the size has been reported, or false otherwise. memoryAllocatorWasteInBytes(size_t *)270 virtual bool memoryAllocatorWasteInBytes(size_t*) { return false; } 271 272 // Allocates discardable memory. May return 0, even if the platform supports 273 // discardable memory. If nonzero, however, then the WebDiscardableMmeory is 274 // returned in an locked state. You may use its underlying data() member 275 // directly, taking care to unlock it when you are ready to let it become 276 // discardable. allocateAndLockDiscardableMemory(size_t bytes)277 virtual WebDiscardableMemory* allocateAndLockDiscardableMemory(size_t bytes) { return 0; } 278 279 // A wrapper for tcmalloc's HeapProfilerStart(); startHeapProfiling(const WebString &)280 virtual void startHeapProfiling(const WebString& /*prefix*/) { } 281 // A wrapper for tcmalloc's HeapProfilerStop(); stopHeapProfiling()282 virtual void stopHeapProfiling() { } 283 // A wrapper for tcmalloc's HeapProfilerDump() dumpHeapProfiling(const WebString &)284 virtual void dumpHeapProfiling(const WebString& /*reason*/) { } 285 // A wrapper for tcmalloc's GetHeapProfile() getHeapProfile()286 virtual WebString getHeapProfile() { return WebString(); } 287 288 static const size_t noDecodedImageByteLimit = static_cast<size_t>(-1); 289 290 // Returns the maximum amount of memory a decoded image should be allowed. 291 // See comments on ImageDecoder::m_maxDecodedBytes. maxDecodedImageBytes()292 virtual size_t maxDecodedImageBytes() { return noDecodedImageByteLimit; } 293 294 295 // Message Ports ------------------------------------------------------- 296 297 // Creates a Message Port Channel pair. This can be called on any thread. 298 // The returned objects should only be used on the thread they were created on. createMessageChannel(WebMessagePortChannel ** channel1,WebMessagePortChannel ** channel2)299 virtual void createMessageChannel(WebMessagePortChannel** channel1, WebMessagePortChannel** channel2) { *channel1 = 0; *channel2 = 0; } 300 301 302 // Network ------------------------------------------------------------- 303 304 // Returns a new WebURLLoader instance. createURLLoader()305 virtual WebURLLoader* createURLLoader() { return 0; } 306 307 // May return null. prescientNetworking()308 virtual WebPrescientNetworking* prescientNetworking() { return 0; } 309 310 // Returns a new WebSocketStreamHandle instance. createSocketStreamHandle()311 virtual WebSocketStreamHandle* createSocketStreamHandle() { return 0; } 312 313 // Returns a new WebSocketHandle instance. createWebSocketHandle()314 virtual WebSocketHandle* createWebSocketHandle() { return 0; } 315 316 // Returns the User-Agent string. userAgent()317 virtual WebString userAgent() { return WebString(); } 318 319 // A suggestion to cache this metadata in association with this URL. cacheMetadata(const WebURL &,double responseTime,const char * data,size_t dataSize)320 virtual void cacheMetadata(const WebURL&, double responseTime, const char* data, size_t dataSize) { } 321 322 // Returns the decoded data url if url had a supported mimetype and parsing was successful. parseDataURL(const WebURL &,WebString & mimetype,WebString & charset)323 virtual WebData parseDataURL(const WebURL&, WebString& mimetype, WebString& charset) { return WebData(); } 324 cancelledError(const WebURL &)325 virtual WebURLError cancelledError(const WebURL&) const { return WebURLError(); } 326 isReservedIPAddress(const WebURL &)327 virtual bool isReservedIPAddress(const WebURL&) const { return false; } isReservedIPAddress(const WebSecurityOrigin &)328 virtual bool isReservedIPAddress(const WebSecurityOrigin&) const { return false; } 329 330 // Plugins ------------------------------------------------------------- 331 332 // If refresh is true, then cached information should not be used to 333 // satisfy this call. getPluginList(bool refresh,WebPluginListBuilder *)334 virtual void getPluginList(bool refresh, WebPluginListBuilder*) { } 335 336 337 // Public Suffix List -------------------------------------------------- 338 339 // May return null on some platforms. publicSuffixList()340 virtual WebPublicSuffixList* publicSuffixList() { return 0; } 341 342 343 // Resources ----------------------------------------------------------- 344 345 // Returns a localized string resource (with substitution parameters). queryLocalizedString(WebLocalizedString::Name)346 virtual WebString queryLocalizedString(WebLocalizedString::Name) { return WebString(); } queryLocalizedString(WebLocalizedString::Name,const WebString & parameter)347 virtual WebString queryLocalizedString(WebLocalizedString::Name, const WebString& parameter) { return WebString(); } queryLocalizedString(WebLocalizedString::Name,const WebString & parameter1,const WebString & parameter2)348 virtual WebString queryLocalizedString(WebLocalizedString::Name, const WebString& parameter1, const WebString& parameter2) { return WebString(); } 349 350 351 // Threads ------------------------------------------------------- 352 353 // Creates an embedder-defined thread. createThread(const char * name)354 virtual WebThread* createThread(const char* name) { return 0; } 355 356 // Returns an interface to the current thread. This is owned by the 357 // embedder. currentThread()358 virtual WebThread* currentThread() { return 0; } 359 360 // Yield the current thread so another thread can be scheduled. yieldCurrentThread()361 virtual void yieldCurrentThread() { } 362 363 364 // WaitableEvent ------------------------------------------------------- 365 366 // Creates an embedder-defined waitable event object. createWaitableEvent()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. waitMultipleEvents(const WebVector<WebWaitableEvent * > & events)373 virtual WebWaitableEvent* waitMultipleEvents(const WebVector<WebWaitableEvent*>& events) { return 0; } 374 375 376 // Profiling ----------------------------------------------------------- 377 decrementStatsCounter(const char * name)378 virtual void decrementStatsCounter(const char* name) { } incrementStatsCounter(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. loadResource(const char * name)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. loadAudioResource(WebAudioBus * destinationBus,const char * audioFileData,size_t dataSize)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. screenColorProfile(WebVector<char> * profile)395 virtual void screenColorProfile(WebVector<char>* profile) { } 396 397 398 // Scrollbar ---------------------------------------------------------- 399 400 // Must return non-null. scrollbarBehavior()401 virtual WebScrollbarBehavior* scrollbarBehavior() { return 0; } 402 403 404 // Sudden Termination -------------------------------------------------- 405 406 // Disable/Enable sudden termination. suddenTerminationChanged(bool enabled)407 virtual void suddenTerminationChanged(bool enabled) { } 408 409 410 // System -------------------------------------------------------------- 411 412 // Returns a value such as "en-US". defaultLocale()413 virtual WebString defaultLocale() { return WebString(); } 414 415 // Wall clock time in seconds since the epoch. currentTime()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. monotonicallyIncreasingTime()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)(); setSharedTimerFiredFunction(SharedTimerFunction timerFunction)428 virtual void setSharedTimerFiredFunction(SharedTimerFunction timerFunction) { } setSharedTimerFireInterval(double)429 virtual void setSharedTimerFireInterval(double) { } stopSharedTimer()430 virtual void stopSharedTimer() { } 431 432 // Callable from a background WebKit thread. callOnMainThread(void (* func)(void *),void * context)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. vibrate(unsigned time)440 virtual void vibrate(unsigned time) { } 441 442 // Cancels the current vibration, if there is one. cancelVibration()443 virtual void cancelVibration() { } 444 445 446 // Testing ------------------------------------------------------------- 447 448 // Get a pointer to testing support interfaces. Will not be available in production builds. unitTestSupport()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. getTraceCategoryEnabledFlag(const char * categoryName)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. getTraceSamplingState(const unsigned bucketName)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. 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,const WebConvertableToTraceFormat * convertableValues,unsigned char flags)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. updateTraceEventDuration(const unsigned char * categoryEnabledFlag,const char * name,TraceEventHandle)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. histogramCustomCounts(const char * name,int sample,int min,int max,int bucketCount)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. histogramEnumeration(const char * name,int sample,int boundaryValue)550 virtual void histogramEnumeration(const char* name, int sample, int boundaryValue) { } 551 // Unlike enumeration histograms, sparse histograms only allocate memory for non-empty buckets. histogramSparse(const char * name,int sample)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. createOffscreenGraphicsContext3D(const WebGraphicsContext3D::Attributes &,WebGraphicsContext3D * shareContext)560 virtual WebGraphicsContext3D* createOffscreenGraphicsContext3D(const WebGraphicsContext3D::Attributes&, WebGraphicsContext3D* shareContext) { return 0; } createOffscreenGraphicsContext3D(const WebGraphicsContext3D::Attributes &)561 virtual WebGraphicsContext3D* createOffscreenGraphicsContext3D(const WebGraphicsContext3D::Attributes&) { return 0; } 562 563 // Returns a newly allocated and initialized offscreen context provider. The provider may return a null 564 // graphics context if GPU is not supported. createSharedOffscreenGraphicsContext3DProvider()565 virtual WebGraphicsContext3DProvider* createSharedOffscreenGraphicsContext3DProvider() { return 0; } 566 567 // Returns true if the platform is capable of producing an offscreen context suitable for accelerating 2d canvas. 568 // This will return false if the platform cannot promise that contexts will be preserved across operations like 569 // locking the screen or if the platform cannot provide a context with suitable performance characteristics. 570 // 571 // This value must be checked again after a context loss event as the platform's capabilities may have changed. canAccelerate2dCanvas()572 virtual bool canAccelerate2dCanvas() { return false; } 573 isThreadedCompositingEnabled()574 virtual bool isThreadedCompositingEnabled() { return false; } 575 compositorSupport()576 virtual WebCompositorSupport* compositorSupport() { return 0; } 577 createFlingAnimator()578 virtual WebFlingAnimator* createFlingAnimator() { return 0; } 579 580 // Creates a new fling animation curve instance for device |deviceSource| 581 // with |velocity| and already scrolled |cumulativeScroll| pixels. createFlingAnimationCurve(WebGestureDevice deviceSource,const WebFloatPoint & velocity,const WebSize & cumulativeScroll)582 virtual WebGestureCurve* createFlingAnimationCurve(WebGestureDevice deviceSource, const WebFloatPoint& velocity, const WebSize& cumulativeScroll) { return 0; } 583 584 // WebRTC ---------------------------------------------------------- 585 586 // Creates an WebRTCPeerConnectionHandler for RTCPeerConnection. 587 // May return null if WebRTC functionality is not avaliable or out of resources. createRTCPeerConnectionHandler(WebRTCPeerConnectionHandlerClient *)588 virtual WebRTCPeerConnectionHandler* createRTCPeerConnectionHandler(WebRTCPeerConnectionHandlerClient*) { return 0; } 589 590 // May return null if WebRTC functionality is not avaliable or out of resources. createMediaStreamCenter(WebMediaStreamCenterClient *)591 virtual WebMediaStreamCenter* createMediaStreamCenter(WebMediaStreamCenterClient*) { return 0; } 592 593 594 // WebWorker ---------------------------------------------------------- 595 didStartWorkerRunLoop(const WebWorkerRunLoop &)596 virtual void didStartWorkerRunLoop(const WebWorkerRunLoop&) { } didStopWorkerRunLoop(const WebWorkerRunLoop &)597 virtual void didStopWorkerRunLoop(const WebWorkerRunLoop&) { } 598 599 // WebCrypto ---------------------------------------------------------- 600 crypto()601 virtual WebCrypto* crypto() { return 0; } 602 603 604 // Platform events ----------------------------------------------------- 605 // Device Orientation, Device Motion, Device Light, Battery, Gamepad. 606 607 // Request the platform to start listening to the events of the specified 608 // type and notify the given listener (if not null) when there is an update. startListening(WebPlatformEventType type,WebPlatformEventListener * listener)609 virtual void startListening(WebPlatformEventType type, WebPlatformEventListener* listener) { } 610 611 // Request the platform to stop listening to the specified event and no 612 // longer notify the listener, if any. stopListening(WebPlatformEventType type)613 virtual void stopListening(WebPlatformEventType type) { } 614 615 // Quota ----------------------------------------------------------- 616 617 // Queries the storage partition's storage usage and quota information. 618 // WebStorageQuotaCallbacks::didQueryStorageUsageAndQuota will be called 619 // with the current usage and quota information for the partition. When 620 // an error occurs WebStorageQuotaCallbacks::didFail is called with an 621 // error code. queryStorageUsageAndQuota(const WebURL & storagePartition,WebStorageQuotaType,WebStorageQuotaCallbacks)622 virtual void queryStorageUsageAndQuota( 623 const WebURL& storagePartition, 624 WebStorageQuotaType, 625 WebStorageQuotaCallbacks) { } 626 627 628 // WebDatabase -------------------------------------------------------- 629 databaseObserver()630 virtual WebDatabaseObserver* databaseObserver() { return 0; } 631 632 633 // Web Notifications -------------------------------------------------- 634 notificationPresenter()635 virtual WebNotificationPresenter* notificationPresenter() { return 0; } 636 637 638 // Geofencing --------------------------------------------------------- 639 geofencingProvider()640 virtual WebGeofencingProvider* geofencingProvider() { return 0; } 641 642 protected: ~Platform()643 virtual ~Platform() { } 644 }; 645 646 } // namespace blink 647 648 #endif 649