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

Unified Diff: base/memory/discardable_memory_allocation.h

Issue 204733003: base: Refactor DiscardableMemoryManager for use with different type of allocations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add missing unlock call and remove unnecessary unlock call Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: base/memory/discardable_memory_allocation.h
diff --git a/base/memory/discardable_memory_allocation.h b/base/memory/discardable_memory_allocation.h
new file mode 100644
index 0000000000000000000000000000000000000000..98e8b98bbd86ff6c7f5cbee311a4a392a9b4dc3b
--- /dev/null
+++ b/base/memory/discardable_memory_allocation.h
@@ -0,0 +1,41 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BASE_MEMORY_DISCARDABLE_MEMORY_ALLOCATION_H_
+#define BASE_MEMORY_DISCARDABLE_MEMORY_ALLOCATION_H_
+
+#include "base/base_export.h"
+#include "base/memory/scoped_ptr.h"
+
+namespace base {
+namespace internal {
+
+class BASE_EXPORT_PRIVATE DiscardableMemoryAllocation {
willchan no longer on Chromium 2014/04/01 01:11:08 Can you comment this class so it's obvious how thi
reveman 2014/04/03 17:02:12 Added a comment here and improved the comments in
+ public:
+ class BASE_EXPORT_PRIVATE Factory {
+ public:
+ virtual scoped_ptr<DiscardableMemoryAllocation> CreateLockedAllocation(
+ size_t bytes) = 0;
+
+ protected:
+ virtual ~Factory() {}
+ };
+
+ virtual ~DiscardableMemoryAllocation() {}
+
+ // Locks the allocation so that it will not be purged by the system. Returns
+ // true if memory is still resident.
+ virtual bool Lock() = 0;
+
+ // Unlocks the allocation so that it can be purged by the system.
+ virtual void Unlock() = 0;
+
+ // Returns the memory address for this allocation.
+ virtual void* Memory() = 0;
+};
+
+} // namespace internal
+} // namespace base
+
+#endif // BASE_MEMORY_DISCARDABLE_MEMORY_ALLOCATION_H_

Powered by Google App Engine
This is Rietveld 408576698