| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 ~WebPrivateOwnPtr() { DCHECK(!m_ptr); } | 52 ~WebPrivateOwnPtr() { DCHECK(!m_ptr); } |
| 53 | 53 |
| 54 explicit WebPrivateOwnPtr(T* ptr) | 54 explicit WebPrivateOwnPtr(T* ptr) |
| 55 : m_ptr(ptr) | 55 : m_ptr(ptr) |
| 56 { | 56 { |
| 57 } | 57 } |
| 58 | 58 |
| 59 T* get() const { return m_ptr; } | 59 T* get() const { return m_ptr; } |
| 60 | 60 |
| 61 #if INSIDE_BLINK | 61 #if INSIDE_BLINK |
| 62 template<typename U> WebPrivateOwnPtr(const PassOwnPtr<U>&, EnsurePtrConvert
ibleArgDecl(U, T)); | 62 template <typename U> |
| 63 WebPrivateOwnPtr(PassOwnPtr<U>, EnsurePtrConvertibleArgDecl(U, T)); |
| 63 | 64 |
| 64 void reset(T* ptr) | 65 void reset(T* ptr) |
| 65 { | 66 { |
| 66 delete m_ptr; | 67 delete m_ptr; |
| 67 m_ptr = ptr; | 68 m_ptr = ptr; |
| 68 } | 69 } |
| 69 | 70 |
| 70 void reset(const PassOwnPtr<T>& o) | 71 void reset(PassOwnPtr<T> o) |
| 71 { | 72 { |
| 72 reset(o.leakPtr()); | 73 reset(o.leakPtr()); |
| 73 } | 74 } |
| 74 | 75 |
| 75 PassOwnPtr<T> release() | 76 PassOwnPtr<T> release() |
| 76 { | 77 { |
| 77 T* ptr = m_ptr; | 78 T* ptr = m_ptr; |
| 78 m_ptr = nullptr; | 79 m_ptr = nullptr; |
| 79 return adoptPtr(ptr); | 80 return adoptPtr(ptr); |
| 80 } | 81 } |
| 81 | 82 |
| 82 T& operator*() const | 83 T& operator*() const |
| 83 { | 84 { |
| 84 DCHECK(m_ptr); | 85 DCHECK(m_ptr); |
| 85 return *m_ptr; | 86 return *m_ptr; |
| 86 } | 87 } |
| 87 | 88 |
| 88 T* operator->() const | 89 T* operator->() const |
| 89 { | 90 { |
| 90 DCHECK(m_ptr); | 91 DCHECK(m_ptr); |
| 91 return m_ptr; | 92 return m_ptr; |
| 92 } | 93 } |
| 93 #endif // INSIDE_BLINK | 94 #endif // INSIDE_BLINK |
| 94 | 95 |
| 95 private: | 96 private: |
| 96 T* m_ptr; | 97 T* m_ptr; |
| 97 }; | 98 }; |
| 98 | 99 |
| 99 #if INSIDE_BLINK | 100 #if INSIDE_BLINK |
| 100 template<typename T> template<typename U> inline WebPrivateOwnPtr<T>::WebPrivate
OwnPtr(const PassOwnPtr<U>& o, EnsurePtrConvertibleArgDefn(U, T)) | 101 template <typename T> |
| 102 template <typename U> |
| 103 inline WebPrivateOwnPtr<T>::WebPrivateOwnPtr(PassOwnPtr<U> o, EnsurePtrConvertib
leArgDefn(U, T)) |
| 101 : m_ptr(o.leakPtr()) | 104 : m_ptr(o.leakPtr()) |
| 102 { | 105 { |
| 103 static_assert(!std::is_array<T>::value, "Pointers to array must never be con
verted"); | 106 static_assert(!std::is_array<T>::value, "Pointers to array must never be con
verted"); |
| 104 } | 107 } |
| 105 #endif | 108 #endif |
| 106 | 109 |
| 107 } // namespace blink | 110 } // namespace blink |
| 108 | 111 |
| 109 #endif | 112 #endif |
| OLD | NEW |