| OLD | NEW |
| 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_SHARED_PTR_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_SHARED_PTR_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_SHARED_PTR_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_SHARED_PTR_H_ |
| 7 | 7 |
| 8 #include "mojo/public/cpp/bindings/lib/shared_data.h" | 8 #include "mojo/public/cpp/bindings/lib/shared_data.h" |
| 9 | 9 |
| 10 namespace mojo { | 10 namespace mojo { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 // Default copy-constructor and assignment operator are OK. | 25 // Default copy-constructor and assignment operator are OK. |
| 26 | 26 |
| 27 P* get() { | 27 P* get() { |
| 28 return impl_.value().ptr; | 28 return impl_.value().ptr; |
| 29 } | 29 } |
| 30 const P* get() const { | 30 const P* get() const { |
| 31 return impl_.value().ptr; | 31 return impl_.value().ptr; |
| 32 } | 32 } |
| 33 | 33 |
| 34 void reset() { |
| 35 impl_.reset(); |
| 36 } |
| 37 |
| 34 P* operator->() { return get(); } | 38 P* operator->() { return get(); } |
| 35 const P* operator->() const { return get(); } | 39 const P* operator->() const { return get(); } |
| 36 | 40 |
| 37 private: | 41 private: |
| 38 class Impl { | 42 class Impl { |
| 39 public: | 43 public: |
| 40 ~Impl() { | 44 ~Impl() { |
| 41 if (ptr) | 45 if (ptr) |
| 42 delete ptr; | 46 delete ptr; |
| 43 } | 47 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 54 MOJO_DISALLOW_COPY_AND_ASSIGN(Impl); | 58 MOJO_DISALLOW_COPY_AND_ASSIGN(Impl); |
| 55 }; | 59 }; |
| 56 | 60 |
| 57 SharedData<Impl> impl_; | 61 SharedData<Impl> impl_; |
| 58 }; | 62 }; |
| 59 | 63 |
| 60 } // namespace mojo | 64 } // namespace mojo |
| 61 } // namespace internal | 65 } // namespace internal |
| 62 | 66 |
| 63 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_SHARED_PTR_H_ | 67 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_SHARED_PTR_H_ |
| OLD | NEW |