ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / base / memory / discardable_memory_shmem_allocator.h
blobac4118edba27a2fda76ca7433588d8ffa075e8bb
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
3 // found in the LICENSE file.
5 #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_SHMEM_ALLOCATOR_H_
6 #define BASE_MEMORY_DISCARDABLE_MEMORY_SHMEM_ALLOCATOR_H_
8 #include "base/base_export.h"
9 #include "base/memory/scoped_ptr.h"
11 namespace base {
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() {}
19 virtual bool Lock() = 0;
20 virtual void Unlock() = 0;
21 virtual void* Memory() const = 0;
24 class BASE_EXPORT DiscardableMemoryShmemAllocator {
25 public:
26 // Returns the allocator instance.
27 static DiscardableMemoryShmemAllocator* GetInstance();
29 // Sets the allocator instance. Can only be called once, e.g. on startup.
30 // Ownership of |instance| remains with the caller.
31 static void SetInstance(DiscardableMemoryShmemAllocator* allocator);
33 virtual scoped_ptr<DiscardableMemoryShmemChunk>
34 AllocateLockedDiscardableMemory(size_t size) = 0;
36 protected:
37 virtual ~DiscardableMemoryShmemAllocator() {}
40 } // namespace base
42 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_SHMEM_ALLOCATOR_H_