| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef WEBKIT_PLATFORM_SUPPORT_IMPL_H_ | |
| 6 #define WEBKIT_PLATFORM_SUPPORT_IMPL_H_ | |
| 7 | |
| 8 #include "base/compiler_specific.h" | |
| 9 #include "base/debug/trace_event.h" | |
| 10 #include "base/platform_file.h" | |
| 11 #include "base/timer/timer.h" | |
| 12 #include "third_party/WebKit/public/platform/Platform.h" | |
| 13 #include "third_party/WebKit/public/platform/WebURLError.h" | |
| 14 #include "ui/base/layout.h" | |
| 15 #include "webkit/glue/resource_loader_bridge.h" | |
| 16 #include "webkit/glue/webkit_glue_export.h" | |
| 17 | |
| 18 namespace base { | |
| 19 class MessageLoop; | |
| 20 } | |
| 21 | |
| 22 namespace WebKit { | |
| 23 class WebSocketStreamHandle; | |
| 24 } | |
| 25 | |
| 26 namespace webkit_glue { | |
| 27 | |
| 28 class WebSocketStreamHandleDelegate; | |
| 29 class WebSocketStreamHandleBridge; | |
| 30 | |
| 31 class WEBKIT_GLUE_EXPORT WebKitPlatformSupportImpl : | |
| 32 NON_EXPORTED_BASE(public WebKit::Platform) { | |
| 33 public: | |
| 34 WebKitPlatformSupportImpl(); | |
| 35 virtual ~WebKitPlatformSupportImpl(); | |
| 36 | |
| 37 // Platform methods (partial implementation): | |
| 38 virtual base::PlatformFile databaseOpenFile( | |
| 39 const WebKit::WebString& vfs_file_name, int desired_flags); | |
| 40 virtual int databaseDeleteFile(const WebKit::WebString& vfs_file_name, | |
| 41 bool sync_dir); | |
| 42 virtual long databaseGetFileAttributes( | |
| 43 const WebKit::WebString& vfs_file_name); | |
| 44 virtual long long databaseGetFileSize(const WebKit::WebString& vfs_file_name); | |
| 45 virtual long long databaseGetSpaceAvailableForOrigin( | |
| 46 const WebKit::WebString& origin_identifier); | |
| 47 virtual WebKit::WebString signedPublicKeyAndChallengeString( | |
| 48 unsigned key_size_index, const WebKit::WebString& challenge, | |
| 49 const WebKit::WebURL& url); | |
| 50 virtual size_t memoryUsageMB(); | |
| 51 virtual size_t actualMemoryUsageMB(); | |
| 52 #if defined(OS_ANDROID) // Other OSes just use the default values. | |
| 53 // TODO(jochen): Remove these. | |
| 54 virtual size_t lowMemoryUsageMB(); | |
| 55 virtual size_t highMemoryUsageMB(); | |
| 56 virtual size_t highUsageDeltaMB(); | |
| 57 #endif | |
| 58 | |
| 59 virtual void startHeapProfiling(const WebKit::WebString& prefix); | |
| 60 virtual void stopHeapProfiling() OVERRIDE; | |
| 61 virtual void dumpHeapProfiling(const WebKit::WebString& reason); | |
| 62 virtual WebKit::WebString getHeapProfile() OVERRIDE; | |
| 63 | |
| 64 virtual bool processMemorySizesInBytes(size_t* private_bytes, | |
| 65 size_t* shared_bytes); | |
| 66 virtual bool memoryAllocatorWasteInBytes(size_t* size); | |
| 67 virtual WebKit::WebURLLoader* createURLLoader(); | |
| 68 virtual WebKit::WebSocketStreamHandle* createSocketStreamHandle(); | |
| 69 virtual WebKit::WebString userAgent(const WebKit::WebURL& url); | |
| 70 virtual WebKit::WebData parseDataURL( | |
| 71 const WebKit::WebURL& url, WebKit::WebString& mimetype, | |
| 72 WebKit::WebString& charset); | |
| 73 virtual WebKit::WebURLError cancelledError(const WebKit::WebURL& url) const; | |
| 74 virtual void decrementStatsCounter(const char* name); | |
| 75 virtual void incrementStatsCounter(const char* name); | |
| 76 virtual void histogramCustomCounts( | |
| 77 const char* name, int sample, int min, int max, int bucket_count); | |
| 78 virtual void histogramEnumeration( | |
| 79 const char* name, int sample, int boundary_value); | |
| 80 virtual void histogramSparse(const char* name, int sample); | |
| 81 virtual const unsigned char* getTraceCategoryEnabledFlag( | |
| 82 const char* category_name); | |
| 83 virtual long* getTraceSamplingState(const unsigned thread_bucket); | |
| 84 virtual void addTraceEvent( | |
| 85 char phase, | |
| 86 const unsigned char* category_group_enabled, | |
| 87 const char* name, | |
| 88 unsigned long long id, | |
| 89 int num_args, | |
| 90 const char** arg_names, | |
| 91 const unsigned char* arg_types, | |
| 92 const unsigned long long* arg_values, | |
| 93 unsigned char flags); | |
| 94 virtual WebKit::WebData loadResource(const char* name); | |
| 95 virtual WebKit::WebString queryLocalizedString( | |
| 96 WebKit::WebLocalizedString::Name name); | |
| 97 virtual WebKit::WebString queryLocalizedString( | |
| 98 WebKit::WebLocalizedString::Name name, int numeric_value); | |
| 99 virtual WebKit::WebString queryLocalizedString( | |
| 100 WebKit::WebLocalizedString::Name name, const WebKit::WebString& value); | |
| 101 virtual WebKit::WebString queryLocalizedString( | |
| 102 WebKit::WebLocalizedString::Name name, | |
| 103 const WebKit::WebString& value1, const WebKit::WebString& value2); | |
| 104 virtual void suddenTerminationChanged(bool enabled) { } | |
| 105 virtual double currentTime(); | |
| 106 virtual double monotonicallyIncreasingTime(); | |
| 107 virtual void cryptographicallyRandomValues( | |
| 108 unsigned char* buffer, size_t length); | |
| 109 virtual void setSharedTimerFiredFunction(void (*func)()); | |
| 110 virtual void setSharedTimerFireInterval(double interval_seconds); | |
| 111 virtual void stopSharedTimer(); | |
| 112 virtual void callOnMainThread(void (*func)(void*), void* context); | |
| 113 | |
| 114 | |
| 115 // Embedder functions. The following are not implemented by the glue layer and | |
| 116 // need to be specialized by the embedder. | |
| 117 | |
| 118 // Gets a localized string given a message id. Returns an empty string if the | |
| 119 // message id is not found. | |
| 120 virtual base::string16 GetLocalizedString(int message_id) = 0; | |
| 121 | |
| 122 // Returns the raw data for a resource. This resource must have been | |
| 123 // specified as BINDATA in the relevant .rc file. | |
| 124 virtual base::StringPiece GetDataResource(int resource_id, | |
| 125 ui::ScaleFactor scale_factor) = 0; | |
| 126 | |
| 127 // Creates a ResourceLoaderBridge. | |
| 128 virtual ResourceLoaderBridge* CreateResourceLoader( | |
| 129 const ResourceLoaderBridge::RequestInfo& request_info) = 0; | |
| 130 // Creates a WebSocketStreamHandleBridge. | |
| 131 virtual WebSocketStreamHandleBridge* CreateWebSocketBridge( | |
| 132 WebKit::WebSocketStreamHandle* handle, | |
| 133 WebSocketStreamHandleDelegate* delegate) = 0; | |
| 134 | |
| 135 void SuspendSharedTimer(); | |
| 136 void ResumeSharedTimer(); | |
| 137 virtual void OnStartSharedTimer(base::TimeDelta delay) {} | |
| 138 | |
| 139 private: | |
| 140 void DoTimeout() { | |
| 141 if (shared_timer_func_ && !shared_timer_suspended_) | |
| 142 shared_timer_func_(); | |
| 143 } | |
| 144 | |
| 145 base::MessageLoop* main_loop_; | |
| 146 base::OneShotTimer<WebKitPlatformSupportImpl> shared_timer_; | |
| 147 void (*shared_timer_func_)(); | |
| 148 double shared_timer_fire_time_; | |
| 149 bool shared_timer_fire_time_was_set_while_suspended_; | |
| 150 int shared_timer_suspended_; // counter | |
| 151 }; | |
| 152 | |
| 153 } // namespace webkit_glue | |
| 154 | |
| 155 #endif // WEBKIT_PLATFORM_SUPPORT_IMPL_H_ | |
| OLD | NEW |