| 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 "sky/viewer/document_view.h" | 5 #include "sky/viewer/document_view.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 | 68 |
| 69 } // namespace | 69 } // namespace |
| 70 | 70 |
| 71 static int s_next_debugger_id = 1; | 71 static int s_next_debugger_id = 1; |
| 72 | 72 |
| 73 DocumentView::DocumentView( | 73 DocumentView::DocumentView( |
| 74 mojo::ServiceProviderPtr provider, | 74 mojo::ServiceProviderPtr provider, |
| 75 mojo::URLResponsePtr response, | 75 mojo::URLResponsePtr response, |
| 76 mojo::Shell* shell) | 76 mojo::Shell* shell, |
| 77 bool is_testing) |
| 77 : response_(response.Pass()), | 78 : response_(response.Pass()), |
| 78 shell_(shell), | 79 shell_(shell), |
| 79 web_view_(NULL), | 80 web_view_(NULL), |
| 80 root_(NULL), | 81 root_(NULL), |
| 81 view_manager_client_factory_(shell_, this), | 82 view_manager_client_factory_(shell_, this), |
| 82 inspector_service_factory_(this), | 83 inspector_service_factory_(this), |
| 84 weak_factory_(this), |
| 83 debugger_id_(s_next_debugger_id++), | 85 debugger_id_(s_next_debugger_id++), |
| 84 weak_factory_(this) { | 86 is_testing_(is_testing) { |
| 85 exported_services_.AddService(&view_manager_client_factory_); | 87 exported_services_.AddService(&view_manager_client_factory_); |
| 86 mojo::WeakBindToPipe(&exported_services_, provider.PassMessagePipe()); | 88 mojo::WeakBindToPipe(&exported_services_, provider.PassMessagePipe()); |
| 87 } | 89 } |
| 88 | 90 |
| 89 DocumentView::~DocumentView() { | 91 DocumentView::~DocumentView() { |
| 90 if (web_view_) | 92 if (web_view_) |
| 91 web_view_->close(); | 93 web_view_->close(); |
| 92 if (root_) | 94 if (root_) |
| 93 root_->RemoveObserver(this); | 95 root_->RemoveObserver(this); |
| 94 } | 96 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 124 | 126 |
| 125 void DocumentView::Load(mojo::URLResponsePtr response) { | 127 void DocumentView::Load(mojo::URLResponsePtr response) { |
| 126 web_view_ = blink::WebView::create(this); | 128 web_view_ = blink::WebView::create(this); |
| 127 ConfigureSettings(web_view_->settings()); | 129 ConfigureSettings(web_view_->settings()); |
| 128 web_view_->setMainFrame(blink::WebLocalFrame::create(this)); | 130 web_view_->setMainFrame(blink::WebLocalFrame::create(this)); |
| 129 web_view_->mainFrame()->load(GURL(response->url), response->body.Pass()); | 131 web_view_->mainFrame()->load(GURL(response->url), response->body.Pass()); |
| 130 } | 132 } |
| 131 | 133 |
| 132 void DocumentView::initializeLayerTreeView() { | 134 void DocumentView::initializeLayerTreeView() { |
| 133 layer_host_.reset(new LayerHost(this)); | 135 layer_host_.reset(new LayerHost(this)); |
| 134 root_layer_ = make_scoped_refptr(new Layer(this)); | 136 root_layer_ = make_scoped_refptr(new Layer(this, is_testing_)); |
| 135 layer_host_->SetRootLayer(root_layer_); | 137 layer_host_->SetRootLayer(root_layer_); |
| 136 } | 138 } |
| 137 | 139 |
| 140 std::string DocumentView::GetPixels() { |
| 141 return layer_host_->GetPixels(); |
| 142 } |
| 143 |
| 138 mojo::Shell* DocumentView::GetShell() { | 144 mojo::Shell* DocumentView::GetShell() { |
| 139 return shell_; | 145 return shell_; |
| 140 } | 146 } |
| 141 | 147 |
| 142 void DocumentView::BeginFrame(base::TimeTicks frame_time) { | 148 void DocumentView::BeginFrame(base::TimeTicks frame_time) { |
| 143 double frame_time_sec = (frame_time - base::TimeTicks()).InSecondsF(); | 149 double frame_time_sec = (frame_time - base::TimeTicks()).InSecondsF(); |
| 144 double deadline_sec = frame_time_sec; | 150 double deadline_sec = frame_time_sec; |
| 145 double interval_sec = 1.0/60; | 151 double interval_sec = 1.0/60; |
| 146 blink::WebBeginFrameArgs web_begin_frame_args( | 152 blink::WebBeginFrameArgs web_begin_frame_args( |
| 147 frame_time_sec, deadline_sec, interval_sec); | 153 frame_time_sec, deadline_sec, interval_sec); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 void DocumentView::StartDebuggerInspectorBackend() { | 279 void DocumentView::StartDebuggerInspectorBackend() { |
| 274 if (!inspector_backend_) { | 280 if (!inspector_backend_) { |
| 275 inspector_host_.reset(new InspectorHostImpl(web_view_, shell_)); | 281 inspector_host_.reset(new InspectorHostImpl(web_view_, shell_)); |
| 276 inspector_backend_.reset( | 282 inspector_backend_.reset( |
| 277 new inspector::InspectorBackendMojo(inspector_host_.get())); | 283 new inspector::InspectorBackendMojo(inspector_host_.get())); |
| 278 } | 284 } |
| 279 inspector_backend_->Connect(); | 285 inspector_backend_->Connect(); |
| 280 } | 286 } |
| 281 | 287 |
| 282 } // namespace sky | 288 } // namespace sky |
| OLD | NEW |