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

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

Issue 535543002: Remove ShellPtrWatcher details from public header (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « mojo/public/cpp/application/application_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 class ApplicationImpl::ShellPtrWatcher : public ErrorHandler {
14 public:
15 ShellPtrWatcher(ApplicationImpl* impl)
14 : impl_(impl) {} 16 : impl_(impl) {}
15 17
16 ApplicationImpl::ShellPtrWatcher::~ShellPtrWatcher() {} 18 virtual ~ShellPtrWatcher() {}
17 19
18 void ApplicationImpl::ShellPtrWatcher::OnConnectionError() { 20 virtual void OnConnectionError() MOJO_OVERRIDE {
19 impl_->OnShellError(); 21 impl_->OnShellError();
20 } 22 }
23
24 private:
25 ApplicationImpl* impl_;
26 MOJO_DISALLOW_COPY_AND_ASSIGN(ShellPtrWatcher);
27 };
21 28
22 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate, 29 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate,
23 ScopedMessagePipeHandle shell_handle) 30 ScopedMessagePipeHandle shell_handle)
24 : delegate_(delegate), shell_watch_(this) { 31 : delegate_(delegate), shell_watch_(NULL) {
25 BindShell(shell_handle.Pass()); 32 BindShell(shell_handle.Pass());
26 } 33 }
27 34
28 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate, 35 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate,
29 MojoHandle shell_handle) 36 MojoHandle shell_handle)
30 : delegate_(delegate), shell_watch_(this) { 37 : delegate_(delegate), shell_watch_(NULL) {
31 BindShell(MakeScopedHandle(MessagePipeHandle(shell_handle))); 38 BindShell(MakeScopedHandle(MessagePipeHandle(shell_handle)));
32 } 39 }
33 40
34 void ApplicationImpl::ClearConnections() { 41 void ApplicationImpl::ClearConnections() {
35 for (ServiceRegistryList::iterator i(incoming_service_registries_.begin()); 42 for (ServiceRegistryList::iterator i(incoming_service_registries_.begin());
36 i != incoming_service_registries_.end(); ++i) 43 i != incoming_service_registries_.end(); ++i)
37 delete *i; 44 delete *i;
38 for (ServiceRegistryList::iterator i(outgoing_service_registries_.begin()); 45 for (ServiceRegistryList::iterator i(outgoing_service_registries_.begin());
39 i != outgoing_service_registries_.end(); ++i) 46 i != outgoing_service_registries_.end(); ++i)
40 delete *i; 47 delete *i;
41 incoming_service_registries_.clear(); 48 incoming_service_registries_.clear();
42 outgoing_service_registries_.clear(); 49 outgoing_service_registries_.clear();
43 } 50 }
44 51
45 ApplicationImpl::~ApplicationImpl() { 52 ApplicationImpl::~ApplicationImpl() {
46 ClearConnections(); 53 ClearConnections();
54 delete shell_watch_;
47 } 55 }
48 56
49 ApplicationConnection* ApplicationImpl::ConnectToApplication( 57 ApplicationConnection* ApplicationImpl::ConnectToApplication(
50 const String& application_url) { 58 const String& application_url) {
51 ServiceProviderPtr out_service_provider; 59 ServiceProviderPtr out_service_provider;
52 shell_->ConnectToApplication(application_url, Get(&out_service_provider)); 60 shell_->ConnectToApplication(application_url, Get(&out_service_provider));
53 internal::ServiceRegistry* registry = new internal::ServiceRegistry( 61 internal::ServiceRegistry* registry = new internal::ServiceRegistry(
54 this, 62 this,
55 application_url, 63 application_url,
56 out_service_provider.Pass()); 64 out_service_provider.Pass());
57 if (!delegate_->ConfigureOutgoingConnection(registry)) { 65 if (!delegate_->ConfigureOutgoingConnection(registry)) {
58 delete registry; 66 delete registry;
59 return NULL; 67 return NULL;
60 } 68 }
61 outgoing_service_registries_.push_back(registry); 69 outgoing_service_registries_.push_back(registry);
62 return registry; 70 return registry;
63 } 71 }
64 72
65 void ApplicationImpl::BindShell(ScopedMessagePipeHandle shell_handle) { 73 void ApplicationImpl::BindShell(ScopedMessagePipeHandle shell_handle) {
74 shell_watch_ = new ShellPtrWatcher(this);
66 shell_.Bind(shell_handle.Pass()); 75 shell_.Bind(shell_handle.Pass());
67 shell_.set_client(this); 76 shell_.set_client(this);
68 shell_.set_error_handler(&shell_watch_); 77 shell_.set_error_handler(shell_watch_);
69 delegate_->Initialize(this); 78 delegate_->Initialize(this);
70 } 79 }
71 80
72 void ApplicationImpl::AcceptConnection(const String& requestor_url, 81 void ApplicationImpl::AcceptConnection(const String& requestor_url,
73 ServiceProviderPtr service_provider) { 82 ServiceProviderPtr service_provider) {
74 internal::ServiceRegistry* registry = new internal::ServiceRegistry( 83 internal::ServiceRegistry* registry = new internal::ServiceRegistry(
75 this, requestor_url, service_provider.Pass()); 84 this, requestor_url, service_provider.Pass());
76 if (!delegate_->ConfigureIncomingConnection(registry)) { 85 if (!delegate_->ConfigureIncomingConnection(registry)) {
77 delete registry; 86 delete registry;
78 return; 87 return;
79 } 88 }
80 incoming_service_registries_.push_back(registry); 89 incoming_service_registries_.push_back(registry);
81 } 90 }
82 91
83 } // namespace mojo 92 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/application/application_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698