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

Side by Side Diff: content/common/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
« no previous file with comments | « content/common/BUILD.gn ('k') | content/common/host_shared_bitmap_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_COMMON_HOST_SHARED_BITMAP_MANAGER_H_
6 #define CONTENT_COMMON_HOST_SHARED_BITMAP_MANAGER_H_
7
8 #include <stddef.h>
9
10 #include <map>
11 #include <memory>
12 #include <set>
13
14 #include "base/containers/hash_tables.h"
15 #include "base/hash.h"
16 #include "base/macros.h"
17 #include "base/memory/ref_counted.h"
18 #include "base/memory/shared_memory.h"
19 #include "base/synchronization/lock.h"
20 #include "base/trace_event/memory_dump_provider.h"
21 #include "cc/resources/shared_bitmap_manager.h"
22 #include "content/common/content_export.h"
23
24 namespace BASE_HASH_NAMESPACE {
25 template <>
26 struct hash<cc::SharedBitmapId> {
27 size_t operator()(const cc::SharedBitmapId& id) const {
28 return base::Hash(reinterpret_cast<const char*>(id.name), sizeof(id.name));
29 }
30 };
31 } // namespace BASE_HASH_NAMESPACE
32
33 namespace content {
34 class BitmapData;
35 class HostSharedBitmapManager;
36
37 class CONTENT_EXPORT HostSharedBitmapManagerClient {
38 public:
39 explicit HostSharedBitmapManagerClient(HostSharedBitmapManager* manager);
40
41 ~HostSharedBitmapManagerClient();
42
43 void AllocateSharedBitmapForChild(
44 base::ProcessHandle process_handle,
45 size_t buffer_size,
46 const cc::SharedBitmapId& id,
47 base::SharedMemoryHandle* shared_memory_handle);
48 void ChildAllocatedSharedBitmap(size_t buffer_size,
49 const base::SharedMemoryHandle& handle,
50 const cc::SharedBitmapId& id);
51 void ChildDeletedSharedBitmap(const cc::SharedBitmapId& id);
52
53 private:
54 HostSharedBitmapManager* manager_;
55
56 // Lock must be held around access to owned_bitmaps_.
57 base::Lock lock_;
58 base::hash_set<cc::SharedBitmapId> owned_bitmaps_;
59
60 DISALLOW_COPY_AND_ASSIGN(HostSharedBitmapManagerClient);
61 };
62
63 class CONTENT_EXPORT HostSharedBitmapManager
64 : public cc::SharedBitmapManager,
65 public base::trace_event::MemoryDumpProvider {
66 public:
67 HostSharedBitmapManager();
68 ~HostSharedBitmapManager() override;
69
70 static HostSharedBitmapManager* current();
71
72 // cc::SharedBitmapManager implementation.
73 std::unique_ptr<cc::SharedBitmap> AllocateSharedBitmap(
74 const gfx::Size& size) override;
75 std::unique_ptr<cc::SharedBitmap> GetSharedBitmapFromId(
76 const gfx::Size& size,
77 const cc::SharedBitmapId&) override;
78
79 // base::trace_event::MemoryDumpProvider implementation.
80 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
81 base::trace_event::ProcessMemoryDump* pmd) override;
82
83 size_t AllocatedBitmapCount() const;
84
85 void FreeSharedMemoryFromMap(const cc::SharedBitmapId& id);
86
87 private:
88 friend class HostSharedBitmapManagerClient;
89
90 void AllocateSharedBitmapForChild(
91 base::ProcessHandle process_handle,
92 size_t buffer_size,
93 const cc::SharedBitmapId& id,
94 base::SharedMemoryHandle* shared_memory_handle);
95 bool ChildAllocatedSharedBitmap(size_t buffer_size,
96 const base::SharedMemoryHandle& handle,
97 const cc::SharedBitmapId& id);
98 void ChildDeletedSharedBitmap(const cc::SharedBitmapId& id);
99
100 mutable base::Lock lock_;
101
102 typedef base::hash_map<cc::SharedBitmapId, scoped_refptr<BitmapData> >
103 BitmapMap;
104 BitmapMap handle_map_;
105
106 DISALLOW_COPY_AND_ASSIGN(HostSharedBitmapManager);
107 };
108
109 } // namespace content
110
111 #endif // CONTENT_COMMON_HOST_SHARED_BITMAP_MANAGER_H_
OLDNEW
« no previous file with comments | « content/common/BUILD.gn ('k') | content/common/host_shared_bitmap_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698