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

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

Issue 441853002: mojo: first take on removing mojo_main_{chromium,standalone}. (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
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/application_impl.h" 5 #include "mojo/public/cpp/application/application_impl.h"
6 6
7 #include "mojo/public/cpp/application/application_delegate.h" 7 #include "mojo/public/cpp/application/application_delegate.h"
8 #include "mojo/public/cpp/application/lib/service_registry.h" 8 #include "mojo/public/cpp/application/lib/service_registry.h"
9 #include "mojo/public/cpp/bindings/interface_ptr.h" 9 #include "mojo/public/cpp/bindings/interface_ptr.h"
10 10
11 namespace mojo { 11 namespace mojo {
12 12
13 ApplicationImpl::ShellPtrWatcher::ShellPtrWatcher(ApplicationImpl* impl) 13 ApplicationImpl::ShellPtrWatcher::ShellPtrWatcher(ApplicationImpl* impl)
14 : impl_(impl) {} 14 : impl_(impl) {}
15 15
16 ApplicationImpl::ShellPtrWatcher::~ShellPtrWatcher() {} 16 ApplicationImpl::ShellPtrWatcher::~ShellPtrWatcher() {}
17 17
18 void ApplicationImpl::ShellPtrWatcher::OnConnectionError() { 18 void ApplicationImpl::ShellPtrWatcher::OnConnectionError() {
19 impl_->OnShellError(); 19 impl_->OnShellError();
20 } 20 }
21 21
22 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate)
23 : delegate_(delegate), shell_watch_(this) {}
24
25 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate, 22 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate,
26 ScopedMessagePipeHandle shell_handle) 23 ScopedMessagePipeHandle shell_handle)
27 : delegate_(delegate), shell_watch_(this) { 24 : delegate_(delegate), shell_watch_(this) {
28 BindShell(shell_handle.Pass()); 25 BindShell(shell_handle.Pass());
29 } 26 }
30 27
31 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate, 28 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate,
32 MojoHandle shell_handle) 29 MojoHandle shell_handle)
33 : delegate_(delegate), shell_watch_(this) { 30 : delegate_(delegate), shell_watch_(this) {
34 BindShell(shell_handle); 31 BindShell(MakeScopedHandle(MessagePipeHandle(shell_handle)));
35 } 32 }
36 33
37 void ApplicationImpl::ClearConnections() { 34 void ApplicationImpl::ClearConnections() {
38 for (ServiceRegistryList::iterator i(incoming_service_registries_.begin()); 35 for (ServiceRegistryList::iterator i(incoming_service_registries_.begin());
39 i != incoming_service_registries_.end(); ++i) 36 i != incoming_service_registries_.end(); ++i)
40 delete *i; 37 delete *i;
41 for (ServiceRegistryList::iterator i(outgoing_service_registries_.begin()); 38 for (ServiceRegistryList::iterator i(outgoing_service_registries_.begin());
42 i != outgoing_service_registries_.end(); ++i) 39 i != outgoing_service_registries_.end(); ++i)
43 delete *i; 40 delete *i;
44 incoming_service_registries_.clear(); 41 incoming_service_registries_.clear();
(...skipping 20 matching lines...) Expand all
65 return registry; 62 return registry;
66 } 63 }
67 64
68 void ApplicationImpl::BindShell(ScopedMessagePipeHandle shell_handle) { 65 void ApplicationImpl::BindShell(ScopedMessagePipeHandle shell_handle) {
69 shell_.Bind(shell_handle.Pass()); 66 shell_.Bind(shell_handle.Pass());
70 shell_.set_client(this); 67 shell_.set_client(this);
71 shell_.set_error_handler(&shell_watch_); 68 shell_.set_error_handler(&shell_watch_);
72 delegate_->Initialize(this); 69 delegate_->Initialize(this);
73 } 70 }
74 71
75 void ApplicationImpl::BindShell(MojoHandle shell_handle) {
76 BindShell(mojo::MakeScopedHandle(mojo::MessagePipeHandle(shell_handle)));
77 }
78
79 void ApplicationImpl::AcceptConnection(const String& requestor_url, 72 void ApplicationImpl::AcceptConnection(const String& requestor_url,
80 ServiceProviderPtr service_provider) { 73 ServiceProviderPtr service_provider) {
81 internal::ServiceRegistry* registry = new internal::ServiceRegistry( 74 internal::ServiceRegistry* registry = new internal::ServiceRegistry(
82 this, requestor_url, service_provider.Pass()); 75 this, requestor_url, service_provider.Pass());
83 if (!delegate_->ConfigureIncomingConnection(registry)) { 76 if (!delegate_->ConfigureIncomingConnection(registry)) {
84 delete registry; 77 delete registry;
85 return; 78 return;
86 } 79 }
87 incoming_service_registries_.push_back(registry); 80 incoming_service_registries_.push_back(registry);
88 } 81 }
89 82
90 } // namespace mojo 83 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698