forked from sanyaade-mobiledev/chromium.src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchild_discardable_shared_memory_manager.h
46 lines (35 loc) · 1.69 KB
/
child_discardable_shared_memory_manager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// 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 CONTENT_CHILD_CHILD_DISCARDABLE_SHARED_MEMORY_MANAGER_H_
#define CONTENT_CHILD_CHILD_DISCARDABLE_SHARED_MEMORY_MANAGER_H_
#include "base/memory/discardable_memory_shmem_allocator.h"
#include "base/memory/ref_counted.h"
#include "base/synchronization/lock.h"
#include "content/child/thread_safe_sender.h"
#include "content/common/discardable_shared_memory_heap.h"
namespace content {
// Implementation of DiscardableMemoryShmemAllocator that allocates
// discardable memory segments through the browser process.
class ChildDiscardableSharedMemoryManager
: public base::DiscardableMemoryShmemAllocator {
public:
explicit ChildDiscardableSharedMemoryManager(ThreadSafeSender* sender);
~ChildDiscardableSharedMemoryManager() override;
// Overridden from base::DiscardableMemoryShmemAllocator:
scoped_ptr<base::DiscardableMemoryShmemChunk> AllocateLockedDiscardableMemory(
size_t size) override;
bool LockSpan(DiscardableSharedMemoryHeap::Span* span);
void UnlockSpan(DiscardableSharedMemoryHeap::Span* span);
bool IsSpanResident(DiscardableSharedMemoryHeap::Span* span) const;
void ReleaseSpan(scoped_ptr<DiscardableSharedMemoryHeap::Span> span);
private:
scoped_ptr<base::DiscardableSharedMemory>
AllocateLockedDiscardableSharedMemory(size_t size);
mutable base::Lock lock_;
DiscardableSharedMemoryHeap heap_;
scoped_refptr<ThreadSafeSender> sender_;
DISALLOW_COPY_AND_ASSIGN(ChildDiscardableSharedMemoryManager);
};
} // namespace content
#endif // CONTENT_CHILD_CHILD_DISCARDABLE_SHARED_MEMORY_MANAGER_H_