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 "mojo/services/view_manager/view_manager_init_service_context.h" | 5 #include "mojo/services/view_manager/view_manager_init_service_context.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "mojo/services/view_manager/root_node_manager.h" | 9 #include "mojo/services/view_manager/connection_manager.h" |
10 #include "mojo/services/view_manager/view_manager_init_service_impl.h" | 10 #include "mojo/services/view_manager/view_manager_init_service_impl.h" |
11 | 11 |
12 namespace mojo { | 12 namespace mojo { |
13 namespace service { | 13 namespace service { |
14 | 14 |
15 ViewManagerInitServiceContext::ConnectParams::ConnectParams() {} | 15 ViewManagerInitServiceContext::ConnectParams::ConnectParams() {} |
16 | 16 |
17 ViewManagerInitServiceContext::ConnectParams::~ConnectParams() {} | 17 ViewManagerInitServiceContext::ConnectParams::~ConnectParams() {} |
18 | 18 |
19 ViewManagerInitServiceContext::ViewManagerInitServiceContext() | 19 ViewManagerInitServiceContext::ViewManagerInitServiceContext() |
(...skipping 11 matching lines...) Expand all Loading... |
31 void ViewManagerInitServiceContext::RemoveConnection( | 31 void ViewManagerInitServiceContext::RemoveConnection( |
32 ViewManagerInitServiceImpl* connection) { | 32 ViewManagerInitServiceImpl* connection) { |
33 if (!deleting_connection_) { | 33 if (!deleting_connection_) { |
34 Connections::iterator it = | 34 Connections::iterator it = |
35 std::find(connections_.begin(), connections_.end(), connection); | 35 std::find(connections_.begin(), connections_.end(), connection); |
36 DCHECK(it != connections_.end()); | 36 DCHECK(it != connections_.end()); |
37 connections_.erase(it); | 37 connections_.erase(it); |
38 } | 38 } |
39 | 39 |
40 // This object is owned by an object that outlives the current thread's | 40 // This object is owned by an object that outlives the current thread's |
41 // message loop, so we need to destroy the RootNodeManager earlier, as it may | 41 // message loop, so we need to destroy the ConnectionManager earlier, as it |
42 // attempt to post tasks during its destruction. | 42 // may attempt to post tasks during its destruction. |
43 if (connections_.empty()) | 43 if (connections_.empty()) |
44 root_node_manager_.reset(); | 44 connection_manager_.reset(); |
45 } | 45 } |
46 | 46 |
47 void ViewManagerInitServiceContext::ConfigureIncomingConnection( | 47 void ViewManagerInitServiceContext::ConfigureIncomingConnection( |
48 ApplicationConnection* connection) { | 48 ApplicationConnection* connection) { |
49 if (!root_node_manager_.get()) { | 49 if (!connection_manager_.get()) { |
50 root_node_manager_.reset(new RootNodeManager( | 50 connection_manager_.reset(new ConnectionManager( |
51 connection, | 51 connection, |
52 this, | 52 this, |
53 base::Bind(&ViewManagerInitServiceContext::OnNativeViewportDeleted, | 53 base::Bind(&ViewManagerInitServiceContext::OnNativeViewportDeleted, |
54 base::Unretained(this)))); | 54 base::Unretained(this)))); |
55 } | 55 } |
56 } | 56 } |
57 | 57 |
58 void ViewManagerInitServiceContext::Embed( | 58 void ViewManagerInitServiceContext::Embed( |
59 const String& url, | 59 const String& url, |
60 ServiceProviderPtr service_provider, | 60 ServiceProviderPtr service_provider, |
(...skipping 14 matching lines...) Expand all Loading... |
75 | 75 |
76 void ViewManagerInitServiceContext::OnNativeViewportDeleted() { | 76 void ViewManagerInitServiceContext::OnNativeViewportDeleted() { |
77 // Prevent the connection from modifying the connection list during manual | 77 // Prevent the connection from modifying the connection list during manual |
78 // teardown. | 78 // teardown. |
79 base::AutoReset<bool> deleting_connection(&deleting_connection_, true); | 79 base::AutoReset<bool> deleting_connection(&deleting_connection_, true); |
80 for (Connections::const_iterator it = connections_.begin(); | 80 for (Connections::const_iterator it = connections_.begin(); |
81 it != connections_.end(); ++it) { | 81 it != connections_.end(); ++it) { |
82 delete *it; | 82 delete *it; |
83 } | 83 } |
84 connections_.clear(); | 84 connections_.clear(); |
85 root_node_manager_.reset(); | 85 connection_manager_.reset(); |
86 } | 86 } |
87 | 87 |
88 void ViewManagerInitServiceContext::MaybeEmbed() { | 88 void ViewManagerInitServiceContext::MaybeEmbed() { |
89 if (!is_tree_host_ready_) | 89 if (!is_tree_host_ready_) |
90 return; | 90 return; |
91 | 91 |
92 for (ScopedVector<ConnectParams>::const_iterator it = connect_params_.begin(); | 92 for (ScopedVector<ConnectParams>::const_iterator it = connect_params_.begin(); |
93 it != connect_params_.end(); ++it) { | 93 it != connect_params_.end(); ++it) { |
94 root_node_manager_->EmbedRoot((*it)->url, (*it)->service_provider.Pass()); | 94 connection_manager_->EmbedRoot((*it)->url, (*it)->service_provider.Pass()); |
95 (*it)->callback.Run(true); | 95 (*it)->callback.Run(true); |
96 } | 96 } |
97 connect_params_.clear(); | 97 connect_params_.clear(); |
98 } | 98 } |
99 | 99 |
100 } // namespace service | 100 } // namespace service |
101 } // namespace mojo | 101 } // namespace mojo |
OLD | NEW |