OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "base/allocator/allocator_shim.h" | 5 #include "base/allocator/allocator_shim.h" |
6 | 6 |
7 #include <malloc.h> | 7 #include <malloc.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <string.h> | 9 #include <string.h> |
10 #include <unistd.h> | 10 #include <unistd.h> |
11 | 11 |
| 12 #include <memory> |
12 #include <new> | 13 #include <new> |
13 #include <vector> | 14 #include <vector> |
14 | 15 |
15 #include "base/atomicops.h" | 16 #include "base/atomicops.h" |
16 #include "base/memory/scoped_ptr.h" | |
17 #include "base/synchronization/waitable_event.h" | 17 #include "base/synchronization/waitable_event.h" |
18 #include "base/threading/platform_thread.h" | 18 #include "base/threading/platform_thread.h" |
19 #include "base/threading/thread_local.h" | 19 #include "base/threading/thread_local.h" |
20 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
22 | 22 |
23 namespace base { | 23 namespace base { |
24 namespace allocator { | 24 namespace allocator { |
25 namespace { | 25 namespace { |
26 | 26 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 void TearDown() override { instance_ = nullptr; } | 119 void TearDown() override { instance_ = nullptr; } |
120 | 120 |
121 protected: | 121 protected: |
122 size_t allocs_intercepted_by_size[kMaxSizeTracked]; | 122 size_t allocs_intercepted_by_size[kMaxSizeTracked]; |
123 size_t zero_allocs_intercepted_by_size[kMaxSizeTracked]; | 123 size_t zero_allocs_intercepted_by_size[kMaxSizeTracked]; |
124 size_t aligned_allocs_intercepted_by_size[kMaxSizeTracked]; | 124 size_t aligned_allocs_intercepted_by_size[kMaxSizeTracked]; |
125 size_t aligned_allocs_intercepted_by_alignment[kMaxSizeTracked]; | 125 size_t aligned_allocs_intercepted_by_alignment[kMaxSizeTracked]; |
126 size_t reallocs_intercepted_by_size[kMaxSizeTracked]; | 126 size_t reallocs_intercepted_by_size[kMaxSizeTracked]; |
127 size_t reallocs_intercepted_by_addr[kMaxSizeTracked]; | 127 size_t reallocs_intercepted_by_addr[kMaxSizeTracked]; |
128 size_t frees_intercepted_by_addr[kMaxSizeTracked]; | 128 size_t frees_intercepted_by_addr[kMaxSizeTracked]; |
129 scoped_ptr<ThreadLocalBoolean> did_fail_realloc_0x42_once; | 129 std::unique_ptr<ThreadLocalBoolean> did_fail_realloc_0x42_once; |
130 subtle::Atomic32 num_new_handler_calls; | 130 subtle::Atomic32 num_new_handler_calls; |
131 | 131 |
132 private: | 132 private: |
133 static AllocatorShimTest* instance_; | 133 static AllocatorShimTest* instance_; |
134 }; | 134 }; |
135 | 135 |
136 struct TestStruct1 { | 136 struct TestStruct1 { |
137 uint32_t ignored; | 137 uint32_t ignored; |
138 uint8_t ignored_2; | 138 uint8_t ignored_2; |
139 }; | 139 }; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 event.Signal(); | 305 event.Signal(); |
306 for (int i = 0; i < kNumThreads; ++i) | 306 for (int i = 0; i < kNumThreads; ++i) |
307 PlatformThread::Join(threads[i]); | 307 PlatformThread::Join(threads[i]); |
308 RemoveAllocatorDispatchForTesting(&g_mock_dispatch); | 308 RemoveAllocatorDispatchForTesting(&g_mock_dispatch); |
309 ASSERT_EQ(kNumThreads, GetNumberOfNewHandlerCalls()); | 309 ASSERT_EQ(kNumThreads, GetNumberOfNewHandlerCalls()); |
310 } | 310 } |
311 | 311 |
312 } // namespace | 312 } // namespace |
313 } // namespace allocator | 313 } // namespace allocator |
314 } // namespace base | 314 } // namespace base |
OLD | NEW |