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

Side by Side Diff: components/discardable_memory/client/client_discardable_shared_memory_manager.h

Issue 2459733002: Move discardable memory to //components from //content (Closed)
Patch Set: Fix build error Created 4 years, 1 month 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 CONTENT_CHILD_CHILD_DISCARDABLE_SHARED_MEMORY_MANAGER_H_ 5 #ifndef COMPONENTS_DISCARDABLE_MEMORY_CLIENT_CLIENT_DISCARDABLE_SHARED_MEMORY_MA NAGER_H_
6 #define CONTENT_CHILD_CHILD_DISCARDABLE_SHARED_MEMORY_MANAGER_H_ 6 #define COMPONENTS_DISCARDABLE_MEMORY_CLIENT_CLIENT_DISCARDABLE_SHARED_MEMORY_MA NAGER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/discardable_memory_allocator.h" 11 #include "base/memory/discardable_memory_allocator.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/synchronization/lock.h" 13 #include "base/synchronization/lock.h"
14 #include "base/trace_event/memory_dump_provider.h" 14 #include "base/trace_event/memory_dump_provider.h"
15 #include "content/child/thread_safe_sender.h" 15 #include "components/discardable_memory/common/discardable_memory_export.h"
16 #include "content/common/content_export.h" 16 #include "components/discardable_memory/common/discardable_shared_memory_heap.h"
17 #include "content/common/discardable_shared_memory_heap.h" 17 #include "components/discardable_memory/common/discardable_shared_memory_manager .h"
18 #include "content/common/host_discardable_shared_memory_manager.h"
19 18
20 namespace content { 19 namespace discardable_memory {
21 20
22 // Implementation of DiscardableMemoryAllocator that allocates 21 // Implementation of DiscardableMemoryAllocator that allocates
23 // discardable memory segments through the browser process. 22 // discardable memory segments through the browser process.
24 class CONTENT_EXPORT ChildDiscardableSharedMemoryManager 23 class DISCARDABLE_MEMORY_EXPORT ClientDiscardableSharedMemoryManager
25 : public base::DiscardableMemoryAllocator, 24 : public base::DiscardableMemoryAllocator,
26 public base::trace_event::MemoryDumpProvider { 25 public base::trace_event::MemoryDumpProvider {
27 public: 26 public:
28 explicit ChildDiscardableSharedMemoryManager(ThreadSafeSender* sender); 27 class Delegate {
29 ~ChildDiscardableSharedMemoryManager() override; 28 public:
29 virtual void AllocateLockedDiscardableSharedMemory(
30 size_t size,
31 DiscardableSharedMemoryId id,
32 base::SharedMemoryHandle* handle) = 0;
33 virtual void DeletedDiscardableSharedMemory(
34 DiscardableSharedMemoryId id) = 0;
35
36 protected:
37 virtual ~Delegate() {}
38 };
39
40 explicit ClientDiscardableSharedMemoryManager(Delegate* delegate);
41 ~ClientDiscardableSharedMemoryManager() override;
30 42
31 // Overridden from base::DiscardableMemoryAllocator: 43 // Overridden from base::DiscardableMemoryAllocator:
32 std::unique_ptr<base::DiscardableMemory> AllocateLockedDiscardableMemory( 44 std::unique_ptr<base::DiscardableMemory> AllocateLockedDiscardableMemory(
33 size_t size) override; 45 size_t size) override;
34 46
35 // Overridden from base::trace_event::MemoryDumpProvider: 47 // Overridden from base::trace_event::MemoryDumpProvider:
36 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, 48 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
37 base::trace_event::ProcessMemoryDump* pmd) override; 49 base::trace_event::ProcessMemoryDump* pmd) override;
38 50
39 // Release memory and associated resources that have been purged. 51 // Release memory and associated resources that have been purged.
(...skipping 17 matching lines...) Expand all
57 69
58 private: 70 private:
59 std::unique_ptr<base::DiscardableSharedMemory> 71 std::unique_ptr<base::DiscardableSharedMemory>
60 AllocateLockedDiscardableSharedMemory(size_t size, 72 AllocateLockedDiscardableSharedMemory(size_t size,
61 DiscardableSharedMemoryId id); 73 DiscardableSharedMemoryId id);
62 void MemoryUsageChanged(size_t new_bytes_allocated, 74 void MemoryUsageChanged(size_t new_bytes_allocated,
63 size_t new_bytes_free) const; 75 size_t new_bytes_free) const;
64 76
65 mutable base::Lock lock_; 77 mutable base::Lock lock_;
66 DiscardableSharedMemoryHeap heap_; 78 DiscardableSharedMemoryHeap heap_;
67 scoped_refptr<ThreadSafeSender> sender_; 79 Delegate* const delegate_;
68 80
69 DISALLOW_COPY_AND_ASSIGN(ChildDiscardableSharedMemoryManager); 81 DISALLOW_COPY_AND_ASSIGN(ClientDiscardableSharedMemoryManager);
70 }; 82 };
71 83
72 } // namespace content 84 } // namespace discardable_memory
73 85
74 #endif // CONTENT_CHILD_CHILD_DISCARDABLE_SHARED_MEMORY_MANAGER_H_ 86 #endif // COMPONENTS_DISCARDABLE_MEMORY_CLIENT_CLIENT_DISCARDABLE_SHARED_MEMORY _MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698