| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_REMOTE_PTR_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_REMOTE_PTR_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_REMOTE_PTR_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_REMOTE_PTR_H_ |
| 7 | 7 |
| 8 #include <assert.h> | 8 #include <assert.h> |
| 9 | 9 |
| 10 #include "mojo/public/cpp/bindings/interface.h" | 10 #include "mojo/public/cpp/bindings/interface.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 typename S::_Peer* peer, | 79 typename S::_Peer* peer, |
| 80 ErrorHandler* error_handler = NULL, | 80 ErrorHandler* error_handler = NULL, |
| 81 MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()) | 81 MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()) |
| 82 : state_(new State(ScopedMessagePipeHandle(interface_handle.Pass()), peer, | 82 : state_(new State(ScopedMessagePipeHandle(interface_handle.Pass()), peer, |
| 83 error_handler, waiter)) { | 83 error_handler, waiter)) { |
| 84 } | 84 } |
| 85 | 85 |
| 86 // Move-only constructor and operator=. | 86 // Move-only constructor and operator=. |
| 87 RemotePtr(RValue other) : state_(other.object->release()) {} | 87 RemotePtr(RValue other) : state_(other.object->release()) {} |
| 88 RemotePtr& operator=(RValue other) { | 88 RemotePtr& operator=(RValue other) { |
| 89 delete state_; |
| 89 state_ = other.object->release(); | 90 state_ = other.object->release(); |
| 90 return *this; | 91 return *this; |
| 91 } | 92 } |
| 92 | 93 |
| 93 ~RemotePtr() { | 94 ~RemotePtr() { |
| 94 delete state_; | 95 delete state_; |
| 95 } | 96 } |
| 96 | 97 |
| 97 bool is_null() const { | 98 bool is_null() const { |
| 98 return !state_; | 99 return !state_; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 state_ = NULL; | 148 state_ = NULL; |
| 148 return state; | 149 return state; |
| 149 } | 150 } |
| 150 | 151 |
| 151 State* state_; | 152 State* state_; |
| 152 }; | 153 }; |
| 153 | 154 |
| 154 } // namespace mojo | 155 } // namespace mojo |
| 155 | 156 |
| 156 #endif // MOJO_PUBLIC_CPP_BINDINGS_REMOTE_PTR_H_ | 157 #endif // MOJO_PUBLIC_CPP_BINDINGS_REMOTE_PTR_H_ |
| OLD | NEW |