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

Side by Side Diff: content/child/child_discardable_shared_memory_manager.h

Issue 1100073004: Adding discardable memory dump provider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 CONTENT_CHILD_CHILD_DISCARDABLE_SHARED_MEMORY_MANAGER_H_ 5 #ifndef CONTENT_CHILD_CHILD_DISCARDABLE_SHARED_MEMORY_MANAGER_H_
6 #define CONTENT_CHILD_CHILD_DISCARDABLE_SHARED_MEMORY_MANAGER_H_ 6 #define CONTENT_CHILD_CHILD_DISCARDABLE_SHARED_MEMORY_MANAGER_H_
7 7
8 #include "base/memory/discardable_memory_allocator.h" 8 #include "base/memory/discardable_memory_allocator.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
11 #include "base/trace_event/memory_dump_provider.h"
11 #include "content/child/thread_safe_sender.h" 12 #include "content/child/thread_safe_sender.h"
12 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
13 #include "content/common/discardable_shared_memory_heap.h" 14 #include "content/common/discardable_shared_memory_heap.h"
14 #include "content/common/host_discardable_shared_memory_manager.h" 15 #include "content/common/host_discardable_shared_memory_manager.h"
15 16
16 namespace content { 17 namespace content {
17 18
18 // Implementation of DiscardableMemoryAllocator that allocates 19 // Implementation of DiscardableMemoryAllocator that allocates
19 // discardable memory segments through the browser process. 20 // discardable memory segments through the browser process.
20 class CONTENT_EXPORT ChildDiscardableSharedMemoryManager 21 class CONTENT_EXPORT ChildDiscardableSharedMemoryManager
21 : public base::DiscardableMemoryAllocator { 22 : public base::DiscardableMemoryAllocator,
23 public base::trace_event::MemoryDumpProvider {
22 public: 24 public:
23 explicit ChildDiscardableSharedMemoryManager(ThreadSafeSender* sender); 25 explicit ChildDiscardableSharedMemoryManager(ThreadSafeSender* sender);
24 ~ChildDiscardableSharedMemoryManager() override; 26 ~ChildDiscardableSharedMemoryManager() override;
25 27
26 // Overridden from base::DiscardableMemoryAllocator: 28 // Overridden from base::DiscardableMemoryAllocator:
27 scoped_ptr<base::DiscardableMemory> AllocateLockedDiscardableMemory( 29 scoped_ptr<base::DiscardableMemory> AllocateLockedDiscardableMemory(
28 size_t size) override; 30 size_t size) override;
29 31
30 // Release memory and associated resources that have been purged. 32 // Release memory and associated resources that have been purged.
31 void ReleaseFreeMemory(); 33 void ReleaseFreeMemory();
32 34
33 bool LockSpan(DiscardableSharedMemoryHeap::Span* span); 35 bool LockSpan(DiscardableSharedMemoryHeap::Span* span);
34 void UnlockSpan(DiscardableSharedMemoryHeap::Span* span); 36 void UnlockSpan(DiscardableSharedMemoryHeap::Span* span);
35 void ReleaseSpan(scoped_ptr<DiscardableSharedMemoryHeap::Span> span); 37 void ReleaseSpan(scoped_ptr<DiscardableSharedMemoryHeap::Span> span);
36 38
39 // base::trace_event::MemoryDumpProvider implementation:
reveman 2015/04/23 17:32:30 nit: "Overridden from base::trace_event::MemoryDum
ssid 2015/04/24 11:23:04 Done.
40 bool DumpInto(base::trace_event::ProcessMemoryDump* pmd) override;
41 const char* GetFriendlyName() const override;
reveman 2015/04/23 17:32:30 nit: please move this functions just below the fun
ssid 2015/04/24 11:23:04 Done.
42
37 private: 43 private:
38 scoped_ptr<base::DiscardableSharedMemory> 44 scoped_ptr<base::DiscardableSharedMemory>
39 AllocateLockedDiscardableSharedMemory(size_t size, 45 AllocateLockedDiscardableSharedMemory(size_t size,
40 DiscardableSharedMemoryId id); 46 DiscardableSharedMemoryId id);
41 void MemoryUsageChanged(size_t new_bytes_allocated, 47 void MemoryUsageChanged(size_t new_bytes_allocated,
42 size_t new_bytes_free) const; 48 size_t new_bytes_free) const;
43 49
44 mutable base::Lock lock_; 50 mutable base::Lock lock_;
45 DiscardableSharedMemoryHeap heap_; 51 DiscardableSharedMemoryHeap heap_;
46 scoped_refptr<ThreadSafeSender> sender_; 52 scoped_refptr<ThreadSafeSender> sender_;
47 53
48 DISALLOW_COPY_AND_ASSIGN(ChildDiscardableSharedMemoryManager); 54 DISALLOW_COPY_AND_ASSIGN(ChildDiscardableSharedMemoryManager);
49 }; 55 };
50 56
51 } // namespace content 57 } // namespace content
52 58
53 #endif // CONTENT_CHILD_CHILD_DISCARDABLE_SHARED_MEMORY_MANAGER_H_ 59 #endif // CONTENT_CHILD_CHILD_DISCARDABLE_SHARED_MEMORY_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698