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