OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_COMMON_HOST_SHARED_BITMAP_MANAGER_H_ | 5 #ifndef CONTENT_COMMON_HOST_SHARED_BITMAP_MANAGER_H_ |
6 #define CONTENT_COMMON_HOST_SHARED_BITMAP_MANAGER_H_ | 6 #define CONTENT_COMMON_HOST_SHARED_BITMAP_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/containers/hash_tables.h" | 12 #include "base/containers/hash_tables.h" |
13 #include "base/hash.h" | 13 #include "base/hash.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/shared_memory.h" | 16 #include "base/memory/shared_memory.h" |
17 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
| 18 #include "base/trace_event/memory_dump_provider.h" |
18 #include "cc/resources/shared_bitmap_manager.h" | 19 #include "cc/resources/shared_bitmap_manager.h" |
19 #include "content/common/content_export.h" | 20 #include "content/common/content_export.h" |
20 | 21 |
21 namespace BASE_HASH_NAMESPACE { | 22 namespace BASE_HASH_NAMESPACE { |
22 template <> | 23 template <> |
23 struct hash<cc::SharedBitmapId> { | 24 struct hash<cc::SharedBitmapId> { |
24 size_t operator()(const cc::SharedBitmapId& id) const { | 25 size_t operator()(const cc::SharedBitmapId& id) const { |
25 return base::Hash(reinterpret_cast<const char*>(id.name), sizeof(id.name)); | 26 return base::Hash(reinterpret_cast<const char*>(id.name), sizeof(id.name)); |
26 } | 27 } |
27 }; | 28 }; |
(...skipping 20 matching lines...) Expand all Loading... |
48 const cc::SharedBitmapId& id); | 49 const cc::SharedBitmapId& id); |
49 void ChildDeletedSharedBitmap(const cc::SharedBitmapId& id); | 50 void ChildDeletedSharedBitmap(const cc::SharedBitmapId& id); |
50 | 51 |
51 private: | 52 private: |
52 HostSharedBitmapManager* manager_; | 53 HostSharedBitmapManager* manager_; |
53 base::hash_set<cc::SharedBitmapId> owned_bitmaps_; | 54 base::hash_set<cc::SharedBitmapId> owned_bitmaps_; |
54 | 55 |
55 DISALLOW_COPY_AND_ASSIGN(HostSharedBitmapManagerClient); | 56 DISALLOW_COPY_AND_ASSIGN(HostSharedBitmapManagerClient); |
56 }; | 57 }; |
57 | 58 |
58 class CONTENT_EXPORT HostSharedBitmapManager : public cc::SharedBitmapManager { | 59 class CONTENT_EXPORT HostSharedBitmapManager |
| 60 : public cc::SharedBitmapManager, |
| 61 public base::trace_event::MemoryDumpProvider { |
59 public: | 62 public: |
60 HostSharedBitmapManager(); | 63 HostSharedBitmapManager(); |
61 ~HostSharedBitmapManager() override; | 64 ~HostSharedBitmapManager() override; |
62 | 65 |
63 static HostSharedBitmapManager* current(); | 66 static HostSharedBitmapManager* current(); |
64 | 67 |
65 // cc::SharedBitmapManager implementation. | 68 // cc::SharedBitmapManager implementation. |
66 scoped_ptr<cc::SharedBitmap> AllocateSharedBitmap( | 69 scoped_ptr<cc::SharedBitmap> AllocateSharedBitmap( |
67 const gfx::Size& size) override; | 70 const gfx::Size& size) override; |
68 scoped_ptr<cc::SharedBitmap> GetSharedBitmapFromId( | 71 scoped_ptr<cc::SharedBitmap> GetSharedBitmapFromId( |
69 const gfx::Size& size, | 72 const gfx::Size& size, |
70 const cc::SharedBitmapId&) override; | 73 const cc::SharedBitmapId&) override; |
71 | 74 |
| 75 // base::trace_event::MemoryDumpProvider implementation. |
| 76 bool OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) override; |
| 77 |
72 size_t AllocatedBitmapCount() const; | 78 size_t AllocatedBitmapCount() const; |
73 | 79 |
74 void FreeSharedMemoryFromMap(const cc::SharedBitmapId& id); | 80 void FreeSharedMemoryFromMap(const cc::SharedBitmapId& id); |
75 | 81 |
76 private: | 82 private: |
77 friend class HostSharedBitmapManagerClient; | 83 friend class HostSharedBitmapManagerClient; |
78 | 84 |
79 void AllocateSharedBitmapForChild( | 85 void AllocateSharedBitmapForChild( |
80 base::ProcessHandle process_handle, | 86 base::ProcessHandle process_handle, |
81 size_t buffer_size, | 87 size_t buffer_size, |
(...skipping 10 matching lines...) Expand all Loading... |
92 typedef base::hash_map<cc::SharedBitmapId, scoped_refptr<BitmapData> > | 98 typedef base::hash_map<cc::SharedBitmapId, scoped_refptr<BitmapData> > |
93 BitmapMap; | 99 BitmapMap; |
94 BitmapMap handle_map_; | 100 BitmapMap handle_map_; |
95 | 101 |
96 DISALLOW_COPY_AND_ASSIGN(HostSharedBitmapManager); | 102 DISALLOW_COPY_AND_ASSIGN(HostSharedBitmapManager); |
97 }; | 103 }; |
98 | 104 |
99 } // namespace content | 105 } // namespace content |
100 | 106 |
101 #endif // CONTENT_COMMON_HOST_SHARED_BITMAP_MANAGER_H_ | 107 #endif // CONTENT_COMMON_HOST_SHARED_BITMAP_MANAGER_H_ |
OLD | NEW |