Chromium Code Reviews| 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/application/public/cpp/application_impl.h" | 5 #include "mojo/application/public/cpp/application_impl.h" |
| 6 | 6 |
| 7 #include "mojo/application/public/cpp/application_delegate.h" | 7 #include "mojo/application/public/cpp/application_delegate.h" |
| 8 #include "mojo/application/public/cpp/lib/service_registry.h" | 8 #include "mojo/application/public/cpp/lib/service_registry.h" |
| 9 #include "mojo/public/cpp/bindings/interface_ptr.h" | 9 #include "mojo/public/cpp/bindings/interface_ptr.h" |
| 10 #include "mojo/public/cpp/environment/logging.h" | 10 #include "mojo/public/cpp/environment/logging.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 MOJO_DISALLOW_COPY_AND_ASSIGN(ShellPtrWatcher); | 24 MOJO_DISALLOW_COPY_AND_ASSIGN(ShellPtrWatcher); |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate, | 27 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate, |
| 28 InterfaceRequest<Application> request) | 28 InterfaceRequest<Application> request) |
| 29 : delegate_(delegate), | 29 : delegate_(delegate), |
| 30 binding_(this, request.Pass()), | 30 binding_(this, request.Pass()), |
| 31 shell_watch_(nullptr) { | 31 shell_watch_(nullptr) { |
| 32 } | 32 } |
| 33 | 33 |
| 34 bool ApplicationImpl::HasArg(const std::string& arg) const { | |
| 35 return std::find(args_.begin(), args_.end(), arg) != args_.end(); | |
| 36 } | |
| 37 | |
| 38 void ApplicationImpl::ClearConnections() { | 34 void ApplicationImpl::ClearConnections() { |
| 39 for (ServiceRegistryList::iterator i(incoming_service_registries_.begin()); | 35 for (ServiceRegistryList::iterator i(incoming_service_registries_.begin()); |
| 40 i != incoming_service_registries_.end(); | 36 i != incoming_service_registries_.end(); |
| 41 ++i) | 37 ++i) |
| 42 delete *i; | 38 delete *i; |
| 43 for (ServiceRegistryList::iterator i(outgoing_service_registries_.begin()); | 39 for (ServiceRegistryList::iterator i(outgoing_service_registries_.begin()); |
| 44 i != outgoing_service_registries_.end(); | 40 i != outgoing_service_registries_.end(); |
| 45 ++i) | 41 ++i) |
| 46 delete *i; | 42 delete *i; |
| 47 incoming_service_registries_.clear(); | 43 incoming_service_registries_.clear(); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 66 local_request.Pass()); | 62 local_request.Pass()); |
| 67 if (!delegate_->ConfigureOutgoingConnection(registry)) { | 63 if (!delegate_->ConfigureOutgoingConnection(registry)) { |
| 68 delete registry; | 64 delete registry; |
| 69 return nullptr; | 65 return nullptr; |
| 70 } | 66 } |
| 71 outgoing_service_registries_.push_back(registry); | 67 outgoing_service_registries_.push_back(registry); |
| 72 return registry; | 68 return registry; |
| 73 } | 69 } |
| 74 | 70 |
| 75 void ApplicationImpl::Initialize(ShellPtr shell, | 71 void ApplicationImpl::Initialize(ShellPtr shell, |
| 76 Array<String> args, | |
| 77 const mojo::String& url) { | 72 const mojo::String& url) { |
|
msw
2015/05/19 17:45:27
nit: fits on line above.
jam
2015/05/19 20:56:37
Done.
| |
| 78 shell_ = shell.Pass(); | 73 shell_ = shell.Pass(); |
| 79 shell_watch_ = new ShellPtrWatcher(this); | 74 shell_watch_ = new ShellPtrWatcher(this); |
| 80 shell_.set_error_handler(shell_watch_); | 75 shell_.set_error_handler(shell_watch_); |
| 81 url_ = url; | 76 url_ = url; |
| 82 args_ = args.To<std::vector<std::string>>(); | |
| 83 delegate_->Initialize(this); | 77 delegate_->Initialize(this); |
| 84 } | 78 } |
| 85 | 79 |
| 86 void ApplicationImpl::WaitForInitialize() { | 80 void ApplicationImpl::WaitForInitialize() { |
| 87 if (!shell_) | 81 if (!shell_) |
| 88 binding_.WaitForIncomingMethodCall(); | 82 binding_.WaitForIncomingMethodCall(); |
| 89 } | 83 } |
| 90 | 84 |
| 91 void ApplicationImpl::UnbindConnections( | 85 void ApplicationImpl::UnbindConnections( |
| 92 InterfaceRequest<Application>* application_request, | 86 InterfaceRequest<Application>* application_request, |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 108 } | 102 } |
| 109 incoming_service_registries_.push_back(registry); | 103 incoming_service_registries_.push_back(registry); |
| 110 } | 104 } |
| 111 | 105 |
| 112 void ApplicationImpl::RequestQuit() { | 106 void ApplicationImpl::RequestQuit() { |
| 113 delegate_->Quit(); | 107 delegate_->Quit(); |
| 114 Terminate(); | 108 Terminate(); |
| 115 } | 109 } |
| 116 | 110 |
| 117 } // namespace mojo | 111 } // namespace mojo |
| OLD | NEW |