| 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 // This is a copy of base/linked_ptr.h with CHECKS/DCHECKS replaced with | 5 // This is a copy of base/linked_ptr.h with CHECKS/DCHECKS replaced with |
| 6 // PP_DCHECKs. | 6 // PP_DCHECKs. |
| 7 // | 7 // |
| 8 // A "smart" pointer type with reference tracking. Every pointer to a | 8 // A "smart" pointer type with reference tracking. Every pointer to a |
| 9 // particular object is kept on a circular linked list. When the last pointer | 9 // particular object is kept on a circular linked list. When the last pointer |
| 10 // to an object is destroyed or reassigned, the object is deleted. | 10 // to an object is destroyed or reassigned, the object is deleted. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // | 30 // |
| 31 // Thread Safety: | 31 // Thread Safety: |
| 32 // A linked_ptr is NOT thread safe. Copying a linked_ptr object is | 32 // A linked_ptr is NOT thread safe. Copying a linked_ptr object is |
| 33 // effectively a read-write operation. | 33 // effectively a read-write operation. |
| 34 // | 34 // |
| 35 // Alternative: to linked_ptr is shared_ptr, which | 35 // Alternative: to linked_ptr is shared_ptr, which |
| 36 // - is also two pointers in size (8 bytes for 32 bit addresses) | 36 // - is also two pointers in size (8 bytes for 32 bit addresses) |
| 37 // - is thread safe for copying and deletion | 37 // - is thread safe for copying and deletion |
| 38 // - supports weak_ptrs | 38 // - supports weak_ptrs |
| 39 | 39 |
| 40 #ifndef WEBKIT_RENDERER_MEDIA_CRYPTO_PPAPI_LINKED_PTR_H_ | 40 #ifndef MEDIA_CDM_PPAPI_LINKED_PTR_H_ |
| 41 #define WEBKIT_RENDERER_MEDIA_CRYPTO_PPAPI_LINKED_PTR_H_ | 41 #define MEDIA_CDM_PPAPI_LINKED_PTR_H_ |
| 42 | 42 |
| 43 #include "ppapi/cpp/logging.h" | 43 #include "ppapi/cpp/logging.h" |
| 44 | 44 |
| 45 // This is used internally by all instances of linked_ptr<>. It needs to be | 45 // This is used internally by all instances of linked_ptr<>. It needs to be |
| 46 // a non-template class because different types of linked_ptr<> can refer to | 46 // a non-template class because different types of linked_ptr<> can refer to |
| 47 // the same object (linked_ptr<Superclass>(obj) vs linked_ptr<Subclass>(obj)). | 47 // the same object (linked_ptr<Superclass>(obj) vs linked_ptr<Subclass>(obj)). |
| 48 // So, it needs to be possible for different types of linked_ptr to participate | 48 // So, it needs to be possible for different types of linked_ptr to participate |
| 49 // in the same circular linked list, so we need a single class type here. | 49 // in the same circular linked list, so we need a single class type here. |
| 50 // | 50 // |
| 51 // DO NOT USE THIS CLASS DIRECTLY YOURSELF. Use linked_ptr<T>. | 51 // DO NOT USE THIS CLASS DIRECTLY YOURSELF. Use linked_ptr<T>. |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 } | 175 } |
| 176 | 176 |
| 177 // A function to convert T* into linked_ptr<T> | 177 // A function to convert T* into linked_ptr<T> |
| 178 // Doing e.g. make_linked_ptr(new FooBarBaz<type>(arg)) is a shorter notation | 178 // Doing e.g. make_linked_ptr(new FooBarBaz<type>(arg)) is a shorter notation |
| 179 // for linked_ptr<FooBarBaz<type> >(new FooBarBaz<type>(arg)) | 179 // for linked_ptr<FooBarBaz<type> >(new FooBarBaz<type>(arg)) |
| 180 template <typename T> | 180 template <typename T> |
| 181 linked_ptr<T> make_linked_ptr(T* ptr) { | 181 linked_ptr<T> make_linked_ptr(T* ptr) { |
| 182 return linked_ptr<T>(ptr); | 182 return linked_ptr<T>(ptr); |
| 183 } | 183 } |
| 184 | 184 |
| 185 #endif // WEBKIT_RENDERER_MEDIA_CRYPTO_PPAPI_LINKED_PTR_H_ | 185 #endif // MEDIA_CDM_PPAPI_LINKED_PTR_H_ |
| OLD | NEW |