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

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

Issue 405163002: Add EmbedRoot to ViewManagerService. (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_service_impl.h" 10 #include "mojo/services/view_manager/view_manager_service_impl.h"
(...skipping 13 matching lines...) Expand all
24 connection, 24 connection,
25 this, 25 this,
26 base::Bind(&ViewManagerInitServiceImpl::OnNativeViewportDeleted, 26 base::Bind(&ViewManagerInitServiceImpl::OnNativeViewportDeleted,
27 base::Unretained(this))), 27 base::Unretained(this))),
28 is_tree_host_ready_(false) { 28 is_tree_host_ready_(false) {
29 } 29 }
30 30
31 ViewManagerInitServiceImpl::~ViewManagerInitServiceImpl() { 31 ViewManagerInitServiceImpl::~ViewManagerInitServiceImpl() {
32 } 32 }
33 33
34 void ViewManagerInitServiceImpl::MaybeEmbedRoot( 34 void ViewManagerInitServiceImpl::MaybeEmbed() {
35 const std::string& url,
36 const Callback<void(bool)>& callback) {
37 if (!is_tree_host_ready_) 35 if (!is_tree_host_ready_)
38 return; 36 return;
39 37
40 root_node_manager_.EmbedRoot(url); 38 ScopedVector<ConnectParams>::const_iterator it = connect_params_.begin();
41 callback.Run(true); 39 for (; it != connect_params_.end(); ++it) {
40 root_node_manager_.EmbedRoot((*it)->url);
41 (*it)->callback.Run(true);
42 }
43 connect_params_.clear();
42 } 44 }
43 45
44 void ViewManagerInitServiceImpl::EmbedRoot( 46 void ViewManagerInitServiceImpl::Embed(
45 const String& url, 47 const String& url,
46 const Callback<void(bool)>& callback) { 48 const Callback<void(bool)>& callback) {
47 // TODO(beng): This means you can only have one EmbedRoot in flight at a time. 49 ConnectParams* params = new ConnectParams;
48 // Keep a vector of these around instead. 50 params->url = url.To<std::string>();
49 connect_params_.reset(new ConnectParams); 51 params->callback = callback;
50 connect_params_->url = url.To<std::string>(); 52 connect_params_.push_back(params);
51 connect_params_->callback = callback; 53 MaybeEmbed();
52 MaybeEmbedRoot(url.To<std::string>(), callback);
53 } 54 }
54 55
55 void ViewManagerInitServiceImpl::OnRootViewManagerWindowTreeHostCreated() { 56 void ViewManagerInitServiceImpl::OnRootViewManagerWindowTreeHostCreated() {
56 DCHECK(!is_tree_host_ready_); 57 DCHECK(!is_tree_host_ready_);
57 is_tree_host_ready_ = true; 58 is_tree_host_ready_ = true;
58 if (connect_params_) 59 MaybeEmbed();
59 MaybeEmbedRoot(connect_params_->url, connect_params_->callback);
60 } 60 }
61 61
62 void ViewManagerInitServiceImpl::OnNativeViewportDeleted() { 62 void ViewManagerInitServiceImpl::OnNativeViewportDeleted() {
63 // TODO(beng): Should not have to rely on implementation detail of 63 // TODO(beng): Should not have to rely on implementation detail of
64 // InterfaceImpl to close the connection. Instead should simply 64 // InterfaceImpl to close the connection. Instead should simply
65 // be able to delete this object. 65 // be able to delete this object.
66 internal_state()->router()->CloseMessagePipe(); 66 internal_state()->router()->CloseMessagePipe();
67 } 67 }
68 68
69 } // namespace service 69 } // namespace service
70 } // namespace view_manager 70 } // namespace view_manager
71 } // namespace mojo 71 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/view_manager/view_manager_init_service_impl.h ('k') | mojo/services/view_manager/view_manager_service_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698