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

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

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

Powered by Google App Engine
This is Rietveld 408576698