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

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

Issue 534843002: Convert view manager to surfaces with uploading shim in client lib (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove overzealous shutdown check in cc/surfaces, add NON_EXPORTED_BASE for windows build, saturate… Created 6 years, 3 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
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_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/connection_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()
20 : is_tree_host_ready_(false), 20 : deleting_connection_(false) {
21 deleting_connection_(false) {} 21 }
22 ViewManagerInitServiceContext::~ViewManagerInitServiceContext() {} 22 ViewManagerInitServiceContext::~ViewManagerInitServiceContext() {}
23 23
24 void ViewManagerInitServiceContext::AddConnection( 24 void ViewManagerInitServiceContext::AddConnection(
25 ViewManagerInitServiceImpl* connection) { 25 ViewManagerInitServiceImpl* connection) {
26 DCHECK(std::find(connections_.begin(), connections_.end(), connection) == 26 DCHECK(std::find(connections_.begin(), connections_.end(), connection) ==
27 connections_.end()); 27 connections_.end());
28 connections_.push_back(connection); 28 connections_.push_back(connection);
29 } 29 }
30 30
31 void ViewManagerInitServiceContext::RemoveConnection( 31 void ViewManagerInitServiceContext::RemoveConnection(
(...skipping 10 matching lines...) Expand all
42 // may 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 connection_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 (!connection_manager_.get()) { 49 if (!connection_manager_.get()) {
50 connection_manager_.reset(new ConnectionManager( 50 connection_manager_.reset(new ConnectionManager(
51 connection, 51 connection,
52 this,
53 base::Bind(&ViewManagerInitServiceContext::OnNativeViewportDeleted, 52 base::Bind(&ViewManagerInitServiceContext::OnNativeViewportDeleted,
54 base::Unretained(this)))); 53 base::Unretained(this))));
55 } 54 }
56 } 55 }
57 56
58 void ViewManagerInitServiceContext::Embed( 57 void ViewManagerInitServiceContext::Embed(
59 const String& url, 58 const String& url,
60 ServiceProviderPtr service_provider, 59 ServiceProviderPtr service_provider,
61 const Callback<void(bool)>& callback) { 60 const Callback<void(bool)>& callback) {
62 ConnectParams* params = new ConnectParams; 61 connection_manager_->EmbedRoot(url, Get(&service_provider));
63 params->url = url.To<std::string>(); 62 callback.Run(true);
64 params->callback = callback;
65 params->service_provider.Bind(service_provider.PassMessagePipe());
66 connect_params_.push_back(params);
67 MaybeEmbed();
68 }
69
70 void ViewManagerInitServiceContext::OnDisplayManagerWindowTreeHostCreated() {
71 DCHECK(!is_tree_host_ready_);
72 is_tree_host_ready_ = true;
73 MaybeEmbed();
74 } 63 }
75 64
76 void ViewManagerInitServiceContext::OnNativeViewportDeleted() { 65 void ViewManagerInitServiceContext::OnNativeViewportDeleted() {
77 // Prevent the connection from modifying the connection list during manual 66 // Prevent the connection from modifying the connection list during manual
78 // teardown. 67 // teardown.
79 base::AutoReset<bool> deleting_connection(&deleting_connection_, true); 68 base::AutoReset<bool> deleting_connection(&deleting_connection_, true);
80 for (Connections::const_iterator it = connections_.begin(); 69 for (Connections::const_iterator it = connections_.begin();
81 it != connections_.end(); ++it) { 70 it != connections_.end(); ++it) {
82 delete *it; 71 delete *it;
83 } 72 }
84 connections_.clear(); 73 connections_.clear();
85 connection_manager_.reset(); 74 connection_manager_.reset();
86 } 75 }
87 76
88 void ViewManagerInitServiceContext::MaybeEmbed() {
89 if (!is_tree_host_ready_)
90 return;
91
92 for (ScopedVector<ConnectParams>::const_iterator it = connect_params_.begin();
93 it != connect_params_.end(); ++it) {
94 connection_manager_->EmbedRoot((*it)->url, (*it)->service_provider.Pass());
95 (*it)->callback.Run(true);
96 }
97 connect_params_.clear();
98 }
99
100 } // namespace service 77 } // namespace service
101 } // namespace mojo 78 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/view_manager/view_manager_init_service_context.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