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