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

Side by Side Diff: base/memory/discardable_memory_shmem_allocator.h

Issue 817653003: Update from https://crrev.com/309717 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
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 #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_SHMEM_ALLOCATOR_H_ 5 #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_SHMEM_ALLOCATOR_H_
6 #define BASE_MEMORY_DISCARDABLE_MEMORY_SHMEM_ALLOCATOR_H_ 6 #define BASE_MEMORY_DISCARDABLE_MEMORY_SHMEM_ALLOCATOR_H_
7 7
8 #include "base/base_export.h" 8 #include "base/base_export.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 10
11 namespace base { 11 namespace base {
12 class DiscardableSharedMemory; 12
13 // TODO(reveman): Remove this by having allocator interface return
14 // real DiscardableMemory instances. crbug.com/442945
15 class BASE_EXPORT DiscardableMemoryShmemChunk {
16 public:
17 virtual ~DiscardableMemoryShmemChunk() {}
18
19 virtual bool Lock() = 0;
20 virtual void Unlock() = 0;
21 virtual void* Memory() const = 0;
22 virtual bool IsMemoryResident() const = 0;
23 };
13 24
14 class BASE_EXPORT DiscardableMemoryShmemAllocator { 25 class BASE_EXPORT DiscardableMemoryShmemAllocator {
15 public: 26 public:
16 // Returns the allocator instance. 27 // Returns the allocator instance.
17 static DiscardableMemoryShmemAllocator* GetInstance(); 28 static DiscardableMemoryShmemAllocator* GetInstance();
18 29
19 // Sets the allocator instance. Can only be called once, e.g. on startup. 30 // Sets the allocator instance. Can only be called once, e.g. on startup.
20 // Ownership of |instance| remains with the caller. 31 // Ownership of |instance| remains with the caller.
21 static void SetInstance(DiscardableMemoryShmemAllocator* allocator); 32 static void SetInstance(DiscardableMemoryShmemAllocator* allocator);
22 33
23 virtual scoped_ptr<DiscardableSharedMemory> 34 virtual scoped_ptr<DiscardableMemoryShmemChunk>
24 AllocateLockedDiscardableSharedMemory(size_t size) = 0; 35 AllocateLockedDiscardableMemory(size_t size) = 0;
25 36
26 protected: 37 protected:
27 virtual ~DiscardableMemoryShmemAllocator() {} 38 virtual ~DiscardableMemoryShmemAllocator() {}
28 }; 39 };
29 40
30 } // namespace base 41 } // namespace base
31 42
32 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_SHMEM_ALLOCATOR_H_ 43 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_SHMEM_ALLOCATOR_H_
OLDNEW
« no previous file with comments | « base/memory/discardable_memory_shmem.cc ('k') | base/memory/discardable_memory_shmem_allocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698