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

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

Issue 612243002: Mojo: NULL -> nullptr in mojo/public/cpp outside of bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
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 #include "mojo/public/cpp/environment/logging.h" 10 #include "mojo/public/cpp/environment/logging.h"
11 11
12 namespace mojo { 12 namespace mojo {
13 13
14 class ApplicationImpl::ShellPtrWatcher : public ErrorHandler { 14 class ApplicationImpl::ShellPtrWatcher : public ErrorHandler {
15 public: 15 public:
16 ShellPtrWatcher(ApplicationImpl* impl) 16 ShellPtrWatcher(ApplicationImpl* impl)
17 : impl_(impl) {} 17 : impl_(impl) {}
18 18
19 virtual ~ShellPtrWatcher() {} 19 virtual ~ShellPtrWatcher() {}
20 20
21 virtual void OnConnectionError() override { impl_->OnShellError(); } 21 virtual void OnConnectionError() override { impl_->OnShellError(); }
22 22
23 private: 23 private:
24 ApplicationImpl* impl_; 24 ApplicationImpl* impl_;
25 MOJO_DISALLOW_COPY_AND_ASSIGN(ShellPtrWatcher); 25 MOJO_DISALLOW_COPY_AND_ASSIGN(ShellPtrWatcher);
26 }; 26 };
27 27
28 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate, 28 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate,
29 ScopedMessagePipeHandle shell_handle) 29 ScopedMessagePipeHandle shell_handle)
30 : initialized_(false), delegate_(delegate), shell_watch_(NULL) { 30 : initialized_(false), delegate_(delegate), shell_watch_(nullptr) {
31 BindShell(shell_handle.Pass()); 31 BindShell(shell_handle.Pass());
32 } 32 }
33 33
34 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate, 34 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate,
35 MojoHandle shell_handle) 35 MojoHandle shell_handle)
36 : initialized_(false), delegate_(delegate), shell_watch_(NULL) { 36 : initialized_(false), delegate_(delegate), shell_watch_(nullptr) {
37 BindShell(MakeScopedHandle(MessagePipeHandle(shell_handle))); 37 BindShell(MakeScopedHandle(MessagePipeHandle(shell_handle)));
38 } 38 }
39 39
40 void ApplicationImpl::ClearConnections() { 40 void ApplicationImpl::ClearConnections() {
41 for (ServiceRegistryList::iterator i(incoming_service_registries_.begin()); 41 for (ServiceRegistryList::iterator i(incoming_service_registries_.begin());
42 i != incoming_service_registries_.end(); ++i) 42 i != incoming_service_registries_.end(); ++i)
43 delete *i; 43 delete *i;
44 for (ServiceRegistryList::iterator i(outgoing_service_registries_.begin()); 44 for (ServiceRegistryList::iterator i(outgoing_service_registries_.begin());
45 i != outgoing_service_registries_.end(); ++i) 45 i != outgoing_service_registries_.end(); ++i)
46 delete *i; 46 delete *i;
(...skipping 17 matching lines...) Expand all
64 const String& application_url) { 64 const String& application_url) {
65 MOJO_CHECK(initialized_); 65 MOJO_CHECK(initialized_);
66 ServiceProviderPtr out_service_provider; 66 ServiceProviderPtr out_service_provider;
67 shell_->ConnectToApplication(application_url, Get(&out_service_provider)); 67 shell_->ConnectToApplication(application_url, Get(&out_service_provider));
68 internal::ServiceRegistry* registry = new internal::ServiceRegistry( 68 internal::ServiceRegistry* registry = new internal::ServiceRegistry(
69 this, 69 this,
70 application_url, 70 application_url,
71 out_service_provider.Pass()); 71 out_service_provider.Pass());
72 if (!delegate_->ConfigureOutgoingConnection(registry)) { 72 if (!delegate_->ConfigureOutgoingConnection(registry)) {
73 delete registry; 73 delete registry;
74 return NULL; 74 return nullptr;
75 } 75 }
76 outgoing_service_registries_.push_back(registry); 76 outgoing_service_registries_.push_back(registry);
77 return registry; 77 return registry;
78 } 78 }
79 79
80 void ApplicationImpl::BindShell(ScopedMessagePipeHandle shell_handle) { 80 void ApplicationImpl::BindShell(ScopedMessagePipeHandle shell_handle) {
81 shell_watch_ = new ShellPtrWatcher(this); 81 shell_watch_ = new ShellPtrWatcher(this);
82 shell_.Bind(shell_handle.Pass()); 82 shell_.Bind(shell_handle.Pass());
83 shell_.set_client(this); 83 shell_.set_client(this);
84 shell_.set_error_handler(shell_watch_); 84 shell_.set_error_handler(shell_watch_);
85 } 85 }
86 86
87 void ApplicationImpl::AcceptConnection(const String& requestor_url, 87 void ApplicationImpl::AcceptConnection(const String& requestor_url,
88 ServiceProviderPtr service_provider) { 88 ServiceProviderPtr service_provider) {
89 internal::ServiceRegistry* registry = new internal::ServiceRegistry( 89 internal::ServiceRegistry* registry = new internal::ServiceRegistry(
90 this, requestor_url, service_provider.Pass()); 90 this, requestor_url, service_provider.Pass());
91 if (!delegate_->ConfigureIncomingConnection(registry)) { 91 if (!delegate_->ConfigureIncomingConnection(registry)) {
92 delete registry; 92 delete registry;
93 return; 93 return;
94 } 94 }
95 incoming_service_registries_.push_back(registry); 95 incoming_service_registries_.push_back(registry);
96 } 96 }
97 97
98 } // namespace mojo 98 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/application/lazy_interface_ptr.h ('k') | mojo/public/cpp/application/lib/application_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698