Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: components/html_viewer/html_document.cc

Issue 1281663002: Mandoline: Allow submitting CompositorFrames directly to mojo::Views (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Rob's comments + Lots of cleanup Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/html_document.h" 5 #include "components/html_viewer/html_document.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/thread_task_runner_handle.h" 14 #include "base/thread_task_runner_handle.h"
15 #include "components/devtools_service/public/cpp/switches.h" 15 #include "components/devtools_service/public/cpp/switches.h"
16 #include "components/html_viewer/blink_input_events_type_converters.h" 16 #include "components/html_viewer/blink_input_events_type_converters.h"
17 #include "components/html_viewer/blink_url_request_type_converters.h" 17 #include "components/html_viewer/blink_url_request_type_converters.h"
18 #include "components/html_viewer/devtools_agent_impl.h" 18 #include "components/html_viewer/devtools_agent_impl.h"
19 #include "components/html_viewer/geolocation_client_impl.h" 19 #include "components/html_viewer/geolocation_client_impl.h"
20 #include "components/html_viewer/global_state.h" 20 #include "components/html_viewer/global_state.h"
21 #include "components/html_viewer/media_factory.h" 21 #include "components/html_viewer/media_factory.h"
22 #include "components/html_viewer/stats_collection_controller.h" 22 #include "components/html_viewer/stats_collection_controller.h"
23 #include "components/html_viewer/web_layer_tree_view_impl.h" 23 #include "components/html_viewer/web_layer_tree_view_impl.h"
24 #include "components/html_viewer/web_storage_namespace_impl.h" 24 #include "components/html_viewer/web_storage_namespace_impl.h"
25 #include "components/html_viewer/web_url_loader_impl.h" 25 #include "components/html_viewer/web_url_loader_impl.h"
26 #include "components/view_manager/public/cpp/view.h" 26 #include "components/view_manager/public/cpp/view.h"
27 #include "components/view_manager/public/cpp/view_manager.h" 27 #include "components/view_manager/public/cpp/view_manager.h"
28 #include "components/view_manager/public/cpp/view_property.h" 28 #include "components/view_manager/public/cpp/view_property.h"
29 #include "components/view_manager/public/interfaces/surfaces.mojom.h"
30 #include "mojo/application/public/cpp/application_impl.h" 29 #include "mojo/application/public/cpp/application_impl.h"
31 #include "mojo/application/public/cpp/connect.h" 30 #include "mojo/application/public/cpp/connect.h"
32 #include "mojo/application/public/interfaces/shell.mojom.h" 31 #include "mojo/application/public/interfaces/shell.mojom.h"
33 #include "mojo/converters/geometry/geometry_type_converters.h" 32 #include "mojo/converters/geometry/geometry_type_converters.h"
34 #include "skia/ext/refptr.h" 33 #include "skia/ext/refptr.h"
35 #include "third_party/WebKit/public/platform/Platform.h" 34 #include "third_party/WebKit/public/platform/Platform.h"
36 #include "third_party/WebKit/public/platform/WebHTTPHeaderVisitor.h" 35 #include "third_party/WebKit/public/platform/WebHTTPHeaderVisitor.h"
37 #include "third_party/WebKit/public/platform/WebSize.h" 36 #include "third_party/WebKit/public/platform/WebSize.h"
38 #include "third_party/WebKit/public/web/WebConsoleMessage.h" 37 #include "third_party/WebKit/public/web/WebConsoleMessage.h"
39 #include "third_party/WebKit/public/web/WebDocument.h" 38 #include "third_party/WebKit/public/web/WebDocument.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 if (web_view_) 198 if (web_view_)
200 web_view_->close(); 199 web_view_->close();
201 if (root_) 200 if (root_)
202 root_->RemoveObserver(this); 201 root_->RemoveObserver(this);
203 } 202 }
204 203
205 void HTMLDocument::OnEmbed(View* root) { 204 void HTMLDocument::OnEmbed(View* root) {
206 DCHECK(!global_state_->is_headless()); 205 DCHECK(!global_state_->is_headless());
207 root_ = root; 206 root_ = root;
208 root_->AddObserver(this); 207 root_->AddObserver(this);
208 root_->RequestCompositorFrameReceiver(
209 compositor_frame_receiver_request_.Pass());
209 UpdateFocus(); 210 UpdateFocus();
210 211
211 InitGlobalStateAndLoadIfNecessary(); 212 InitGlobalStateAndLoadIfNecessary();
212 } 213 }
213 214
214 void HTMLDocument::OnViewManagerDestroyed(ViewManager* view_manager) { 215 void HTMLDocument::OnViewManagerDestroyed(ViewManager* view_manager) {
215 delete this; 216 delete this;
216 } 217 }
217 218
218 void HTMLDocument::Create(mojo::ApplicationConnection* connection, 219 void HTMLDocument::Create(mojo::ApplicationConnection* connection,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 } 297 }
297 298
298 void HTMLDocument::initializeLayerTreeView() { 299 void HTMLDocument::initializeLayerTreeView() {
299 if (global_state_->is_headless()) { 300 if (global_state_->is_headless()) {
300 web_layer_tree_view_impl_.reset( 301 web_layer_tree_view_impl_.reset(
301 new WebLayerTreeViewImpl(global_state_->compositor_thread(), nullptr, 302 new WebLayerTreeViewImpl(global_state_->compositor_thread(), nullptr,
302 nullptr, nullptr, nullptr)); 303 nullptr, nullptr, nullptr));
303 return; 304 return;
304 } 305 }
305 306
306 mojo::URLRequestPtr request(mojo::URLRequest::New()); 307 mojo::CompositorFrameReceiverPtr receiver;
307 request->url = mojo::String::From("mojo:view_manager"); 308 compositor_frame_receiver_request_ = GetProxy(&receiver);
308 mojo::SurfacePtr surface;
309 html_document_app_->ConnectToService(request.Pass(), &surface);
310 309
311 // TODO(jamesr): Should be mojo:gpu_service 310 // TODO(jamesr): Should be mojo:gpu_service
312 mojo::URLRequestPtr request2(mojo::URLRequest::New()); 311 mojo::URLRequestPtr request2(mojo::URLRequest::New());
313 request2->url = mojo::String::From("mojo:view_manager"); 312 request2->url = mojo::String::From("mojo:view_manager");
314 mojo::GpuPtr gpu_service; 313 mojo::GpuPtr gpu_service;
315 html_document_app_->ConnectToService(request2.Pass(), &gpu_service); 314 html_document_app_->ConnectToService(request2.Pass(), &gpu_service);
316 web_layer_tree_view_impl_.reset(new WebLayerTreeViewImpl( 315 web_layer_tree_view_impl_.reset(new WebLayerTreeViewImpl(
317 global_state_->compositor_thread(), 316 global_state_->compositor_thread(),
318 global_state_->gpu_memory_buffer_manager(), 317 global_state_->gpu_memory_buffer_manager(),
319 global_state_->raster_thread_helper()->task_graph_runner(), 318 global_state_->raster_thread_helper()->task_graph_runner(),
320 surface.Pass(), gpu_service.Pass())); 319 receiver.Pass(), gpu_service.Pass()));
321 } 320 }
322 321
323 blink::WebLayerTreeView* HTMLDocument::layerTreeView() { 322 blink::WebLayerTreeView* HTMLDocument::layerTreeView() {
324 return web_layer_tree_view_impl_.get(); 323 return web_layer_tree_view_impl_.get();
325 } 324 }
326 325
327 blink::WebMediaPlayer* HTMLDocument::createMediaPlayer( 326 blink::WebMediaPlayer* HTMLDocument::createMediaPlayer(
328 blink::WebLocalFrame* frame, 327 blink::WebLocalFrame* frame,
329 const blink::WebURL& url, 328 const blink::WebURL& url,
330 blink::WebMediaPlayerClient* client, 329 blink::WebMediaPlayerClient* client,
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 489
491 void HTMLDocument::UpdateFocus() { 490 void HTMLDocument::UpdateFocus() {
492 if (!web_view_) 491 if (!web_view_)
493 return; 492 return;
494 bool is_focused = root_ && root_->HasFocus(); 493 bool is_focused = root_ && root_->HasFocus();
495 web_view_->setFocus(is_focused); 494 web_view_->setFocus(is_focused);
496 web_view_->setIsActive(is_focused); 495 web_view_->setIsActive(is_focused);
497 } 496 }
498 497
499 } // namespace html_viewer 498 } // namespace html_viewer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698