OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 COMPONENTS_HTML_VIEWER_BLINK_PLATFORM_IMPL_H_ | 5 #ifndef COMPONENTS_HTML_VIEWER_BLINK_PLATFORM_IMPL_H_ |
6 #define COMPONENTS_HTML_VIEWER_BLINK_PLATFORM_IMPL_H_ | 6 #define COMPONENTS_HTML_VIEWER_BLINK_PLATFORM_IMPL_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/threading/thread_local_storage.h" | 10 #include "base/threading/thread_local_storage.h" |
11 #include "base/timer/timer.h" | 11 #include "base/timer/timer.h" |
12 #include "cc/blink/web_compositor_support_impl.h" | 12 #include "cc/blink/web_compositor_support_impl.h" |
13 #include "components/html_viewer/blink_resource_map.h" | 13 #include "components/html_viewer/blink_resource_map.h" |
14 #include "components/html_viewer/mock_web_blob_registry_impl.h" | 14 #include "components/html_viewer/mock_web_blob_registry_impl.h" |
15 #include "components/html_viewer/web_mime_registry_impl.h" | 15 #include "components/html_viewer/web_mime_registry_impl.h" |
16 #include "components/html_viewer/web_notification_manager_impl.h" | 16 #include "components/html_viewer/web_notification_manager_impl.h" |
17 #include "components/html_viewer/web_scheduler_impl.h" | |
18 #include "components/html_viewer/web_theme_engine_impl.h" | 17 #include "components/html_viewer/web_theme_engine_impl.h" |
19 #include "components/webcrypto/webcrypto_impl.h" | 18 #include "components/webcrypto/webcrypto_impl.h" |
20 #include "mojo/services/network/public/interfaces/network_service.mojom.h" | 19 #include "mojo/services/network/public/interfaces/network_service.mojom.h" |
21 #include "third_party/WebKit/public/platform/Platform.h" | 20 #include "third_party/WebKit/public/platform/Platform.h" |
22 #include "third_party/WebKit/public/platform/WebScrollbarBehavior.h" | 21 #include "third_party/WebKit/public/platform/WebScrollbarBehavior.h" |
23 | 22 |
| 23 namespace scheduler { |
| 24 class RendererScheduler; |
| 25 class WebThreadImplForRendererScheduler; |
| 26 } |
| 27 |
24 namespace mojo { | 28 namespace mojo { |
25 class ApplicationImpl; | 29 class ApplicationImpl; |
26 } | 30 } |
27 | 31 |
28 namespace html_viewer { | 32 namespace html_viewer { |
29 | 33 |
30 class WebClipboardImpl; | 34 class WebClipboardImpl; |
31 class WebCookieJarImpl; | 35 class WebCookieJarImpl; |
32 | 36 |
33 class BlinkPlatformImpl : public blink::Platform { | 37 class BlinkPlatformImpl : public blink::Platform { |
34 public: | 38 public: |
35 // |app| may be null in tests. | 39 // |app| may be null in tests. |
36 explicit BlinkPlatformImpl(mojo::ApplicationImpl* app); | 40 BlinkPlatformImpl(mojo::ApplicationImpl* app, |
| 41 scheduler::RendererScheduler* renderer_scheduler); |
37 virtual ~BlinkPlatformImpl(); | 42 virtual ~BlinkPlatformImpl(); |
38 | 43 |
39 // blink::Platform methods: | 44 // blink::Platform methods: |
40 virtual blink::WebCookieJar* cookieJar(); | 45 virtual blink::WebCookieJar* cookieJar(); |
41 virtual blink::WebClipboard* clipboard(); | 46 virtual blink::WebClipboard* clipboard(); |
42 virtual blink::WebMimeRegistry* mimeRegistry(); | 47 virtual blink::WebMimeRegistry* mimeRegistry(); |
43 virtual blink::WebThemeEngine* themeEngine(); | 48 virtual blink::WebThemeEngine* themeEngine(); |
44 virtual blink::WebScheduler* scheduler(); | |
45 virtual blink::WebString defaultLocale(); | 49 virtual blink::WebString defaultLocale(); |
46 virtual blink::WebBlobRegistry* blobRegistry(); | 50 virtual blink::WebBlobRegistry* blobRegistry(); |
47 virtual double currentTime(); | 51 virtual double currentTime(); |
48 virtual double monotonicallyIncreasingTime(); | 52 virtual double monotonicallyIncreasingTime(); |
49 virtual void cryptographicallyRandomValues(unsigned char* buffer, | 53 virtual void cryptographicallyRandomValues(unsigned char* buffer, |
50 size_t length); | 54 size_t length); |
51 virtual void setSharedTimerFiredFunction(void (*func)()); | 55 virtual void setSharedTimerFiredFunction(void (*func)()); |
52 virtual void setSharedTimerFireInterval(double interval_seconds); | 56 virtual void setSharedTimerFireInterval(double interval_seconds); |
53 virtual void stopSharedTimer(); | 57 virtual void stopSharedTimer(); |
54 virtual bool isThreadedCompositingEnabled(); | 58 virtual bool isThreadedCompositingEnabled(); |
(...skipping 21 matching lines...) Expand all Loading... |
76 virtual blink::WebGestureCurve* createFlingAnimationCurve( | 80 virtual blink::WebGestureCurve* createFlingAnimationCurve( |
77 blink::WebGestureDevice device_source, | 81 blink::WebGestureDevice device_source, |
78 const blink::WebFloatPoint& velocity, | 82 const blink::WebFloatPoint& velocity, |
79 const blink::WebSize& cumulative_scroll); | 83 const blink::WebSize& cumulative_scroll); |
80 virtual blink::WebCrypto* crypto(); | 84 virtual blink::WebCrypto* crypto(); |
81 virtual blink::WebNotificationManager* notificationManager(); | 85 virtual blink::WebNotificationManager* notificationManager(); |
82 | 86 |
83 private: | 87 private: |
84 void SuspendSharedTimer(); | 88 void SuspendSharedTimer(); |
85 void ResumeSharedTimer(); | 89 void ResumeSharedTimer(); |
| 90 void UpdateWebThreadTLS(blink::WebThread* thread); |
86 | 91 |
87 void DoTimeout() { | 92 void DoTimeout() { |
88 if (shared_timer_func_ && !shared_timer_suspended_) | 93 if (shared_timer_func_ && !shared_timer_suspended_) |
89 shared_timer_func_(); | 94 shared_timer_func_(); |
90 } | 95 } |
91 | 96 |
92 static void DestroyCurrentThread(void*); | 97 static void DestroyCurrentThread(void*); |
93 | 98 |
| 99 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
| 100 scoped_ptr<scheduler::WebThreadImplForRendererScheduler> main_thread_; |
94 base::OneShotTimer<BlinkPlatformImpl> shared_timer_; | 101 base::OneShotTimer<BlinkPlatformImpl> shared_timer_; |
95 void (*shared_timer_func_)(); | 102 void (*shared_timer_func_)(); |
96 double shared_timer_fire_time_; | 103 double shared_timer_fire_time_; |
97 bool shared_timer_fire_time_was_set_while_suspended_; | 104 bool shared_timer_fire_time_was_set_while_suspended_; |
98 int shared_timer_suspended_; // counter | 105 int shared_timer_suspended_; // counter |
99 base::ThreadLocalStorage::Slot current_thread_slot_; | 106 base::ThreadLocalStorage::Slot current_thread_slot_; |
100 cc_blink::WebCompositorSupportImpl compositor_support_; | 107 cc_blink::WebCompositorSupportImpl compositor_support_; |
101 WebThemeEngineImpl theme_engine_; | 108 WebThemeEngineImpl theme_engine_; |
102 WebMimeRegistryImpl mime_registry_; | 109 WebMimeRegistryImpl mime_registry_; |
103 WebSchedulerImpl scheduler_; | |
104 webcrypto::WebCryptoImpl web_crypto_; | 110 webcrypto::WebCryptoImpl web_crypto_; |
105 WebNotificationManagerImpl web_notification_manager_; | 111 WebNotificationManagerImpl web_notification_manager_; |
106 blink::WebScrollbarBehavior scrollbar_behavior_; | 112 blink::WebScrollbarBehavior scrollbar_behavior_; |
107 BlinkResourceMap blink_resource_map_; | 113 BlinkResourceMap blink_resource_map_; |
108 mojo::NetworkServicePtr network_service_; | 114 mojo::NetworkServicePtr network_service_; |
109 MockWebBlobRegistryImpl blob_registry_; | 115 MockWebBlobRegistryImpl blob_registry_; |
110 scoped_ptr<WebCookieJarImpl> cookie_jar_; | 116 scoped_ptr<WebCookieJarImpl> cookie_jar_; |
111 scoped_ptr<WebClipboardImpl> clipboard_; | 117 scoped_ptr<WebClipboardImpl> clipboard_; |
112 | 118 |
113 DISALLOW_COPY_AND_ASSIGN(BlinkPlatformImpl); | 119 DISALLOW_COPY_AND_ASSIGN(BlinkPlatformImpl); |
114 }; | 120 }; |
115 | 121 |
116 } // namespace html_viewer | 122 } // namespace html_viewer |
117 | 123 |
118 #endif // COMPONENTS_HTML_VIEWER_BLINK_PLATFORM_IMPL_H_ | 124 #endif // COMPONENTS_HTML_VIEWER_BLINK_PLATFORM_IMPL_H_ |
OLD | NEW |