Use scoped_ptr::Pass instead of scoped_ptr::PassAs<T>.
[chromium-blink-merge.git] / mojo / services / html_viewer / blink_platform_impl.h
blob9abd3363d3cc6eda39bab360d19e9963de1d337d
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 MOJO_SERVICES_HTML_VIEWER_BLINK_PLATFORM_IMPL_H_
6 #define MOJO_SERVICES_HTML_VIEWER_BLINK_PLATFORM_IMPL_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h"
10 #include "base/threading/thread_local_storage.h"
11 #include "base/timer/timer.h"
12 #include "cc/blink/web_compositor_support_impl.h"
13 #include "mojo/services/html_viewer/webmimeregistry_impl.h"
14 #include "mojo/services/html_viewer/webthemeengine_impl.h"
15 #include "mojo/services/public/interfaces/network/network_service.mojom.h"
16 #include "third_party/WebKit/public/platform/Platform.h"
17 #include "third_party/WebKit/public/platform/WebScrollbarBehavior.h"
19 namespace mojo {
20 class ApplicationImpl;
21 class WebClipboardImpl;
22 class WebCookieJarImpl;
24 class BlinkPlatformImpl : public blink::Platform {
25 public:
26 explicit BlinkPlatformImpl(ApplicationImpl* app);
27 virtual ~BlinkPlatformImpl();
29 // blink::Platform methods:
30 virtual blink::WebCookieJar* cookieJar();
31 virtual blink::WebClipboard* clipboard();
32 virtual blink::WebMimeRegistry* mimeRegistry();
33 virtual blink::WebThemeEngine* themeEngine();
34 virtual blink::WebString defaultLocale();
35 virtual double currentTime();
36 virtual double monotonicallyIncreasingTime();
37 virtual void cryptographicallyRandomValues(
38 unsigned char* buffer, size_t length);
39 virtual void setSharedTimerFiredFunction(void (*func)());
40 virtual void setSharedTimerFireInterval(double interval_seconds);
41 virtual void stopSharedTimer();
42 virtual void callOnMainThread(void (*func)(void*), void* context);
43 virtual bool isThreadedCompositingEnabled();
44 virtual blink::WebCompositorSupport* compositorSupport();
45 virtual blink::WebURLLoader* createURLLoader();
46 virtual blink::WebSocketHandle* createWebSocketHandle();
47 virtual blink::WebString userAgent();
48 virtual blink::WebData parseDataURL(
49 const blink::WebURL& url, blink::WebString& mime_type,
50 blink::WebString& charset);
51 virtual blink::WebURLError cancelledError(const blink::WebURL& url) const;
52 virtual blink::WebThread* createThread(const char* name);
53 virtual blink::WebThread* currentThread();
54 virtual void yieldCurrentThread();
55 virtual blink::WebWaitableEvent* createWaitableEvent();
56 virtual blink::WebWaitableEvent* waitMultipleEvents(
57 const blink::WebVector<blink::WebWaitableEvent*>& events);
58 virtual blink::WebScrollbarBehavior* scrollbarBehavior();
59 virtual const unsigned char* getTraceCategoryEnabledFlag(
60 const char* category_name);
62 private:
63 void SuspendSharedTimer();
64 void ResumeSharedTimer();
66 void DoTimeout() {
67 if (shared_timer_func_ && !shared_timer_suspended_)
68 shared_timer_func_();
71 static void DestroyCurrentThread(void*);
73 NetworkServicePtr network_service_;
74 base::MessageLoop* main_loop_;
75 base::OneShotTimer<BlinkPlatformImpl> shared_timer_;
76 void (*shared_timer_func_)();
77 double shared_timer_fire_time_;
78 bool shared_timer_fire_time_was_set_while_suspended_;
79 int shared_timer_suspended_; // counter
80 base::ThreadLocalStorage::Slot current_thread_slot_;
81 cc_blink::WebCompositorSupportImpl compositor_support_;
82 WebThemeEngineImpl theme_engine_;
83 scoped_ptr<WebCookieJarImpl> cookie_jar_;
84 scoped_ptr<WebClipboardImpl> clipboard_;
85 WebMimeRegistryImpl mime_registry_;
86 blink::WebScrollbarBehavior scrollbar_behavior_;
88 DISALLOW_COPY_AND_ASSIGN(BlinkPlatformImpl);
91 } // namespace mojo
93 #endif // MOJO_SERVICES_HTML_VIEWER_BLINK_PLATFORM_IMPL_H_