Update optimize_png_files.sh to work on msysgit bash.
[chromium-blink-merge.git] / content / child / blink_platform_impl.h
blob32e872e8839f26ed0bf5ed252b0da25c79ef4371
1 // Copyright 2014 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.
5 #ifndef CONTENT_CHILD_BLINK_PLATFORM_IMPL_H_
6 #define CONTENT_CHILD_BLINK_PLATFORM_IMPL_H_
8 #include "base/compiler_specific.h"
9 #include "base/debug/trace_event.h"
10 #include "base/platform_file.h"
11 #include "base/threading/thread_local_storage.h"
12 #include "base/timer/timer.h"
13 #include "content/child/webcrypto/webcrypto_impl.h"
14 #include "content/child/webfallbackthemeengine_impl.h"
15 #include "content/common/content_export.h"
16 #include "third_party/WebKit/public/platform/Platform.h"
17 #include "third_party/WebKit/public/platform/WebURLError.h"
18 #include "ui/base/layout.h"
20 #if defined(USE_DEFAULT_RENDER_THEME)
21 #include "content/child/webthemeengine_impl_default.h"
22 #elif defined(OS_WIN)
23 #include "content/child/webthemeengine_impl_win.h"
24 #elif defined(OS_MACOSX)
25 #include "content/child/webthemeengine_impl_mac.h"
26 #elif defined(OS_ANDROID)
27 #include "content/child/webthemeengine_impl_android.h"
28 #endif
30 namespace base {
31 class MessageLoop;
34 namespace content {
35 class FlingCurveConfiguration;
36 class WebCryptoImpl;
38 class CONTENT_EXPORT BlinkPlatformImpl
39 : NON_EXPORTED_BASE(public blink::Platform) {
40 public:
41 BlinkPlatformImpl();
42 virtual ~BlinkPlatformImpl();
44 // Platform methods (partial implementation):
45 virtual blink::WebThemeEngine* themeEngine();
46 virtual blink::WebFallbackThemeEngine* fallbackThemeEngine();
47 virtual base::PlatformFile databaseOpenFile(
48 const blink::WebString& vfs_file_name, int desired_flags);
49 virtual int databaseDeleteFile(const blink::WebString& vfs_file_name,
50 bool sync_dir);
51 virtual long databaseGetFileAttributes(
52 const blink::WebString& vfs_file_name);
53 virtual long long databaseGetFileSize(const blink::WebString& vfs_file_name);
54 virtual long long databaseGetSpaceAvailableForOrigin(
55 const blink::WebString& origin_identifier);
56 virtual blink::WebString signedPublicKeyAndChallengeString(
57 unsigned key_size_index, const blink::WebString& challenge,
58 const blink::WebURL& url);
59 virtual size_t memoryUsageMB();
60 virtual size_t actualMemoryUsageMB();
61 virtual size_t physicalMemoryMB();
62 virtual size_t virtualMemoryLimitMB();
63 virtual size_t numberOfProcessors();
65 virtual void startHeapProfiling(const blink::WebString& prefix);
66 virtual void stopHeapProfiling() OVERRIDE;
67 virtual void dumpHeapProfiling(const blink::WebString& reason);
68 virtual blink::WebString getHeapProfile() OVERRIDE;
70 virtual bool processMemorySizesInBytes(size_t* private_bytes,
71 size_t* shared_bytes);
72 virtual bool memoryAllocatorWasteInBytes(size_t* size);
73 virtual blink::WebDiscardableMemory* allocateAndLockDiscardableMemory(
74 size_t bytes);
75 virtual size_t maxDecodedImageBytes() OVERRIDE;
76 virtual blink::WebURLLoader* createURLLoader();
77 virtual blink::WebSocketStreamHandle* createSocketStreamHandle();
78 virtual blink::WebSocketHandle* createWebSocketHandle() OVERRIDE;
79 virtual blink::WebString userAgent();
80 virtual blink::WebData parseDataURL(
81 const blink::WebURL& url, blink::WebString& mimetype,
82 blink::WebString& charset);
83 virtual blink::WebURLError cancelledError(const blink::WebURL& url) const;
84 virtual blink::WebThread* createThread(const char* name);
85 virtual blink::WebThread* currentThread();
86 virtual blink::WebWaitableEvent* createWaitableEvent();
87 virtual blink::WebWaitableEvent* waitMultipleEvents(
88 const blink::WebVector<blink::WebWaitableEvent*>& events);
89 virtual void decrementStatsCounter(const char* name);
90 virtual void incrementStatsCounter(const char* name);
91 virtual void histogramCustomCounts(
92 const char* name, int sample, int min, int max, int bucket_count);
93 virtual void histogramEnumeration(
94 const char* name, int sample, int boundary_value);
95 virtual void histogramSparse(const char* name, int sample);
96 virtual const unsigned char* getTraceCategoryEnabledFlag(
97 const char* category_name);
98 virtual long* getTraceSamplingState(const unsigned thread_bucket);
99 virtual TraceEventHandle addTraceEvent(
100 char phase,
101 const unsigned char* category_group_enabled,
102 const char* name,
103 unsigned long long id,
104 int num_args,
105 const char** arg_names,
106 const unsigned char* arg_types,
107 const unsigned long long* arg_values,
108 unsigned char flags);
109 virtual TraceEventHandle addTraceEvent(
110 char phase,
111 const unsigned char* category_group_enabled,
112 const char* name,
113 unsigned long long id,
114 int num_args,
115 const char** arg_names,
116 const unsigned char* arg_types,
117 const unsigned long long* arg_values,
118 const blink::WebConvertableToTraceFormat* convertable_values,
119 unsigned char flags);
120 virtual void updateTraceEventDuration(
121 const unsigned char* category_group_enabled,
122 const char* name,
123 TraceEventHandle);
124 virtual blink::WebData loadResource(const char* name);
125 virtual blink::WebString queryLocalizedString(
126 blink::WebLocalizedString::Name name);
127 virtual blink::WebString queryLocalizedString(
128 blink::WebLocalizedString::Name name, int numeric_value);
129 virtual blink::WebString queryLocalizedString(
130 blink::WebLocalizedString::Name name, const blink::WebString& value);
131 virtual blink::WebString queryLocalizedString(
132 blink::WebLocalizedString::Name name,
133 const blink::WebString& value1, const blink::WebString& value2);
134 virtual void suddenTerminationChanged(bool enabled) { }
135 virtual double currentTime();
136 virtual double monotonicallyIncreasingTime();
137 virtual void cryptographicallyRandomValues(
138 unsigned char* buffer, size_t length);
139 virtual void setSharedTimerFiredFunction(void (*func)());
140 virtual void setSharedTimerFireInterval(double interval_seconds);
141 virtual void stopSharedTimer();
142 virtual void callOnMainThread(void (*func)(void*), void* context);
143 virtual blink::WebGestureCurve* createFlingAnimationCurve(
144 int device_source,
145 const blink::WebFloatPoint& velocity,
146 const blink::WebSize& cumulative_scroll) OVERRIDE;
147 virtual void didStartWorkerRunLoop(
148 const blink::WebWorkerRunLoop& runLoop) OVERRIDE;
149 virtual void didStopWorkerRunLoop(
150 const blink::WebWorkerRunLoop& runLoop) OVERRIDE;
151 virtual blink::WebCrypto* crypto() OVERRIDE;
153 void SetFlingCurveParameters(const std::vector<float>& new_touchpad,
154 const std::vector<float>& new_touchscreen);
156 void SuspendSharedTimer();
157 void ResumeSharedTimer();
158 virtual void OnStartSharedTimer(base::TimeDelta delay) {}
160 private:
161 static void DestroyCurrentThread(void*);
163 void DoTimeout() {
164 if (shared_timer_func_ && !shared_timer_suspended_)
165 shared_timer_func_();
168 WebThemeEngineImpl native_theme_engine_;
169 WebFallbackThemeEngineImpl fallback_theme_engine_;
170 base::MessageLoop* main_loop_;
171 base::OneShotTimer<BlinkPlatformImpl> shared_timer_;
172 void (*shared_timer_func_)();
173 double shared_timer_fire_time_;
174 bool shared_timer_fire_time_was_set_while_suspended_;
175 int shared_timer_suspended_; // counter
176 scoped_ptr<FlingCurveConfiguration> fling_curve_configuration_;
177 base::ThreadLocalStorage::Slot current_thread_slot_;
178 WebCryptoImpl web_crypto_;
181 } // namespace content
183 #endif // CONTENT_CHILD_BLINK_PLATFORM_IMPL_H_