| 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 | 5 |
| 6 #ifndef LIBRARIES_SDK_UTIL_SCOPED_REF_H_ | 6 #ifndef LIBRARIES_SDK_UTIL_SCOPED_REF_H_ |
| 7 #define LIBRARIES_SDK_UTIL_SCOPED_REF_H_ | 7 #define LIBRARIES_SDK_UTIL_SCOPED_REF_H_ |
| 8 | 8 |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 | 10 |
| 11 #include "sdk_util/macros.h" | 11 #include "sdk_util/macros.h" |
| 12 #include "sdk_util/ref_object.h" | 12 #include "sdk_util/ref_object.h" |
| 13 | 13 |
| 14 namespace sdk_util { |
| 15 |
| 14 class ScopedRefBase { | 16 class ScopedRefBase { |
| 15 protected: | 17 protected: |
| 16 ScopedRefBase() : ptr_(NULL) {} | 18 ScopedRefBase() : ptr_(NULL) {} |
| 17 ~ScopedRefBase() { reset(NULL); } | 19 ~ScopedRefBase() { reset(NULL); } |
| 18 | 20 |
| 19 void reset(RefObject* obj) { | 21 void reset(RefObject* obj) { |
| 20 if (obj) { | 22 if (obj) { |
| 21 obj->Acquire(); | 23 obj->Acquire(); |
| 22 } | 24 } |
| 23 if (ptr_) { | 25 if (ptr_) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 private: | 75 private: |
| 74 typedef void (ScopedRef::*bool_as_func_ptr)() const; | 76 typedef void (ScopedRef::*bool_as_func_ptr)() const; |
| 75 void bool_as_func_impl() const {}; | 77 void bool_as_func_impl() const {}; |
| 76 | 78 |
| 77 public: | 79 public: |
| 78 operator bool_as_func_ptr() const { | 80 operator bool_as_func_ptr() const { |
| 79 return (ptr_ != NULL) ? &ScopedRef::bool_as_func_impl : 0; | 81 return (ptr_ != NULL) ? &ScopedRef::bool_as_func_impl : 0; |
| 80 } | 82 } |
| 81 }; | 83 }; |
| 82 | 84 |
| 85 } // namespace sdk_util |
| 86 |
| 83 #endif // LIBRARIES_SDK_UTIL_SCOPED_REF_H_ | 87 #endif // LIBRARIES_SDK_UTIL_SCOPED_REF_H_ |
| OLD | NEW |