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

Side by Side Diff: mojo/public/cpp/bindings/lib/interface_ptr_internal.h

Issue 613053002: Mojo: NULL -> nullptr in mojo/public/cpp/bindings and also for the bindings generator. (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 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_INTERNAL_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_INTERNAL_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_INTERNAL_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_INTERNAL_H_
7 7
8 #include <algorithm> // For |std::swap()|. 8 #include <algorithm> // For |std::swap()|.
9 9
10 #include "mojo/public/cpp/bindings/lib/filter_chain.h" 10 #include "mojo/public/cpp/bindings/lib/filter_chain.h"
11 #include "mojo/public/cpp/bindings/lib/message_header_validator.h" 11 #include "mojo/public/cpp/bindings/lib/message_header_validator.h"
12 #include "mojo/public/cpp/bindings/lib/router.h" 12 #include "mojo/public/cpp/bindings/lib/router.h"
13 #include "mojo/public/cpp/environment/logging.h" 13 #include "mojo/public/cpp/environment/logging.h"
14 14
15 struct MojoAsyncWaiter; 15 struct MojoAsyncWaiter;
16 16
17 namespace mojo { 17 namespace mojo {
18 namespace internal { 18 namespace internal {
19 19
20 template <typename Interface> 20 template <typename Interface>
21 class InterfacePtrState { 21 class InterfacePtrState {
22 public: 22 public:
23 InterfacePtrState() : proxy_(NULL), router_(NULL), waiter_(NULL) {} 23 InterfacePtrState() : proxy_(nullptr), router_(nullptr), waiter_(nullptr) {}
24 24
25 ~InterfacePtrState() { 25 ~InterfacePtrState() {
26 // Destruction order matters here. We delete |proxy_| first, even though 26 // Destruction order matters here. We delete |proxy_| first, even though
27 // |router_| may have a reference to it, so that |~Interface| may have a 27 // |router_| may have a reference to it, so that |~Interface| may have a
28 // shot at generating new outbound messages (ie, invoking client methods). 28 // shot at generating new outbound messages (ie, invoking client methods).
29 delete proxy_; 29 delete proxy_;
30 delete router_; 30 delete router_;
31 } 31 }
32 32
33 Interface* instance() { 33 Interface* instance() {
34 ConfigureProxyIfNecessary(); 34 ConfigureProxyIfNecessary();
35 35
36 // This will be NULL if the object is not bound. 36 // This will be null if the object is not bound.
37 return proxy_; 37 return proxy_;
38 } 38 }
39 39
40 void Swap(InterfacePtrState* other) { 40 void Swap(InterfacePtrState* other) {
41 std::swap(other->proxy_, proxy_); 41 std::swap(other->proxy_, proxy_);
42 std::swap(other->router_, router_); 42 std::swap(other->router_, router_);
43 handle_.swap(other->handle_); 43 handle_.swap(other->handle_);
44 std::swap(other->waiter_, waiter_); 44 std::swap(other->waiter_, waiter_);
45 } 45 }
46 46
(...skipping 11 matching lines...) Expand all
58 ConfigureProxyIfNecessary(); 58 ConfigureProxyIfNecessary();
59 59
60 MOJO_DCHECK(router_); 60 MOJO_DCHECK(router_);
61 return router_->WaitForIncomingMessage(); 61 return router_->WaitForIncomingMessage();
62 } 62 }
63 63
64 ScopedMessagePipeHandle PassMessagePipe() { 64 ScopedMessagePipeHandle PassMessagePipe() {
65 if (router_) 65 if (router_)
66 return router_->PassMessagePipe(); 66 return router_->PassMessagePipe();
67 67
68 waiter_ = NULL; 68 waiter_ = nullptr;
69 return handle_.Pass(); 69 return handle_.Pass();
70 } 70 }
71 71
72 bool is_bound() const { 72 bool is_bound() const {
73 return handle_.is_valid() || router_; 73 return handle_.is_valid() || router_;
74 } 74 }
75 75
76 void set_client(typename Interface::Client* client) { 76 void set_client(typename Interface::Client* client) {
77 ConfigureProxyIfNecessary(); 77 ConfigureProxyIfNecessary();
78 78
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 MOJO_DCHECK(!handle_.is_valid()); 118 MOJO_DCHECK(!handle_.is_valid());
119 return; 119 return;
120 } 120 }
121 121
122 FilterChain filters; 122 FilterChain filters;
123 filters.Append<MessageHeaderValidator>(); 123 filters.Append<MessageHeaderValidator>();
124 filters.Append<typename Interface::Client::RequestValidator_>(); 124 filters.Append<typename Interface::Client::RequestValidator_>();
125 filters.Append<typename Interface::ResponseValidator_>(); 125 filters.Append<typename Interface::ResponseValidator_>();
126 126
127 router_ = new Router(handle_.Pass(), filters.Pass(), waiter_); 127 router_ = new Router(handle_.Pass(), filters.Pass(), waiter_);
128 waiter_ = NULL; 128 waiter_ = nullptr;
129 129
130 ProxyWithStub* proxy = new ProxyWithStub(router_); 130 ProxyWithStub* proxy = new ProxyWithStub(router_);
131 router_->set_incoming_receiver(&proxy->stub); 131 router_->set_incoming_receiver(&proxy->stub);
132 132
133 proxy_ = proxy; 133 proxy_ = proxy;
134 } 134 }
135 135
136 ProxyWithStub* proxy_; 136 ProxyWithStub* proxy_;
137 Router* router_; 137 Router* router_;
138 138
139 // |proxy_| and |router_| are not initialized until read/write with the 139 // |proxy_| and |router_| are not initialized until read/write with the
140 // message pipe handle is needed. Before that, |handle_| and |waiter_| store 140 // message pipe handle is needed. Before that, |handle_| and |waiter_| store
141 // the arguments of Bind(). 141 // the arguments of Bind().
142 ScopedMessagePipeHandle handle_; 142 ScopedMessagePipeHandle handle_;
143 const MojoAsyncWaiter* waiter_; 143 const MojoAsyncWaiter* waiter_;
144 144
145 MOJO_DISALLOW_COPY_AND_ASSIGN(InterfacePtrState); 145 MOJO_DISALLOW_COPY_AND_ASSIGN(InterfacePtrState);
146 }; 146 };
147 147
148 } // namespace internal 148 } // namespace internal
149 } // namespace mojo 149 } // namespace mojo
150 150
151 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_INTERNAL_H_ 151 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_INTERNAL_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/interface_impl_internal.h ('k') | mojo/public/cpp/bindings/lib/message.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698