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

Side by Side Diff: base/allocator/allocator_shim.h

Issue 2279473002: [OBSOLETE]new experiment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months 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
« no previous file with comments | « BUILD.gn ('k') | hax/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef BASE_ALLOCATOR_ALLOCATOR_SHIM_H_ 5 #ifndef BASE_ALLOCATOR_ALLOCATOR_SHIM_H_
6 #define BASE_ALLOCATOR_ALLOCATOR_SHIM_H_ 6 #define BASE_ALLOCATOR_ALLOCATOR_SHIM_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/allocator/allocator_shim_internals.h"
10 #include "base/base_export.h" 11 #include "base/base_export.h"
11 12
12 namespace base { 13 namespace base {
13 namespace allocator { 14 namespace allocator {
14 15
15 // Allocator Shim API. Allows to to: 16 // Allocator Shim API. Allows to to:
16 // - Configure the behavior of the allocator (what to do on OOM failures). 17 // - Configure the behavior of the allocator (what to do on OOM failures).
17 // - Install new hooks (AllocatorDispatch) in the allocator chain. 18 // - Install new hooks (AllocatorDispatch) in the allocator chain.
18 19
19 // When this shim layer is enabled, the route of an allocation is as-follows: 20 // When this shim layer is enabled, the route of an allocation is as-follows:
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // configuration. 71 // configuration.
71 static const AllocatorDispatch default_dispatch; 72 static const AllocatorDispatch default_dispatch;
72 }; 73 };
73 74
74 // When true makes malloc behave like new, w.r.t calling the new_handler if 75 // When true makes malloc behave like new, w.r.t calling the new_handler if
75 // the allocation fails (see set_new_mode() in Windows). 76 // the allocation fails (see set_new_mode() in Windows).
76 BASE_EXPORT void SetCallNewHandlerOnMallocFailure(bool value); 77 BASE_EXPORT void SetCallNewHandlerOnMallocFailure(bool value);
77 78
78 // Allocates |size| bytes or returns nullptr. It does NOT call the new_handler, 79 // Allocates |size| bytes or returns nullptr. It does NOT call the new_handler,
79 // regardless of SetCallNewHandlerOnMallocFailure(). 80 // regardless of SetCallNewHandlerOnMallocFailure().
80 BASE_EXPORT void* UncheckedAlloc(size_t size); 81 SHIM_ALWAYS_EXPORT void* UncheckedAlloc(size_t size);
81 82
82 // Inserts |dispatch| in front of the allocator chain. This method is NOT 83 // Inserts |dispatch| in front of the allocator chain. This method is NOT
83 // thread-safe w.r.t concurrent invocations of InsertAllocatorDispatch(). 84 // thread-safe w.r.t concurrent invocations of InsertAllocatorDispatch().
84 // The callers have the responsibility of linearizing the changes to the chain 85 // The callers have the responsibility of linearizing the changes to the chain
85 // (or more likely call these always on the same thread). 86 // (or more likely call these always on the same thread).
86 BASE_EXPORT void InsertAllocatorDispatch(AllocatorDispatch* dispatch); 87 BASE_EXPORT void InsertAllocatorDispatch(AllocatorDispatch* dispatch);
87 88
88 // Test-only. Rationale: (1) lack of use cases; (2) dealing safely with a 89 // Test-only. Rationale: (1) lack of use cases; (2) dealing safely with a
89 // removal of arbitrary elements from a singly linked list would require a lock 90 // removal of arbitrary elements from a singly linked list would require a lock
90 // in malloc(), which we really don't want. 91 // in malloc(), which we really don't want.
91 BASE_EXPORT void RemoveAllocatorDispatchForTesting(AllocatorDispatch* dispatch); 92 BASE_EXPORT void RemoveAllocatorDispatchForTesting(AllocatorDispatch* dispatch);
92 93
93 } // namespace allocator 94 } // namespace allocator
94 } // namespace base 95 } // namespace base
95 96
96 #endif // BASE_ALLOCATOR_ALLOCATOR_SHIM_H_ 97 #endif // BASE_ALLOCATOR_ALLOCATOR_SHIM_H_
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | hax/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698