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

Side by Side Diff: base/memory/discardable_memory_emulated.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_EMULATED_H_ 5 #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_EMULATED_H_
6 #define BASE_MEMORY_DISCARDABLE_MEMORY_EMULATED_H_ 6 #define BASE_MEMORY_DISCARDABLE_MEMORY_EMULATED_H_
7 7
8 #include "base/memory/discardable_memory.h" 8 #include "base/memory/discardable_memory.h"
9 9
10 #include "base/memory/discardable_memory_manager.h"
11
10 namespace base { 12 namespace base {
11 namespace internal { 13 namespace internal {
12 14
13 class DiscardableMemoryEmulated : public DiscardableMemory { 15 class DiscardableMemoryEmulated : public DiscardableMemory {
14 public: 16 public:
15 explicit DiscardableMemoryEmulated(size_t size); 17 explicit DiscardableMemoryEmulated(size_t size);
16 virtual ~DiscardableMemoryEmulated(); 18 virtual ~DiscardableMemoryEmulated();
17 19
18 static void RegisterMemoryPressureListeners(); 20 static void RegisterMemoryPressureListeners();
19 static void UnregisterMemoryPressureListeners(); 21 static void UnregisterMemoryPressureListeners();
20 22
21 static void PurgeForTesting(); 23 static void PurgeForTesting();
22 24
23 bool Initialize(); 25 bool Initialize();
24 26
25 // Overridden from DiscardableMemory: 27 // Overridden from DiscardableMemory:
26 virtual DiscardableMemoryLockStatus Lock() OVERRIDE; 28 virtual DiscardableMemoryLockStatus Lock() OVERRIDE;
27 virtual void Unlock() OVERRIDE; 29 virtual void Unlock() OVERRIDE;
28 virtual void* Memory() const OVERRIDE; 30 virtual void* Memory() const OVERRIDE;
29 31
30 private: 32 private:
31 scoped_ptr<uint8, FreeDeleter> memory_; 33 DiscardableMemoryManager::AllocationId allocation_id_;
32 bool is_locked_; 34 void* memory_;
33 35
34 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryEmulated); 36 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryEmulated);
35 }; 37 };
36 38
37 } // namespace internal 39 } // namespace internal
38 } // namespace base 40 } // namespace base
39 41
40 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_EMULATED_H_ 42 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_EMULATED_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698