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