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

Unified Diff: base/memory/discardable_memory.cc

Issue 114923005: base: Discardable memory types. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: base/memory/discardable_memory.cc
diff --git a/base/memory/discardable_memory.cc b/base/memory/discardable_memory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..74830aefe9800be7866ec9c532b4125d2b556b1d
--- /dev/null
+++ b/base/memory/discardable_memory.cc
@@ -0,0 +1,34 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
Philippe 2013/12/17 14:28:21 Nit: I believe there is no '(c)' anymore for new f
reveman 2013/12/18 08:12:38 Done.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/memory/discardable_memory.h"
+
+#include "base/lazy_instance.h"
+
+namespace base {
+namespace {
+
+struct DiscardableMemoryTypeInitializedWithPreferredValue {
+ DiscardableMemoryTypeInitializedWithPreferredValue()
+ : v(DiscardableMemory::GetSupportedTypes().front()) {
+ }
+
+ DiscardableMemoryType v;
Philippe 2013/12/17 14:28:21 Nit: maybe call this 'value' or 'type'.
reveman 2013/12/18 08:12:38 Done.
+};
+LazyInstance<DiscardableMemoryTypeInitializedWithPreferredValue>::Leaky
+ g_discardable_memory_type = LAZY_INSTANCE_INITIALIZER;
+
+} // namespace
+
+// static
+void DiscardableMemory::SetType(DiscardableMemoryType type) {
+ g_discardable_memory_type.Get().v = type;
+}
+
+// static
+DiscardableMemoryType DiscardableMemory::GetType() {
+ return g_discardable_memory_type.Get().v;
+}
+
+} // namespace base

Powered by Google App Engine
This is Rietveld 408576698