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

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, 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 (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/ipc/shared_bitmap_manager.mojom.h"
21 #include "cc/resources/shared_bitmap_manager.h" 22 #include "cc/resources/shared_bitmap_manager.h"
22 #include "content/common/content_export.h" 23 #include "components/display_compositor/display_compositor_export.h"
24 #include "mojo/public/cpp/bindings/associated_binding.h"
23 25
24 namespace BASE_HASH_NAMESPACE { 26 namespace BASE_HASH_NAMESPACE {
25 template <> 27 template <>
26 struct hash<cc::SharedBitmapId> { 28 struct hash<cc::SharedBitmapId> {
27 size_t operator()(const cc::SharedBitmapId& id) const { 29 size_t operator()(const cc::SharedBitmapId& id) const {
28 return base::Hash(reinterpret_cast<const char*>(id.name), sizeof(id.name)); 30 return base::Hash(reinterpret_cast<const char*>(id.name), sizeof(id.name));
29 } 31 }
30 }; 32 };
31 } // namespace BASE_HASH_NAMESPACE 33 } // namespace BASE_HASH_NAMESPACE
32 34
33 namespace content { 35 namespace display_compositor {
34 class BitmapData; 36 class BitmapData;
35 class HostSharedBitmapManager; 37 class HostSharedBitmapManager;
36 38
37 class CONTENT_EXPORT HostSharedBitmapManagerClient { 39 class DISPLAY_COMPOSITOR_EXPORT HostSharedBitmapManagerClient
40 : NON_EXPORTED_BASE(public cc::mojom::SharedBitmapManager) {
38 public: 41 public:
39 explicit HostSharedBitmapManagerClient(HostSharedBitmapManager* manager); 42 explicit HostSharedBitmapManagerClient(HostSharedBitmapManager* manager);
40 43
41 ~HostSharedBitmapManagerClient(); 44 ~HostSharedBitmapManagerClient() override;
45
46 void Bind(cc::mojom::SharedBitmapManagerAssociatedRequest request);
47
48 // cc::mojom::SharedBitmapManager overrides:
49 void DidAllocateSharedBitmap(mojo::ScopedSharedBufferHandle buffer,
50 const cc::SharedBitmapId& id) override;
51 void DidDeleteSharedBitmap(const cc::SharedBitmapId& id) override;
42 52
43 void AllocateSharedBitmapForChild( 53 void AllocateSharedBitmapForChild(
44 base::ProcessHandle process_handle, 54 base::ProcessHandle process_handle,
45 size_t buffer_size, 55 size_t buffer_size,
46 const cc::SharedBitmapId& id, 56 const cc::SharedBitmapId& id,
47 base::SharedMemoryHandle* shared_memory_handle); 57 base::SharedMemoryHandle* shared_memory_handle);
48 void ChildAllocatedSharedBitmap(size_t buffer_size, 58 void ChildAllocatedSharedBitmap(size_t buffer_size,
49 const base::SharedMemoryHandle& handle, 59 const base::SharedMemoryHandle& handle,
50 const cc::SharedBitmapId& id); 60 const cc::SharedBitmapId& id);
51 void ChildDeletedSharedBitmap(const cc::SharedBitmapId& id);
52 61
53 private: 62 private:
54 HostSharedBitmapManager* manager_; 63 HostSharedBitmapManager* manager_;
64 mojo::AssociatedBinding<cc::mojom::SharedBitmapManager> binding_;
55 65
56 // Lock must be held around access to owned_bitmaps_. 66 // Lock must be held around access to owned_bitmaps_.
57 base::Lock lock_; 67 base::Lock lock_;
58 base::hash_set<cc::SharedBitmapId> owned_bitmaps_; 68 base::hash_set<cc::SharedBitmapId> owned_bitmaps_;
59 69
60 DISALLOW_COPY_AND_ASSIGN(HostSharedBitmapManagerClient); 70 DISALLOW_COPY_AND_ASSIGN(HostSharedBitmapManagerClient);
61 }; 71 };
62 72
63 class CONTENT_EXPORT HostSharedBitmapManager 73 class DISPLAY_COMPOSITOR_EXPORT HostSharedBitmapManager
64 : public cc::SharedBitmapManager, 74 : public cc::SharedBitmapManager,
65 public base::trace_event::MemoryDumpProvider { 75 public base::trace_event::MemoryDumpProvider {
66 public: 76 public:
67 HostSharedBitmapManager(); 77 HostSharedBitmapManager();
68 ~HostSharedBitmapManager() override; 78 ~HostSharedBitmapManager() override;
69 79
70 static HostSharedBitmapManager* current(); 80 static HostSharedBitmapManager* current();
71 81
72 // cc::SharedBitmapManager implementation. 82 // cc::SharedBitmapManager implementation.
73 std::unique_ptr<cc::SharedBitmap> AllocateSharedBitmap( 83 std::unique_ptr<cc::SharedBitmap> AllocateSharedBitmap(
(...skipping 18 matching lines...) Expand all
92 size_t buffer_size, 102 size_t buffer_size,
93 const cc::SharedBitmapId& id, 103 const cc::SharedBitmapId& id,
94 base::SharedMemoryHandle* shared_memory_handle); 104 base::SharedMemoryHandle* shared_memory_handle);
95 bool ChildAllocatedSharedBitmap(size_t buffer_size, 105 bool ChildAllocatedSharedBitmap(size_t buffer_size,
96 const base::SharedMemoryHandle& handle, 106 const base::SharedMemoryHandle& handle,
97 const cc::SharedBitmapId& id); 107 const cc::SharedBitmapId& id);
98 void ChildDeletedSharedBitmap(const cc::SharedBitmapId& id); 108 void ChildDeletedSharedBitmap(const cc::SharedBitmapId& id);
99 109
100 mutable base::Lock lock_; 110 mutable base::Lock lock_;
101 111
102 typedef base::hash_map<cc::SharedBitmapId, scoped_refptr<BitmapData> > 112 typedef base::hash_map<cc::SharedBitmapId, scoped_refptr<BitmapData>>
103 BitmapMap; 113 BitmapMap;
104 BitmapMap handle_map_; 114 BitmapMap handle_map_;
105 115
106 DISALLOW_COPY_AND_ASSIGN(HostSharedBitmapManager); 116 DISALLOW_COPY_AND_ASSIGN(HostSharedBitmapManager);
107 }; 117 };
108 118
109 } // namespace content 119 } // namespace display_compositor
110 120
111 #endif // CONTENT_COMMON_HOST_SHARED_BITMAP_MANAGER_H_ 121 #endif // COMPONENTS_DISPLAY_COMPOSITOR_HOST_SHARED_BITMAP_MANAGER_H_
OLDNEW
« no previous file with comments | « components/display_compositor/DEPS ('k') | components/display_compositor/host_shared_bitmap_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698