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

Side by Side Diff: mojo/public/cpp/application/lib/service_provider_impl.cc

Issue 466273002: Remove OpenWindow from the WindowManager interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 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
« no previous file with comments | « no previous file | mojo/public/cpp/application/lib/weak_service_provider.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 "mojo/public/cpp/application/service_provider_impl.h" 5 #include "mojo/public/cpp/application/service_provider_impl.h"
6 6
7 #include "mojo/public/cpp/application/lib/service_connector.h" 7 #include "mojo/public/cpp/application/lib/service_connector.h"
8 #include "mojo/public/cpp/application/lib/weak_service_provider.h" 8 #include "mojo/public/cpp/application/lib/weak_service_provider.h"
9 #include "mojo/public/cpp/environment/logging.h" 9 #include "mojo/public/cpp/environment/logging.h"
10 10
11 namespace mojo { 11 namespace mojo {
12 12
13 ServiceProviderImpl::ServiceProviderImpl() : remote_(NULL) { 13 ServiceProviderImpl::ServiceProviderImpl() : remote_(NULL) {
14 } 14 }
15 15
16 ServiceProviderImpl::~ServiceProviderImpl() { 16 ServiceProviderImpl::~ServiceProviderImpl() {
17 } 17 }
18 18
19 ServiceProvider* ServiceProviderImpl::CreateRemoteServiceProvider() { 19 ServiceProvider* ServiceProviderImpl::CreateRemoteServiceProvider() {
20 // TODO(beng): it sure would be nice if this method could return a scoped_ptr. 20 // TODO(beng): it sure would be nice if this method could return a scoped_ptr.
21 MOJO_DCHECK(!remote_); 21 MOJO_DCHECK(!remote_);
22 remote_ = new internal::WeakServiceProvider(client()); 22 remote_ = new internal::WeakServiceProvider(this, client());
23 return remote_; 23 return remote_;
24 } 24 }
25 25
26 void ServiceProviderImpl::ConnectToService( 26 void ServiceProviderImpl::ConnectToService(
27 const String& service_name, 27 const String& service_name,
28 ScopedMessagePipeHandle client_handle) { 28 ScopedMessagePipeHandle client_handle) {
29 if (service_connectors_.find(service_name) == service_connectors_.end()) { 29 if (service_connectors_.find(service_name) == service_connectors_.end()) {
30 client_handle.reset(); 30 client_handle.reset();
31 return; 31 return;
32 } 32 }
33 33
34 internal::ServiceConnectorBase* service_connector = 34 internal::ServiceConnectorBase* service_connector =
35 service_connectors_[service_name]; 35 service_connectors_[service_name];
36 return service_connector->ConnectToService(service_name, 36 return service_connector->ConnectToService(service_name,
37 client_handle.Pass()); 37 client_handle.Pass());
38 } 38 }
39 39
40 void ServiceProviderImpl::OnConnectionError() { 40 void ServiceProviderImpl::OnConnectionError() {
41 if (remote_) { 41 ClearRemote();
42 remote_->Clear();
43 remote_ = NULL;
44 }
45 } 42 }
46 43
47 void ServiceProviderImpl::AddServiceConnector( 44 void ServiceProviderImpl::AddServiceConnector(
48 internal::ServiceConnectorBase* service_connector) { 45 internal::ServiceConnectorBase* service_connector) {
49 RemoveServiceConnector(service_connector); 46 RemoveServiceConnector(service_connector);
50 service_connectors_[service_connector->name()] = service_connector; 47 service_connectors_[service_connector->name()] = service_connector;
51 // TODO(beng): perhaps take app connection thru ctor?? 48 // TODO(beng): perhaps take app connection thru ctor??
52 service_connector->set_application_connection(NULL); 49 service_connector->set_application_connection(NULL);
53 } 50 }
54 51
55 void ServiceProviderImpl::RemoveServiceConnector( 52 void ServiceProviderImpl::RemoveServiceConnector(
56 internal::ServiceConnectorBase* service_connector) { 53 internal::ServiceConnectorBase* service_connector) {
57 NameToServiceConnectorMap::iterator it = 54 NameToServiceConnectorMap::iterator it =
58 service_connectors_.find(service_connector->name()); 55 service_connectors_.find(service_connector->name());
59 if (it == service_connectors_.end()) 56 if (it == service_connectors_.end())
60 return; 57 return;
61 delete it->second; 58 delete it->second;
62 service_connectors_.erase(it); 59 service_connectors_.erase(it);
63 } 60 }
64 61
62 void ServiceProviderImpl::ClearRemote() {
63 if (remote_) {
64 remote_->Clear();
65 remote_ = NULL;
66 }
67 }
68
65 } // namespace mojo 69 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | mojo/public/cpp/application/lib/weak_service_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698