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 #include "components/html_viewer/blink_platform_impl.h" | 5 #include "components/html_viewer/blink_platform_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
13 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
14 #include "base/threading/platform_thread.h" | 14 #include "base/threading/platform_thread.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
17 #include "components/html_viewer/blink_resource_constants.h" | 17 #include "components/html_viewer/blink_resource_constants.h" |
18 #include "components/html_viewer/web_clipboard_impl.h" | 18 #include "components/html_viewer/web_clipboard_impl.h" |
19 #include "components/html_viewer/web_cookie_jar_impl.h" | 19 #include "components/html_viewer/web_cookie_jar_impl.h" |
| 20 #include "components/html_viewer/web_graphics_context_3d_command_buffer_impl.h" |
20 #include "components/html_viewer/web_socket_handle_impl.h" | 21 #include "components/html_viewer/web_socket_handle_impl.h" |
21 #include "components/html_viewer/web_url_loader_impl.h" | 22 #include "components/html_viewer/web_url_loader_impl.h" |
22 #include "components/message_port/web_message_port_channel_impl.h" | 23 #include "components/message_port/web_message_port_channel_impl.h" |
23 #include "components/mime_util/mime_util.h" | 24 #include "components/mime_util/mime_util.h" |
24 #include "components/scheduler/child/webthread_impl_for_worker_scheduler.h" | 25 #include "components/scheduler/child/webthread_impl_for_worker_scheduler.h" |
25 #include "components/scheduler/renderer/renderer_scheduler.h" | 26 #include "components/scheduler/renderer/renderer_scheduler.h" |
26 #include "components/scheduler/renderer/webthread_impl_for_renderer_scheduler.h" | 27 #include "components/scheduler/renderer/webthread_impl_for_renderer_scheduler.h" |
27 #include "mojo/application/public/cpp/application_impl.h" | 28 #include "mojo/application/public/cpp/application_impl.h" |
28 #include "mojo/application/public/cpp/connect.h" | 29 #include "mojo/application/public/cpp/connect.h" |
29 #include "mojo/common/user_agent.h" | 30 #include "mojo/common/user_agent.h" |
30 #include "net/base/data_url.h" | 31 #include "net/base/data_url.h" |
31 #include "net/base/ip_address_number.h" | 32 #include "net/base/ip_address_number.h" |
32 #include "net/base/net_errors.h" | 33 #include "net/base/net_errors.h" |
33 #include "net/base/net_util.h" | 34 #include "net/base/net_util.h" |
34 #include "third_party/WebKit/public/platform/WebWaitableEvent.h" | 35 #include "third_party/WebKit/public/platform/WebWaitableEvent.h" |
35 #include "ui/base/resource/resource_bundle.h" | 36 #include "ui/base/resource/resource_bundle.h" |
36 #include "ui/events/gestures/blink/web_gesture_curve_impl.h" | 37 #include "ui/events/gestures/blink/web_gesture_curve_impl.h" |
| 38 #include "url/gurl.h" |
37 | 39 |
38 namespace html_viewer { | 40 namespace html_viewer { |
39 namespace { | 41 namespace { |
40 | 42 |
41 // Allows overriding user agent scring. | 43 // Allows overriding user agent scring. |
42 const char kUserAgentSwitch[] = "user-agent"; | 44 const char kUserAgentSwitch[] = "user-agent"; |
43 | 45 |
44 class WebWaitableEventImpl : public blink::WebWaitableEvent { | 46 class WebWaitableEventImpl : public blink::WebWaitableEvent { |
45 public: | 47 public: |
46 WebWaitableEventImpl(ResetPolicy policy, InitialState state) { | 48 WebWaitableEventImpl(ResetPolicy policy, InitialState state) { |
(...skipping 14 matching lines...) Expand all Loading... |
61 private: | 63 private: |
62 scoped_ptr<base::WaitableEvent> impl_; | 64 scoped_ptr<base::WaitableEvent> impl_; |
63 DISALLOW_COPY_AND_ASSIGN(WebWaitableEventImpl); | 65 DISALLOW_COPY_AND_ASSIGN(WebWaitableEventImpl); |
64 }; | 66 }; |
65 | 67 |
66 } // namespace | 68 } // namespace |
67 | 69 |
68 BlinkPlatformImpl::BlinkPlatformImpl( | 70 BlinkPlatformImpl::BlinkPlatformImpl( |
69 mojo::ApplicationImpl* app, | 71 mojo::ApplicationImpl* app, |
70 scheduler::RendererScheduler* renderer_scheduler) | 72 scheduler::RendererScheduler* renderer_scheduler) |
71 : main_thread_task_runner_(renderer_scheduler->DefaultTaskRunner()), | 73 : app_(app), |
| 74 main_thread_task_runner_(renderer_scheduler->DefaultTaskRunner()), |
72 main_thread_(new scheduler::WebThreadImplForRendererScheduler( | 75 main_thread_(new scheduler::WebThreadImplForRendererScheduler( |
73 renderer_scheduler)) { | 76 renderer_scheduler)) { |
74 if (app) { | 77 if (app) { |
75 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 78 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
76 request->url = mojo::String::From("mojo:network_service"); | 79 request->url = mojo::String::From("mojo:network_service"); |
77 scoped_ptr<mojo::ApplicationConnection> connection = | 80 scoped_ptr<mojo::ApplicationConnection> connection = |
78 app->ConnectToApplication(request.Pass()); | 81 app->ConnectToApplication(request.Pass()); |
79 connection->ConnectToService(&web_socket_factory_); | 82 connection->ConnectToService(&web_socket_factory_); |
80 connection->ConnectToService(&url_loader_factory_); | 83 connection->ConnectToService(&url_loader_factory_); |
81 | 84 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 blink::WebScrollbarBehavior* BlinkPlatformImpl::scrollbarBehavior() { | 158 blink::WebScrollbarBehavior* BlinkPlatformImpl::scrollbarBehavior() { |
156 return &scrollbar_behavior_; | 159 return &scrollbar_behavior_; |
157 } | 160 } |
158 | 161 |
159 const unsigned char* BlinkPlatformImpl::getTraceCategoryEnabledFlag( | 162 const unsigned char* BlinkPlatformImpl::getTraceCategoryEnabledFlag( |
160 const char* category_name) { | 163 const char* category_name) { |
161 static const unsigned char buf[] = "*"; | 164 static const unsigned char buf[] = "*"; |
162 return buf; | 165 return buf; |
163 } | 166 } |
164 | 167 |
| 168 blink::WebGraphicsContext3D* |
| 169 BlinkPlatformImpl::createOffscreenGraphicsContext3D( |
| 170 const blink::WebGraphicsContext3D::Attributes& attributes, |
| 171 blink::WebGraphicsContext3D* share_context) { |
| 172 return createOffscreenGraphicsContext3D(attributes, share_context, nullptr); |
| 173 } |
| 174 |
| 175 blink::WebGraphicsContext3D* |
| 176 BlinkPlatformImpl::createOffscreenGraphicsContext3D( |
| 177 const blink::WebGraphicsContext3D::Attributes& attributes, |
| 178 blink::WebGraphicsContext3D* share_context, |
| 179 blink::WebGLInfo* gl_info) { |
| 180 return WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( |
| 181 app_, GURL(attributes.topDocumentURL), attributes, share_context, |
| 182 gl_info); |
| 183 } |
| 184 |
| 185 blink::WebGraphicsContext3D* |
| 186 BlinkPlatformImpl::createOffscreenGraphicsContext3D( |
| 187 const blink::WebGraphicsContext3D::Attributes& attributes) { |
| 188 return createOffscreenGraphicsContext3D(attributes, nullptr, nullptr); |
| 189 } |
| 190 |
| 191 blink::WebGraphicsContext3DProvider* |
| 192 BlinkPlatformImpl::createSharedOffscreenGraphicsContext3DProvider() { |
| 193 return nullptr; |
| 194 } |
| 195 |
165 blink::WebData BlinkPlatformImpl::loadResource(const char* resource) { | 196 blink::WebData BlinkPlatformImpl::loadResource(const char* resource) { |
166 for (size_t i = 0; i < arraysize(kDataResources); ++i) { | 197 for (size_t i = 0; i < arraysize(kDataResources); ++i) { |
167 if (!strcmp(resource, kDataResources[i].name)) { | 198 if (!strcmp(resource, kDataResources[i].name)) { |
168 base::StringPiece data = | 199 base::StringPiece data = |
169 ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( | 200 ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( |
170 kDataResources[i].id, ui::SCALE_FACTOR_100P); | 201 kDataResources[i].id, ui::SCALE_FACTOR_100P); |
171 return blink::WebData(data.data(), data.size()); | 202 return blink::WebData(data.data(), data.size()); |
172 } | 203 } |
173 } | 204 } |
174 NOTREACHED() << "Requested resource is unavailable: " << resource; | 205 NOTREACHED() << "Requested resource is unavailable: " << resource; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 BlinkPlatformImpl::notificationManager() { | 311 BlinkPlatformImpl::notificationManager() { |
281 return &web_notification_manager_; | 312 return &web_notification_manager_; |
282 } | 313 } |
283 | 314 |
284 void BlinkPlatformImpl::UpdateWebThreadTLS(blink::WebThread* thread) { | 315 void BlinkPlatformImpl::UpdateWebThreadTLS(blink::WebThread* thread) { |
285 DCHECK(!current_thread_slot_.Get()); | 316 DCHECK(!current_thread_slot_.Get()); |
286 current_thread_slot_.Set(thread); | 317 current_thread_slot_.Set(thread); |
287 } | 318 } |
288 | 319 |
289 } // namespace html_viewer | 320 } // namespace html_viewer |
OLD | NEW |