Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Side by Side Diff: base/allocator/allocator_shim_unittest.cc

Issue 2552333002: Change the CRT initialization to create a new heap for Chrome.dll. (Closed)
Patch Set: Add a test per Will's request. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 10
11 #include <memory> 11 #include <memory>
12 #include <new> 12 #include <new>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/allocator/features.h"
15 #include "base/atomicops.h" 16 #include "base/atomicops.h"
16 #include "base/process/process_metrics.h" 17 #include "base/process/process_metrics.h"
17 #include "base/synchronization/waitable_event.h" 18 #include "base/synchronization/waitable_event.h"
18 #include "base/threading/platform_thread.h" 19 #include "base/threading/platform_thread.h"
19 #include "base/threading/thread_local.h" 20 #include "base/threading/thread_local.h"
20 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
22 23
23 #if !defined(OS_WIN) 24 #if defined(OS_WIN)
25 #include <windows.h>
26 #else
24 #include <unistd.h> 27 #include <unistd.h>
25 #endif 28 #endif
26 29
27 // Some new Android NDKs (64 bit) does not expose (p)valloc anymore. These 30 // Some new Android NDKs (64 bit) does not expose (p)valloc anymore. These
28 // functions are implemented at the shim-layer level. 31 // functions are implemented at the shim-layer level.
29 #if defined(OS_ANDROID) 32 #if defined(OS_ANDROID)
30 extern "C" { 33 extern "C" {
31 void* valloc(size_t size); 34 void* valloc(size_t size);
32 void* pvalloc(size_t size); 35 void* pvalloc(size_t size);
33 } 36 }
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 std::set_new_handler(&AllocatorShimTest::NewHandler); 325 std::set_new_handler(&AllocatorShimTest::NewHandler);
323 SetCallNewHandlerOnMallocFailure(true); // It's going to fail on realloc(). 326 SetCallNewHandlerOnMallocFailure(true); // It's going to fail on realloc().
324 InsertAllocatorDispatch(&g_mock_dispatch); 327 InsertAllocatorDispatch(&g_mock_dispatch);
325 event.Signal(); 328 event.Signal();
326 for (int i = 0; i < kNumThreads; ++i) 329 for (int i = 0; i < kNumThreads; ++i)
327 PlatformThread::Join(threads[i]); 330 PlatformThread::Join(threads[i]);
328 RemoveAllocatorDispatchForTesting(&g_mock_dispatch); 331 RemoveAllocatorDispatchForTesting(&g_mock_dispatch);
329 ASSERT_EQ(kNumThreads, GetNumberOfNewHandlerCalls()); 332 ASSERT_EQ(kNumThreads, GetNumberOfNewHandlerCalls());
330 } 333 }
331 334
335 #if defined(OS_WIN) && BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM)
336 TEST_F(AllocatorShimTest, ShimReplacesCRTHeapWhenEnabled) {
337 ASSERT_NE(::GetProcessHeap(), reinterpret_cast<HANDLE>(_get_heap_handle()));
338 }
339 #endif // defined(OS_WIN) && BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM)
340
332 } // namespace 341 } // namespace
333 } // namespace allocator 342 } // namespace allocator
334 } // namespace base 343 } // namespace base
OLDNEW
« no previous file with comments | « base/allocator/allocator_shim_override_ucrt_symbols_win.h ('k') | base/trace_event/malloc_dump_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698