| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Intel Corporation. All rights reserved. | 3 * Copyright (C) 2013 Intel Corporation. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 // to help simplify the implementation of WebKit interfaces that merely | 41 // to help simplify the implementation of WebKit interfaces that merely |
| 42 // wrap a pointer to a WebCore class. It's similar to WebPrivatePtr, but it | 42 // wrap a pointer to a WebCore class. It's similar to WebPrivatePtr, but it |
| 43 // wraps a naked pointer rather than a reference counted. | 43 // wraps a naked pointer rather than a reference counted. |
| 44 // Note: you must call reset(0) on the implementation side in order to delete | 44 // Note: you must call reset(0) on the implementation side in order to delete |
| 45 // the WebCore pointer. | 45 // the WebCore pointer. |
| 46 template <typename T> | 46 template <typename T> |
| 47 class WebPrivateOwnPtr : public WebNonCopyable { | 47 class WebPrivateOwnPtr : public WebNonCopyable { |
| 48 public: | 48 public: |
| 49 WebPrivateOwnPtr() : m_ptr(nullptr) {} | 49 WebPrivateOwnPtr() : m_ptr(nullptr) {} |
| 50 WebPrivateOwnPtr(std::nullptr_t) : m_ptr(nullptr) {} | 50 WebPrivateOwnPtr(std::nullptr_t) : m_ptr(nullptr) {} |
| 51 ~WebPrivateOwnPtr() { BLINK_ASSERT(!m_ptr); } | 51 ~WebPrivateOwnPtr() { DCHECK(!m_ptr); } |
| 52 | 52 |
| 53 explicit WebPrivateOwnPtr(T* ptr) | 53 explicit WebPrivateOwnPtr(T* ptr) |
| 54 : m_ptr(ptr) | 54 : m_ptr(ptr) |
| 55 { | 55 { |
| 56 } | 56 } |
| 57 | 57 |
| 58 T* get() const { return m_ptr; } | 58 T* get() const { return m_ptr; } |
| 59 | 59 |
| 60 #if INSIDE_BLINK | 60 #if INSIDE_BLINK |
| 61 template<typename U> WebPrivateOwnPtr(const PassOwnPtr<U>&, EnsurePtrConvert
ibleArgDecl(U, T)); | 61 template<typename U> WebPrivateOwnPtr(const PassOwnPtr<U>&, EnsurePtrConvert
ibleArgDecl(U, T)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 73 | 73 |
| 74 PassOwnPtr<T> release() | 74 PassOwnPtr<T> release() |
| 75 { | 75 { |
| 76 T* ptr = m_ptr; | 76 T* ptr = m_ptr; |
| 77 m_ptr = nullptr; | 77 m_ptr = nullptr; |
| 78 return adoptPtr(ptr); | 78 return adoptPtr(ptr); |
| 79 } | 79 } |
| 80 | 80 |
| 81 T& operator*() const | 81 T& operator*() const |
| 82 { | 82 { |
| 83 BLINK_ASSERT(m_ptr); | 83 DCHECK(m_ptr); |
| 84 return *m_ptr; | 84 return *m_ptr; |
| 85 } | 85 } |
| 86 | 86 |
| 87 T* operator->() const | 87 T* operator->() const |
| 88 { | 88 { |
| 89 BLINK_ASSERT(m_ptr); | 89 DCHECK(m_ptr); |
| 90 return m_ptr; | 90 return m_ptr; |
| 91 } | 91 } |
| 92 #endif // INSIDE_BLINK | 92 #endif // INSIDE_BLINK |
| 93 | 93 |
| 94 private: | 94 private: |
| 95 T* m_ptr; | 95 T* m_ptr; |
| 96 }; | 96 }; |
| 97 | 97 |
| 98 #if INSIDE_BLINK | 98 #if INSIDE_BLINK |
| 99 template<typename T> template<typename U> inline WebPrivateOwnPtr<T>::WebPrivate
OwnPtr(const PassOwnPtr<U>& o, EnsurePtrConvertibleArgDefn(U, T)) | 99 template<typename T> template<typename U> inline WebPrivateOwnPtr<T>::WebPrivate
OwnPtr(const PassOwnPtr<U>& o, EnsurePtrConvertibleArgDefn(U, T)) |
| 100 : m_ptr(o.leakPtr()) | 100 : m_ptr(o.leakPtr()) |
| 101 { | 101 { |
| 102 static_assert(!std::is_array<T>::value, "Pointers to array must never be con
verted"); | 102 static_assert(!std::is_array<T>::value, "Pointers to array must never be con
verted"); |
| 103 } | 103 } |
| 104 #endif | 104 #endif |
| 105 | 105 |
| 106 } // namespace blink | 106 } // namespace blink |
| 107 | 107 |
| 108 #endif | 108 #endif |
| OLD | NEW |