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

Unified Diff: base/memory/discardable_memory_ashmem.h

Issue 195863005: Use DiscardableMemoryManager on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix base.gypi Created 6 years, 8 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_ashmem.h
diff --git a/base/memory/discardable_memory_ashmem.h b/base/memory/discardable_memory_ashmem.h
new file mode 100644
index 0000000000000000000000000000000000000000..1d5944185dc3bf99e38b9d94aaefc6bf967d7333
--- /dev/null
+++ b/base/memory/discardable_memory_ashmem.h
@@ -0,0 +1,53 @@
+// 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_ASHMEM_H_
+#define BASE_MEMORY_DISCARDABLE_MEMORY_ASHMEM_H_
+
+#include "base/memory/discardable_memory.h"
+
+#include "base/macros.h"
+#include "base/memory/discardable_memory_manager.h"
+
+namespace base {
+namespace internal {
+
+class DiscardableAshmemChunk;
+class DiscardableMemoryAllocator;
+class DiscardableMemoryManager;
+
+class DiscardableMemoryAshmem
+ : public DiscardableMemory,
+ public internal::DiscardableMemoryManagerAllocation {
+ public:
+ explicit DiscardableMemoryAshmem(size_t size,
+ DiscardableMemoryAllocator* allocator,
+ DiscardableMemoryManager* manager);
+
+ virtual ~DiscardableMemoryAshmem();
+
+ bool Initialize();
+
+ // Overridden from DiscardableMemory:
+ virtual DiscardableMemoryLockStatus Lock() OVERRIDE;
+ virtual void Unlock() OVERRIDE;
+ virtual void* Memory() const OVERRIDE;
+
+ // Overridden from internal::DiscardableMemoryManagerAllocation:
+ virtual bool AllocateAndAcquireLock(size_t bytes) OVERRIDE;
+ virtual void ReleaseLock() OVERRIDE;
+ virtual void Purge() OVERRIDE;
+
+ private:
+ DiscardableMemoryAllocator* const allocator_;
+ DiscardableMemoryManager* const manager_;
reveman 2014/04/26 00:13:37 nit: I don't think we typically use "const" for po
Philippe 2014/04/28 12:23:14 Unfortunately, yes. I saw that const is underused
reveman 2014/04/28 15:39:16 I agree that it's valuable and would prefer that i
Philippe 2014/04/28 15:53:45 I see, thanks. I went over all our discardable mem
willchan no longer on Chromium 2014/04/30 06:38:21 FWIW, I am positive on const pointers as well, but
+ scoped_ptr<DiscardableAshmemChunk> ashmem_chunk_;
+
+ DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryAshmem);
+};
+
+} // namespace internal
+} // namespace base
+
+#endif // BASE_MEMORY_DISCARDABLE_MEMORY_ASHMEM_H_

Powered by Google App Engine
This is Rietveld 408576698