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

Side by Side Diff: mojo/services/view_manager/view_manager_init_service_impl.cc

Issue 400113005: A new WM bootstrap flow (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 5 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 | Annotate | Revision Log
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 "mojo/services/view_manager/view_manager_init_service_impl.h" 5 #include "mojo/services/view_manager/view_manager_init_service_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" 8 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h"
9 #include "mojo/services/view_manager/ids.h" 9 #include "mojo/services/view_manager/ids.h"
10 #include "mojo/services/view_manager/view_manager_init_service_context.h"
10 #include "mojo/services/view_manager/view_manager_service_impl.h" 11 #include "mojo/services/view_manager/view_manager_service_impl.h"
11 12
12 namespace mojo { 13 namespace mojo {
13 class ApplicationConnection; 14 class ApplicationConnection;
14 namespace view_manager { 15 namespace view_manager {
15 namespace service { 16 namespace service {
16 17
17 ViewManagerInitServiceImpl::ConnectParams::ConnectParams() {} 18 ViewManagerInitServiceImpl::ConnectParams::ConnectParams() {}
18 19
19 ViewManagerInitServiceImpl::ConnectParams::~ConnectParams() {} 20 ViewManagerInitServiceImpl::ConnectParams::~ConnectParams() {}
20 21
21 ViewManagerInitServiceImpl::ViewManagerInitServiceImpl( 22 ViewManagerInitServiceImpl::ViewManagerInitServiceImpl(
22 ApplicationConnection* connection) 23 ApplicationConnection* connection,
23 : root_node_manager_( 24 ViewManagerInitServiceContext* context)
24 connection, 25 : context_(context) {
25 this, 26 context_->AddConnection(this);
26 base::Bind(&ViewManagerInitServiceImpl::OnNativeViewportDeleted,
27 base::Unretained(this))),
28 is_tree_host_ready_(false) {
29 } 27 }
30 28
31 ViewManagerInitServiceImpl::~ViewManagerInitServiceImpl() { 29 ViewManagerInitServiceImpl::~ViewManagerInitServiceImpl() {
30 context_->RemoveConnection(this);
31 }
32
33 void ViewManagerInitServiceImpl::OnNativeViewportDeleted() {
34 // TODO(beng): Should not have to rely on implementation detail of
35 // InterfaceImpl to close the connection. Instead should simply
36 // be able to delete this object.
37 internal_state()->router()->CloseMessagePipe();
38 }
39
40 void ViewManagerInitServiceImpl::OnRootViewManagerWindowTreeHostCreated() {
41 MaybeEmbed();
32 } 42 }
33 43
34 void ViewManagerInitServiceImpl::MaybeEmbed() { 44 void ViewManagerInitServiceImpl::MaybeEmbed() {
35 if (!is_tree_host_ready_) 45 if (!context_->is_tree_host_ready())
36 return; 46 return;
37 47
38 ScopedVector<ConnectParams>::const_iterator it = connect_params_.begin(); 48 ScopedVector<ConnectParams>::const_iterator it = connect_params_.begin();
39 for (; it != connect_params_.end(); ++it) { 49 for (; it != connect_params_.end(); ++it) {
40 root_node_manager_.EmbedRoot((*it)->url); 50 context_->root_node_manager()->EmbedRoot((*it)->url);
41 (*it)->callback.Run(true); 51 (*it)->callback.Run(true);
42 } 52 }
43 connect_params_.clear(); 53 connect_params_.clear();
44 } 54 }
45 55
46 void ViewManagerInitServiceImpl::Embed( 56 void ViewManagerInitServiceImpl::Embed(
47 const String& url, 57 const String& url,
48 const Callback<void(bool)>& callback) { 58 const Callback<void(bool)>& callback) {
49 ConnectParams* params = new ConnectParams; 59 ConnectParams* params = new ConnectParams;
50 params->url = url.To<std::string>(); 60 params->url = url.To<std::string>();
51 params->callback = callback; 61 params->callback = callback;
52 connect_params_.push_back(params); 62 connect_params_.push_back(params);
53 MaybeEmbed(); 63 MaybeEmbed();
54 } 64 }
55 65
56 void ViewManagerInitServiceImpl::OnRootViewManagerWindowTreeHostCreated() {
57 DCHECK(!is_tree_host_ready_);
58 is_tree_host_ready_ = true;
59 MaybeEmbed();
60 }
61
62 void ViewManagerInitServiceImpl::OnNativeViewportDeleted() {
63 // TODO(beng): Should not have to rely on implementation detail of
64 // InterfaceImpl to close the connection. Instead should simply
65 // be able to delete this object.
66 internal_state()->router()->CloseMessagePipe();
67 }
68
69 } // namespace service 66 } // namespace service
70 } // namespace view_manager 67 } // namespace view_manager
71 } // namespace mojo 68 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/view_manager/view_manager_init_service_impl.h ('k') | mojo/services/window_manager/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698