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 "third_party/WebKit/public/platform/Platform.h"
16 #include "third_party/WebKit/public/platform/WebScrollbarBehavior.h"
20 class BlinkPlatformImpl
: public blink::Platform
{
22 explicit BlinkPlatformImpl();
23 virtual ~BlinkPlatformImpl();
25 // blink::Platform methods:
26 virtual blink::WebMimeRegistry
* mimeRegistry();
27 virtual blink::WebThemeEngine
* themeEngine();
28 virtual blink::WebString
defaultLocale();
29 virtual double currentTime();
30 virtual double monotonicallyIncreasingTime();
31 virtual void cryptographicallyRandomValues(
32 unsigned char* buffer
, size_t length
);
33 virtual void setSharedTimerFiredFunction(void (*func
)());
34 virtual void setSharedTimerFireInterval(double interval_seconds
);
35 virtual void stopSharedTimer();
36 virtual void callOnMainThread(void (*func
)(void*), void* context
);
37 virtual bool isThreadedCompositingEnabled();
38 virtual blink::WebCompositorSupport
* compositorSupport();
39 virtual blink::WebURLLoader
* createURLLoader();
40 virtual blink::WebSocketHandle
* createWebSocketHandle();
41 virtual blink::WebString
userAgent();
42 virtual blink::WebData
parseDataURL(
43 const blink::WebURL
& url
, blink::WebString
& mime_type
,
44 blink::WebString
& charset
);
45 virtual blink::WebURLError
cancelledError(const blink::WebURL
& url
) const;
46 virtual blink::WebThread
* createThread(const char* name
);
47 virtual blink::WebThread
* currentThread();
48 virtual void yieldCurrentThread();
49 virtual blink::WebWaitableEvent
* createWaitableEvent();
50 virtual blink::WebWaitableEvent
* waitMultipleEvents(
51 const blink::WebVector
<blink::WebWaitableEvent
*>& events
);
52 virtual blink::WebScrollbarBehavior
* scrollbarBehavior();
53 virtual const unsigned char* getTraceCategoryEnabledFlag(
54 const char* category_name
);
57 void SuspendSharedTimer();
58 void ResumeSharedTimer();
61 if (shared_timer_func_
&& !shared_timer_suspended_
)
65 static void DestroyCurrentThread(void*);
67 base::MessageLoop
* main_loop_
;
68 base::OneShotTimer
<BlinkPlatformImpl
> shared_timer_
;
69 void (*shared_timer_func_
)();
70 double shared_timer_fire_time_
;
71 bool shared_timer_fire_time_was_set_while_suspended_
;
72 int shared_timer_suspended_
; // counter
73 base::ThreadLocalStorage::Slot current_thread_slot_
;
74 cc_blink::WebCompositorSupportImpl compositor_support_
;
75 WebThemeEngineImpl theme_engine_
;
76 WebMimeRegistryImpl mime_registry_
;
77 blink::WebScrollbarBehavior scrollbar_behavior_
;
79 DISALLOW_COPY_AND_ASSIGN(BlinkPlatformImpl
);
84 #endif // MOJO_SERVICES_HTML_VIEWER_BLINK_PLATFORM_IMPL_H_