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

Side by Side Diff: components/display_compositor/host_shared_bitmap_manager.h

Issue 2717213004: Move SharedBitmapManager implementation out of content/ (Closed)
Patch Set: rebase Created 3 years, 9 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 (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 COMPONENTS_DISPLAY_COMPOSITOR_HOST_SHARED_BITMAP_MANAGER_H_
6 #define CONTENT_COMMON_HOST_SHARED_BITMAP_MANAGER_H_ 6 #define COMPONENTS_DISPLAY_COMPOSITOR_HOST_SHARED_BITMAP_MANAGER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 #include <set> 12 #include <set>
13 13
14 #include "base/containers/hash_tables.h" 14 #include "base/containers/hash_tables.h"
15 #include "base/hash.h" 15 #include "base/hash.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "base/memory/shared_memory.h" 18 #include "base/memory/shared_memory.h"
19 #include "base/synchronization/lock.h" 19 #include "base/synchronization/lock.h"
20 #include "base/trace_event/memory_dump_provider.h" 20 #include "base/trace_event/memory_dump_provider.h"
21 #include "cc/resources/shared_bitmap_manager.h" 21 #include "cc/resources/shared_bitmap_manager.h"
22 #include "content/common/content_export.h" 22 #include "components/display_compositor/display_compositor_export.h"
23 #include "components/display_compositor/interfaces/shared_bitmap_manager.mojom.h "
23 24
24 namespace BASE_HASH_NAMESPACE { 25 namespace BASE_HASH_NAMESPACE {
25 template <> 26 template <>
26 struct hash<cc::SharedBitmapId> { 27 struct hash<cc::SharedBitmapId> {
27 size_t operator()(const cc::SharedBitmapId& id) const { 28 size_t operator()(const cc::SharedBitmapId& id) const {
28 return base::Hash(reinterpret_cast<const char*>(id.name), sizeof(id.name)); 29 return base::Hash(reinterpret_cast<const char*>(id.name), sizeof(id.name));
29 } 30 }
30 }; 31 };
31 } // namespace BASE_HASH_NAMESPACE 32 } // namespace BASE_HASH_NAMESPACE
32 33
33 namespace content { 34 namespace display_compositor {
34 class BitmapData; 35 class BitmapData;
35 class HostSharedBitmapManager; 36 class HostSharedBitmapManager;
36 37
37 class CONTENT_EXPORT HostSharedBitmapManagerClient { 38 class DISPLAY_COMPOSITOR_EXPORT HostSharedBitmapManagerClient {
38 public: 39 public:
39 explicit HostSharedBitmapManagerClient(HostSharedBitmapManager* manager); 40 explicit HostSharedBitmapManagerClient(HostSharedBitmapManager* manager);
40 41
41 ~HostSharedBitmapManagerClient(); 42 ~HostSharedBitmapManagerClient();
42 43
44 void Bind(mojom::SharedBitmapManagerRequest request);
45
43 void AllocateSharedBitmapForChild( 46 void AllocateSharedBitmapForChild(
44 base::ProcessHandle process_handle, 47 base::ProcessHandle process_handle,
45 size_t buffer_size, 48 size_t buffer_size,
46 const cc::SharedBitmapId& id, 49 const cc::SharedBitmapId& id,
47 base::SharedMemoryHandle* shared_memory_handle); 50 base::SharedMemoryHandle* shared_memory_handle);
48 void ChildAllocatedSharedBitmap(size_t buffer_size, 51 void ChildAllocatedSharedBitmap(size_t buffer_size,
49 const base::SharedMemoryHandle& handle, 52 const base::SharedMemoryHandle& handle,
50 const cc::SharedBitmapId& id); 53 const cc::SharedBitmapId& id);
51 void ChildDeletedSharedBitmap(const cc::SharedBitmapId& id); 54 void ChildDeletedSharedBitmap(const cc::SharedBitmapId& id);
52 55
53 private: 56 private:
54 HostSharedBitmapManager* manager_; 57 HostSharedBitmapManager* manager_;
55 58
56 // Lock must be held around access to owned_bitmaps_. 59 // Lock must be held around access to owned_bitmaps_.
57 base::Lock lock_; 60 base::Lock lock_;
58 base::hash_set<cc::SharedBitmapId> owned_bitmaps_; 61 base::hash_set<cc::SharedBitmapId> owned_bitmaps_;
59 62
60 DISALLOW_COPY_AND_ASSIGN(HostSharedBitmapManagerClient); 63 DISALLOW_COPY_AND_ASSIGN(HostSharedBitmapManagerClient);
61 }; 64 };
62 65
63 class CONTENT_EXPORT HostSharedBitmapManager 66 class DISPLAY_COMPOSITOR_EXPORT HostSharedBitmapManager
64 : public cc::SharedBitmapManager, 67 : public cc::SharedBitmapManager,
65 public base::trace_event::MemoryDumpProvider { 68 public base::trace_event::MemoryDumpProvider {
66 public: 69 public:
67 HostSharedBitmapManager(); 70 HostSharedBitmapManager();
68 ~HostSharedBitmapManager() override; 71 ~HostSharedBitmapManager() override;
69 72
70 static HostSharedBitmapManager* current(); 73 static HostSharedBitmapManager* current();
71 74
72 // cc::SharedBitmapManager implementation. 75 // cc::SharedBitmapManager implementation.
73 std::unique_ptr<cc::SharedBitmap> AllocateSharedBitmap( 76 std::unique_ptr<cc::SharedBitmap> AllocateSharedBitmap(
(...skipping 18 matching lines...) Expand all
92 size_t buffer_size, 95 size_t buffer_size,
93 const cc::SharedBitmapId& id, 96 const cc::SharedBitmapId& id,
94 base::SharedMemoryHandle* shared_memory_handle); 97 base::SharedMemoryHandle* shared_memory_handle);
95 bool ChildAllocatedSharedBitmap(size_t buffer_size, 98 bool ChildAllocatedSharedBitmap(size_t buffer_size,
96 const base::SharedMemoryHandle& handle, 99 const base::SharedMemoryHandle& handle,
97 const cc::SharedBitmapId& id); 100 const cc::SharedBitmapId& id);
98 void ChildDeletedSharedBitmap(const cc::SharedBitmapId& id); 101 void ChildDeletedSharedBitmap(const cc::SharedBitmapId& id);
99 102
100 mutable base::Lock lock_; 103 mutable base::Lock lock_;
101 104
102 typedef base::hash_map<cc::SharedBitmapId, scoped_refptr<BitmapData> > 105 typedef base::hash_map<cc::SharedBitmapId, scoped_refptr<BitmapData>>
103 BitmapMap; 106 BitmapMap;
104 BitmapMap handle_map_; 107 BitmapMap handle_map_;
105 108
106 DISALLOW_COPY_AND_ASSIGN(HostSharedBitmapManager); 109 DISALLOW_COPY_AND_ASSIGN(HostSharedBitmapManager);
107 }; 110 };
108 111
109 } // namespace content 112 } // namespace display_compositor
110 113
111 #endif // CONTENT_COMMON_HOST_SHARED_BITMAP_MANAGER_H_ 114 #endif // COMPONENTS_DISPLAY_COMPOSITOR_HOST_SHARED_BITMAP_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698