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

Side by Side Diff: base/memory/discardable_memory.cc

Issue 681713002: Update from chromium https://crrev.com/301315 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 | « base/memory/discardable_memory.h ('k') | base/memory/discardable_memory_android.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/memory/discardable_memory.h" 5 #include "base/memory/discardable_memory.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 9
10 namespace base { 10 namespace base {
11 namespace { 11 namespace {
12 12
13 const struct TypeNamePair { 13 const struct TypeNamePair {
14 DiscardableMemoryType type; 14 DiscardableMemoryType type;
15 const char* name; 15 const char* name;
16 } kTypeNamePairs[] = { 16 } kTypeNamePairs[] = {
17 { DISCARDABLE_MEMORY_TYPE_ASHMEM, "ashmem" }, 17 { DISCARDABLE_MEMORY_TYPE_ASHMEM, "ashmem" },
18 { DISCARDABLE_MEMORY_TYPE_MACH, "mach" }, 18 { DISCARDABLE_MEMORY_TYPE_MACH, "mach" },
19 { DISCARDABLE_MEMORY_TYPE_EMULATED, "emulated" } 19 { DISCARDABLE_MEMORY_TYPE_EMULATED, "emulated" },
20 { DISCARDABLE_MEMORY_TYPE_SHMEM, "shmem" }
20 }; 21 };
21 22
22 DiscardableMemoryType g_preferred_type = DISCARDABLE_MEMORY_TYPE_NONE; 23 DiscardableMemoryType g_preferred_type = DISCARDABLE_MEMORY_TYPE_NONE;
23 24
24 struct DefaultPreferredType { 25 struct DefaultPreferredType {
25 DefaultPreferredType() : value(DISCARDABLE_MEMORY_TYPE_NONE) { 26 DefaultPreferredType() : value(DISCARDABLE_MEMORY_TYPE_NONE) {
26 std::vector<DiscardableMemoryType> supported_types; 27 std::vector<DiscardableMemoryType> supported_types;
27 DiscardableMemory::GetSupportedTypes(&supported_types); 28 DiscardableMemory::GetSupportedTypes(&supported_types);
28 DCHECK(!supported_types.empty()); 29 DCHECK(!supported_types.empty());
29 value = supported_types[0]; 30 value = supported_types[0];
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 return g_preferred_type; 77 return g_preferred_type;
77 } 78 }
78 79
79 // static 80 // static
80 scoped_ptr<DiscardableMemory> DiscardableMemory::CreateLockedMemory( 81 scoped_ptr<DiscardableMemory> DiscardableMemory::CreateLockedMemory(
81 size_t size) { 82 size_t size) {
82 return CreateLockedMemoryWithType(GetPreferredType(), size); 83 return CreateLockedMemoryWithType(GetPreferredType(), size);
83 } 84 }
84 85
85 } // namespace base 86 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/discardable_memory.h ('k') | base/memory/discardable_memory_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698