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

Side by Side Diff: services/ui/public/cpp/bitmap/child_shared_bitmap_manager.cc

Issue 2535213002: [WIP] Add SharedMemoryTracker to dump base::SharedMemory usage
Patch Set: (rebase) Created 3 years, 7 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 | « media/video/gpu_memory_buffer_video_frame_pool.cc ('k') | ui/gfx/gpu_memory_buffer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "services/ui/public/cpp/bitmap/child_shared_bitmap_manager.h" 5 #include "services/ui/public/cpp/bitmap/child_shared_bitmap_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 13 matching lines...) Expand all
24 class ChildSharedBitmap : public cc::SharedBitmap { 24 class ChildSharedBitmap : public cc::SharedBitmap {
25 public: 25 public:
26 ChildSharedBitmap( 26 ChildSharedBitmap(
27 const scoped_refptr<cc::mojom::ThreadSafeSharedBitmapManagerAssociatedPtr> 27 const scoped_refptr<cc::mojom::ThreadSafeSharedBitmapManagerAssociatedPtr>
28 shared_bitmap_manager_ptr, 28 shared_bitmap_manager_ptr,
29 base::SharedMemory* shared_memory, 29 base::SharedMemory* shared_memory,
30 const cc::SharedBitmapId& id) 30 const cc::SharedBitmapId& id)
31 : cc::SharedBitmap(static_cast<uint8_t*>(shared_memory->memory()), id), 31 : cc::SharedBitmap(static_cast<uint8_t*>(shared_memory->memory()), id),
32 shared_bitmap_manager_ptr_(shared_bitmap_manager_ptr) {} 32 shared_bitmap_manager_ptr_(shared_bitmap_manager_ptr) {}
33 33
34 // TODO(hajimehoshi): shared bitmpa is not reffered in this case?
35
34 ChildSharedBitmap( 36 ChildSharedBitmap(
35 const scoped_refptr<cc::mojom::ThreadSafeSharedBitmapManagerAssociatedPtr> 37 const scoped_refptr<cc::mojom::ThreadSafeSharedBitmapManagerAssociatedPtr>
36 shared_bitmap_manager_ptr, 38 shared_bitmap_manager_ptr,
37 std::unique_ptr<base::SharedMemory> shared_memory_holder, 39 std::unique_ptr<base::SharedMemory> shared_memory_holder,
38 const cc::SharedBitmapId& id) 40 const cc::SharedBitmapId& id)
39 : ChildSharedBitmap(shared_bitmap_manager_ptr, 41 : ChildSharedBitmap(shared_bitmap_manager_ptr,
40 shared_memory_holder.get(), 42 shared_memory_holder.get(),
41 id) { 43 id) {
42 shared_memory_holder_ = std::move(shared_memory_holder); 44 shared_memory_holder_ = std::move(shared_memory_holder);
43 } 45 }
44 46
45 ~ChildSharedBitmap() override { 47 ~ChildSharedBitmap() override {
46 (*shared_bitmap_manager_ptr_)->DidDeleteSharedBitmap(id()); 48 (*shared_bitmap_manager_ptr_)->DidDeleteSharedBitmap(id());
47 } 49 }
48 50
51 base::SharedMemory* GetSharedMemory() const override {
52 return shared_memory_holder_.get();
53 }
54
49 private: 55 private:
50 scoped_refptr<cc::mojom::ThreadSafeSharedBitmapManagerAssociatedPtr> 56 scoped_refptr<cc::mojom::ThreadSafeSharedBitmapManagerAssociatedPtr>
51 shared_bitmap_manager_ptr_; 57 shared_bitmap_manager_ptr_;
52 std::unique_ptr<base::SharedMemory> shared_memory_holder_; 58 std::unique_ptr<base::SharedMemory> shared_memory_holder_;
53 }; 59 };
54 60
55 // Collect extra information for debugging bitmap creation failures. 61 // Collect extra information for debugging bitmap creation failures.
56 void CollectMemoryUsageAndDie(const gfx::Size& size, size_t alloc_size) { 62 void CollectMemoryUsageAndDie(const gfx::Size& size, size_t alloc_size) {
57 #if defined(OS_WIN) 63 #if defined(OS_WIN)
58 int width = size.width(); 64 int width = size.width();
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 } 162 }
157 163
158 mojo::ScopedSharedBufferHandle buffer_handle = mojo::WrapSharedMemoryHandle( 164 mojo::ScopedSharedBufferHandle buffer_handle = mojo::WrapSharedMemoryHandle(
159 handle_to_send, memory->mapped_size(), true /* read_only */); 165 handle_to_send, memory->mapped_size(), true /* read_only */);
160 166
161 (*shared_bitmap_manager_ptr_) 167 (*shared_bitmap_manager_ptr_)
162 ->DidAllocateSharedBitmap(std::move(buffer_handle), id); 168 ->DidAllocateSharedBitmap(std::move(buffer_handle), id);
163 } 169 }
164 170
165 } // namespace ui 171 } // namespace ui
OLDNEW
« no previous file with comments | « media/video/gpu_memory_buffer_video_frame_pool.cc ('k') | ui/gfx/gpu_memory_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698