Added ability to use new GAIA endpoint on CrOS login screen.
[chromium-blink-merge.git] / base / allocator / allocator_extension.cc
blob83e460ac82bc899317b0634ac3a24afbcdb44cbc
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/allocator/allocator_extension.h"
7 #include "base/logging.h"
9 namespace base {
10 namespace allocator {
12 bool GetAllocatorWasteSize(size_t* size) {
13 thunks::GetAllocatorWasteSizeFunction get_allocator_waste_size_function =
14 thunks::GetGetAllocatorWasteSizeFunction();
15 return get_allocator_waste_size_function != NULL &&
16 get_allocator_waste_size_function(size);
19 void GetStats(char* buffer, int buffer_length) {
20 DCHECK_GT(buffer_length, 0);
21 thunks::GetStatsFunction get_stats_function = thunks::GetGetStatsFunction();
22 if (get_stats_function)
23 get_stats_function(buffer, buffer_length);
24 else
25 buffer[0] = '\0';
28 void ReleaseFreeMemory() {
29 thunks::ReleaseFreeMemoryFunction release_free_memory_function =
30 thunks::GetReleaseFreeMemoryFunction();
31 if (release_free_memory_function)
32 release_free_memory_function();
35 void SetGetAllocatorWasteSizeFunction(
36 thunks::GetAllocatorWasteSizeFunction get_allocator_waste_size_function) {
37 DCHECK_EQ(thunks::GetGetAllocatorWasteSizeFunction(),
38 reinterpret_cast<thunks::GetAllocatorWasteSizeFunction>(NULL));
39 thunks::SetGetAllocatorWasteSizeFunction(get_allocator_waste_size_function);
42 void SetGetStatsFunction(thunks::GetStatsFunction get_stats_function) {
43 DCHECK_EQ(thunks::GetGetStatsFunction(),
44 reinterpret_cast<thunks::GetStatsFunction>(NULL));
45 thunks::SetGetStatsFunction(get_stats_function);
48 void SetReleaseFreeMemoryFunction(
49 thunks::ReleaseFreeMemoryFunction release_free_memory_function) {
50 DCHECK_EQ(thunks::GetReleaseFreeMemoryFunction(),
51 reinterpret_cast<thunks::ReleaseFreeMemoryFunction>(NULL));
52 thunks::SetReleaseFreeMemoryFunction(release_free_memory_function);
55 } // namespace allocator
56 } // namespace base