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/public/shell/application.h" | 5 #include "mojo/public/shell/application.h" |
6 | 6 |
7 namespace mojo { | 7 namespace mojo { |
8 | 8 |
9 Application::Application(ScopedShellHandle shell_handle) | 9 Application::Application(ScopedShellHandle shell_handle) |
10 : shell_(shell_handle.Pass(), this) { | 10 : internal::ServiceFactoryBase::Owner(shell_handle.Pass()) { |
11 } | 11 } |
12 | 12 |
13 Application::Application(MojoHandle shell_handle) | 13 Application::Application(MojoHandle shell_handle) |
14 : shell_(mojo::MakeScopedHandle(ShellHandle(shell_handle)).Pass()) {} | 14 : internal::ServiceFactoryBase::Owner( |
| 15 mojo::MakeScopedHandle(ShellHandle(shell_handle)).Pass()) {} |
15 | 16 |
16 Application::~Application() { | 17 Application::~Application() { |
17 for (ServiceFactoryList::iterator it = service_factories_.begin(); | 18 for (ServiceFactoryList::iterator it = service_factories_.begin(); |
18 it != service_factories_.end(); ++it) { | 19 it != service_factories_.end(); ++it) { |
19 delete *it; | 20 delete *it; |
20 } | 21 } |
21 } | 22 } |
22 | 23 |
23 Shell* Application::GetShell() { | |
24 return shell_.get(); | |
25 } | |
26 | |
27 void Application::AddServiceFactory( | 24 void Application::AddServiceFactory( |
28 internal::ServiceFactoryBase* service_factory) { | 25 internal::ServiceFactoryBase* service_factory) { |
29 service_factories_.push_back(service_factory); | 26 service_factories_.push_back(service_factory); |
30 set_service_factory_owner(service_factory, this); | 27 set_service_factory_owner(service_factory, this); |
31 } | 28 } |
32 | 29 |
33 void Application::RemoveServiceFactory( | 30 void Application::RemoveServiceFactory( |
34 internal::ServiceFactoryBase* service_factory) { | 31 internal::ServiceFactoryBase* service_factory) { |
35 for (ServiceFactoryList::iterator it = service_factories_.begin(); | 32 for (ServiceFactoryList::iterator it = service_factories_.begin(); |
36 it != service_factories_.end(); ++it) { | 33 it != service_factories_.end(); ++it) { |
(...skipping 11 matching lines...) Expand all Loading... |
48 ScopedMessagePipeHandle client_handle) { | 45 ScopedMessagePipeHandle client_handle) { |
49 // TODO(davemoore): This method must be overridden by an Application subclass | 46 // TODO(davemoore): This method must be overridden by an Application subclass |
50 // to dispatch to the right ServiceFactory. We need to figure out an approach | 47 // to dispatch to the right ServiceFactory. We need to figure out an approach |
51 // to registration to make this better. | 48 // to registration to make this better. |
52 assert(1 == service_factories_.size()); | 49 assert(1 == service_factories_.size()); |
53 return service_factories_.front()->AcceptConnection(url.To<std::string>(), | 50 return service_factories_.front()->AcceptConnection(url.To<std::string>(), |
54 client_handle.Pass()); | 51 client_handle.Pass()); |
55 } | 52 } |
56 | 53 |
57 } // namespace mojo | 54 } // namespace mojo |
OLD | NEW |