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

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

Issue 298003008: Shell / ShellClient -> ServiceProvider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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/public/cpp/shell/application.h" 5 #include "mojo/public/cpp/application/application.h"
6 6
7 namespace mojo { 7 namespace mojo {
8 8
9 Application::Application(ScopedMessagePipeHandle shell_handle) 9 Application::Application(ScopedMessagePipeHandle service_provider_handle)
10 : internal::ServiceConnectorBase::Owner(shell_handle.Pass()) { 10 : internal::ServiceConnectorBase::Owner(service_provider_handle.Pass()) {
11 } 11 }
12 12
13 Application::Application(MojoHandle shell_handle) 13 Application::Application(MojoHandle service_provider_handle)
14 : internal::ServiceConnectorBase::Owner( 14 : internal::ServiceConnectorBase::Owner(
15 mojo::MakeScopedHandle(MessagePipeHandle(shell_handle)).Pass()) {} 15 mojo::MakeScopedHandle(
16 MessagePipeHandle(service_provider_handle)).Pass()) {}
16 17
17 Application::~Application() { 18 Application::~Application() {
18 for (ServiceConnectorList::iterator it = service_connectors_.begin(); 19 for (ServiceConnectorList::iterator it = service_connectors_.begin();
19 it != service_connectors_.end(); ++it) { 20 it != service_connectors_.end(); ++it) {
20 delete *it; 21 delete *it;
21 } 22 }
22 } 23 }
23 24
24 void Application::AddServiceConnector( 25 void Application::AddServiceConnector(
25 internal::ServiceConnectorBase* service_connector) { 26 internal::ServiceConnectorBase* service_connector) {
26 service_connectors_.push_back(service_connector); 27 service_connectors_.push_back(service_connector);
27 set_service_connector_owner(service_connector, this); 28 set_service_connector_owner(service_connector, this);
28 } 29 }
29 30
30 void Application::RemoveServiceConnector( 31 void Application::RemoveServiceConnector(
31 internal::ServiceConnectorBase* service_connector) { 32 internal::ServiceConnectorBase* service_connector) {
32 for (ServiceConnectorList::iterator it = service_connectors_.begin(); 33 for (ServiceConnectorList::iterator it = service_connectors_.begin();
33 it != service_connectors_.end(); ++it) { 34 it != service_connectors_.end(); ++it) {
34 if (*it == service_connector) { 35 if (*it == service_connector) {
35 service_connectors_.erase(it); 36 service_connectors_.erase(it);
36 delete service_connector; 37 delete service_connector;
37 break; 38 break;
38 } 39 }
39 } 40 }
40 if (service_connectors_.empty()) 41 if (service_connectors_.empty())
41 shell_.reset(); 42 service_provider_.reset();
42 } 43 }
43 44
44 void Application::AcceptConnection(const mojo::String& url, 45 void Application::ConnectToService(const mojo::String& url,
45 ScopedMessagePipeHandle client_handle) { 46 ScopedMessagePipeHandle client_handle) {
46 // TODO(davemoore): This method must be overridden by an Application subclass 47 // TODO(davemoore): This method must be overridden by an Application subclass
47 // to dispatch to the right ServiceConnector. We need to figure out an 48 // to dispatch to the right ServiceConnector. We need to figure out an
48 // approach to registration to make this better. 49 // approach to registration to make this better.
49 assert(1 == service_connectors_.size()); 50 assert(1 == service_connectors_.size());
50 return service_connectors_.front()->AcceptConnection(url.To<std::string>(), 51 return service_connectors_.front()->ConnectToService(url.To<std::string>(),
51 client_handle.Pass()); 52 client_handle.Pass());
52 } 53 }
53 54
54 } // namespace mojo 55 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/application/connect.h ('k') | mojo/public/cpp/application/lib/service_connector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698