| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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 // unique_ptr-style pointer that stores values that may be from an arena. Takes | 5 // unique_ptr-style pointer that stores values that may be from an arena. Takes |
| 6 // up the same storage as the platform's native pointer type. Takes ownership | 6 // up the same storage as the platform's native pointer type. Takes ownership |
| 7 // of the value it's constructed with; if holding a value in an arena, and the | 7 // of the value it's constructed with; if holding a value in an arena, and the |
| 8 // type has a non-trivial destructor, the arena must outlive the | 8 // type has a non-trivial destructor, the arena must outlive the |
| 9 // QuicArenaScopedPtr. Does not support array overloads. | 9 // QuicArenaScopedPtr. Does not support array overloads. |
| 10 | 10 |
| 11 #ifndef NET_QUIC_CORE_QUIC_ARENA_SCOPED_PTR_H_ | 11 #ifndef NET_QUIC_CORE_QUIC_ARENA_SCOPED_PTR_H_ |
| 12 #define NET_QUIC_CORE_QUIC_ARENA_SCOPED_PTR_H_ | 12 #define NET_QUIC_CORE_QUIC_ARENA_SCOPED_PTR_H_ |
| 13 | 13 |
| 14 #include <cstdint> // for uintptr_t | 14 #include <cstdint> // for uintptr_t |
| 15 | 15 |
| 16 #include "base/logging.h" | |
| 17 #include "base/macros.h" | 16 #include "base/macros.h" |
| 18 #include "net/quic/platform/api/quic_aligned.h" | 17 #include "net/quic/platform/api/quic_aligned.h" |
| 18 #include "net/quic/platform/api/quic_logging.h" |
| 19 | 19 |
| 20 namespace net { | 20 namespace net { |
| 21 | 21 |
| 22 template <typename T> | 22 template <typename T> |
| 23 class QuicArenaScopedPtr { | 23 class QuicArenaScopedPtr { |
| 24 static_assert(QUIC_ALIGN_OF(T*) > 1, | 24 static_assert(QUIC_ALIGN_OF(T*) > 1, |
| 25 "QuicArenaScopedPtr can only store objects that are aligned to " | 25 "QuicArenaScopedPtr can only store objects that are aligned to " |
| 26 "greater than 1 byte."); | 26 "greater than 1 byte."); |
| 27 | 27 |
| 28 public: | 28 public: |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 case ConstructFrom::kArena: | 200 case ConstructFrom::kArena: |
| 201 value_ = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(value_) | | 201 value_ = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(value_) | |
| 202 QuicArenaScopedPtr<T>::kFromArenaMask); | 202 QuicArenaScopedPtr<T>::kFromArenaMask); |
| 203 break; | 203 break; |
| 204 } | 204 } |
| 205 } | 205 } |
| 206 | 206 |
| 207 } // namespace net | 207 } // namespace net |
| 208 | 208 |
| 209 #endif // NET_QUIC_CORE_QUIC_ARENA_SCOPED_PTR_H_ | 209 #endif // NET_QUIC_CORE_QUIC_ARENA_SCOPED_PTR_H_ |
| OLD | NEW |