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

Side by Side Diff: sky/viewer/document_view.cc

Issue 958673002: Added ServiceRegistry interface (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « sky/viewer/document_view.h ('k') | sky/viewer/internals.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 } // namespace 97 } // namespace
98 98
99 DocumentView::DocumentView( 99 DocumentView::DocumentView(
100 mojo::InterfaceRequest<mojo::ServiceProvider> services, 100 mojo::InterfaceRequest<mojo::ServiceProvider> services,
101 mojo::ServiceProviderPtr exported_services, 101 mojo::ServiceProviderPtr exported_services,
102 mojo::URLResponsePtr response, 102 mojo::URLResponsePtr response,
103 mojo::Shell* shell) 103 mojo::Shell* shell)
104 : response_(response.Pass()), 104 : response_(response.Pass()),
105 exported_services_(services.Pass()), 105 exported_services_(services.Pass()),
106 imported_services_(exported_services.Pass()),
106 shell_(shell), 107 shell_(shell),
107 web_view_(nullptr), 108 web_view_(nullptr),
108 root_(nullptr), 109 root_(nullptr),
109 view_manager_client_factory_(shell_, this), 110 view_manager_client_factory_(shell_, this),
110 bitmap_rasterizer_(nullptr), 111 bitmap_rasterizer_(nullptr),
111 weak_factory_(this) { 112 weak_factory_(this) {
112 exported_services_.AddService(&view_manager_client_factory_); 113 exported_services_.AddService(&view_manager_client_factory_);
114 InitServiceRegistry();
113 } 115 }
114 116
115 DocumentView::~DocumentView() { 117 DocumentView::~DocumentView() {
116 if (web_view_) 118 if (web_view_)
117 web_view_->close(); 119 web_view_->close();
118 if (root_) 120 if (root_)
119 root_->RemoveObserver(this); 121 root_->RemoveObserver(this);
120 ui::GestureRecognizer::Get()->CleanupStateForConsumer(this); 122 ui::GestureRecognizer::Get()->CleanupStateForConsumer(this);
121 } 123 }
122 124
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 } 189 }
188 190
189 mojo::ScopedMessagePipeHandle DocumentView::TakeServicesProvidedToEmbedder() { 191 mojo::ScopedMessagePipeHandle DocumentView::TakeServicesProvidedToEmbedder() {
190 return services_provided_to_embedder_.PassMessagePipe(); 192 return services_provided_to_embedder_.PassMessagePipe();
191 } 193 }
192 194
193 mojo::ScopedMessagePipeHandle DocumentView::TakeServicesProvidedByEmbedder() { 195 mojo::ScopedMessagePipeHandle DocumentView::TakeServicesProvidedByEmbedder() {
194 return services_provided_by_embedder_.PassMessagePipe(); 196 return services_provided_by_embedder_.PassMessagePipe();
195 } 197 }
196 198
199 mojo::ScopedMessagePipeHandle DocumentView::TakeServiceRegistry() {
200 return service_registry_.PassMessagePipe();
201 }
202
197 mojo::Shell* DocumentView::GetShell() { 203 mojo::Shell* DocumentView::GetShell() {
198 return shell_; 204 return shell_;
199 } 205 }
200 206
201 void DocumentView::BeginFrame(base::TimeTicks frame_time) { 207 void DocumentView::BeginFrame(base::TimeTicks frame_time) {
202 double frame_time_sec = (frame_time - base::TimeTicks()).InSecondsF(); 208 double frame_time_sec = (frame_time - base::TimeTicks()).InSecondsF();
203 double deadline_sec = frame_time_sec; 209 double deadline_sec = frame_time_sec;
204 double interval_sec = 1.0/60; 210 double interval_sec = 1.0/60;
205 blink::WebBeginFrameArgs web_begin_frame_args( 211 blink::WebBeginFrameArgs web_begin_frame_args(
206 frame_time_sec, deadline_sec, interval_sec); 212 frame_time_sec, deadline_sec, interval_sec);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 web_view_->handleInputEvent(*gesture_event); 359 web_view_->handleInputEvent(*gesture_event);
354 } 360 }
355 } 361 }
356 } 362 }
357 } 363 }
358 364
359 void DocumentView::StartDebuggerInspectorBackend() { 365 void DocumentView::StartDebuggerInspectorBackend() {
360 // FIXME: Do we need this for dart? 366 // FIXME: Do we need this for dart?
361 } 367 }
362 368
369 void DocumentView::InitServiceRegistry() {
370 mojo::ConnectToService(imported_services_.get(), &service_registry_);
371 mojo::Array<mojo::String> interface_names(1);
372 interface_names[0] = "ViewManagerClient";
373 mojo::ServiceProviderImpl* sp_impl(new mojo::ServiceProviderImpl());
374 sp_impl->AddService(&view_manager_client_factory_);
375 mojo::ServiceProviderPtr sp;
376 service_registry_service_provider_binding_.reset(
377 new mojo::StrongBinding<mojo::ServiceProvider>(sp_impl, &sp));
378 service_registry_->AddServices(interface_names.Pass(), sp.Pass());
379 }
380
363 } // namespace sky 381 } // namespace sky
OLDNEW
« no previous file with comments | « sky/viewer/document_view.h ('k') | sky/viewer/internals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698