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

Side by Side Diff: content/common/host_shared_bitmap_manager.h

Issue 955523005: Add HostSharedBitmapManagerClient to organize bitmaps coming from renderers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 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
(...skipping 11 matching lines...) Expand all
22 template <> 22 template <>
23 struct hash<cc::SharedBitmapId> { 23 struct hash<cc::SharedBitmapId> {
24 size_t operator()(const cc::SharedBitmapId& id) const { 24 size_t operator()(const cc::SharedBitmapId& id) const {
25 return base::Hash(reinterpret_cast<const char*>(id.name), sizeof(id.name)); 25 return base::Hash(reinterpret_cast<const char*>(id.name), sizeof(id.name));
26 } 26 }
27 }; 27 };
28 } // namespace BASE_HASH_NAMESPACE 28 } // namespace BASE_HASH_NAMESPACE
29 29
30 namespace content { 30 namespace content {
31 class BitmapData; 31 class BitmapData;
32 class HostSharedBitmapManager;
33
34 class CONTENT_EXPORT HostSharedBitmapManagerClient {
35 public:
36 explicit HostSharedBitmapManagerClient(HostSharedBitmapManager* manager);
37
38 ~HostSharedBitmapManagerClient();
39
40 void AllocateSharedBitmapForChild(
41 base::ProcessHandle process_handle,
42 size_t buffer_size,
43 const cc::SharedBitmapId& id,
44 base::SharedMemoryHandle* shared_memory_handle);
45 void ChildAllocatedSharedBitmap(size_t buffer_size,
46 const base::SharedMemoryHandle& handle,
47 base::ProcessHandle process_handle,
48 const cc::SharedBitmapId& id);
49 void ChildDeletedSharedBitmap(const cc::SharedBitmapId& id);
50
51 private:
52 HostSharedBitmapManager* manager_;
53 base::hash_set<cc::SharedBitmapId> owned_bitmaps_;
54
55 DISALLOW_COPY_AND_ASSIGN(HostSharedBitmapManagerClient);
56 };
32 57
33 class CONTENT_EXPORT HostSharedBitmapManager : public cc::SharedBitmapManager { 58 class CONTENT_EXPORT HostSharedBitmapManager : public cc::SharedBitmapManager {
34 public: 59 public:
35 HostSharedBitmapManager(); 60 HostSharedBitmapManager();
36 ~HostSharedBitmapManager() override; 61 ~HostSharedBitmapManager() override;
37 62
38 static HostSharedBitmapManager* current(); 63 static HostSharedBitmapManager* current();
39 64
40 // cc::SharedBitmapManager implementation. 65 // cc::SharedBitmapManager implementation.
41 scoped_ptr<cc::SharedBitmap> AllocateSharedBitmap( 66 scoped_ptr<cc::SharedBitmap> AllocateSharedBitmap(
42 const gfx::Size& size) override; 67 const gfx::Size& size) override;
43 scoped_ptr<cc::SharedBitmap> GetSharedBitmapFromId( 68 scoped_ptr<cc::SharedBitmap> GetSharedBitmapFromId(
44 const gfx::Size& size, 69 const gfx::Size& size,
45 const cc::SharedBitmapId&) override; 70 const cc::SharedBitmapId&) override;
46 71
72 size_t AllocatedBitmapCount() const;
73
74 void FreeSharedMemoryFromMap(const cc::SharedBitmapId& id);
75
76 private:
77 friend class HostSharedBitmapManagerClient;
78
47 void AllocateSharedBitmapForChild( 79 void AllocateSharedBitmapForChild(
48 base::ProcessHandle process_handle, 80 base::ProcessHandle process_handle,
49 size_t buffer_size, 81 size_t buffer_size,
50 const cc::SharedBitmapId& id, 82 const cc::SharedBitmapId& id,
51 base::SharedMemoryHandle* shared_memory_handle); 83 base::SharedMemoryHandle* shared_memory_handle);
52 void ChildAllocatedSharedBitmap(size_t buffer_size, 84 void ChildAllocatedSharedBitmap(size_t buffer_size,
53 const base::SharedMemoryHandle& handle, 85 const base::SharedMemoryHandle& handle,
54 base::ProcessHandle process_handle, 86 base::ProcessHandle process_handle,
55 const cc::SharedBitmapId& id); 87 const cc::SharedBitmapId& id);
56 void ChildDeletedSharedBitmap(const cc::SharedBitmapId& id); 88 void ChildDeletedSharedBitmap(const cc::SharedBitmapId& id);
57 void ProcessRemoved(base::ProcessHandle process_handle);
58 89
59 size_t AllocatedBitmapCount() const;
60
61 void FreeSharedMemoryFromMap(const cc::SharedBitmapId& id);
62
63 private:
64 mutable base::Lock lock_; 90 mutable base::Lock lock_;
65 91
66 typedef base::hash_map<cc::SharedBitmapId, scoped_refptr<BitmapData> > 92 typedef base::hash_map<cc::SharedBitmapId, scoped_refptr<BitmapData> >
67 BitmapMap; 93 BitmapMap;
68 BitmapMap handle_map_; 94 BitmapMap handle_map_;
69 95
70 typedef base::hash_map<base::ProcessHandle, 96 DISALLOW_COPY_AND_ASSIGN(HostSharedBitmapManager);
71 base::hash_set<cc::SharedBitmapId> > ProcessMap;
72 ProcessMap process_map_;
73 }; 97 };
74 98
75 } // namespace content 99 } // namespace content
76 100
77 #endif // CONTENT_COMMON_HOST_SHARED_BITMAP_MANAGER_H_ 101 #endif // CONTENT_COMMON_HOST_SHARED_BITMAP_MANAGER_H_
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura_unittest.cc ('k') | content/common/host_shared_bitmap_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698