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

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

Issue 2919253002: Don't move raw pointers in services (Closed)
Patch Set: Created 3 years, 6 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 #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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 ChildSharedBitmapManager::GetSharedBitmapFromId(const gfx::Size&, 132 ChildSharedBitmapManager::GetSharedBitmapFromId(const gfx::Size&,
133 const cc::SharedBitmapId&) { 133 const cc::SharedBitmapId&) {
134 NOTREACHED(); 134 NOTREACHED();
135 return nullptr; 135 return nullptr;
136 } 136 }
137 137
138 std::unique_ptr<cc::SharedBitmap> 138 std::unique_ptr<cc::SharedBitmap>
139 ChildSharedBitmapManager::GetBitmapForSharedMemory(base::SharedMemory* mem) { 139 ChildSharedBitmapManager::GetBitmapForSharedMemory(base::SharedMemory* mem) {
140 cc::SharedBitmapId id = cc::SharedBitmap::GenerateId(); 140 cc::SharedBitmapId id = cc::SharedBitmap::GenerateId();
141 NotifyAllocatedSharedBitmap(mem, cc::SharedBitmap::GenerateId()); 141 NotifyAllocatedSharedBitmap(mem, cc::SharedBitmap::GenerateId());
142 return base::MakeUnique<ChildSharedBitmap>(shared_bitmap_manager_ptr_, 142 return base::MakeUnique<ChildSharedBitmap>(shared_bitmap_manager_ptr_, mem,
143 std::move(mem), id); 143 id);
144 } 144 }
145 145
146 // Notifies the browser process that a shared bitmap with the given ID was 146 // Notifies the browser process that a shared bitmap with the given ID was
147 // allocated. Caller keeps ownership of |memory|. 147 // allocated. Caller keeps ownership of |memory|.
148 void ChildSharedBitmapManager::NotifyAllocatedSharedBitmap( 148 void ChildSharedBitmapManager::NotifyAllocatedSharedBitmap(
149 base::SharedMemory* memory, 149 base::SharedMemory* memory,
150 const cc::SharedBitmapId& id) { 150 const cc::SharedBitmapId& id) {
151 base::SharedMemoryHandle handle_to_send = 151 base::SharedMemoryHandle handle_to_send =
152 base::SharedMemory::DuplicateHandle(memory->handle()); 152 base::SharedMemory::DuplicateHandle(memory->handle());
153 if (!base::SharedMemory::IsHandleValid(handle_to_send)) { 153 if (!base::SharedMemory::IsHandleValid(handle_to_send)) {
154 LOG(ERROR) << "Failed to duplicate shared memory handle for bitmap."; 154 LOG(ERROR) << "Failed to duplicate shared memory handle for bitmap.";
155 return; 155 return;
156 } 156 }
157 157
158 mojo::ScopedSharedBufferHandle buffer_handle = mojo::WrapSharedMemoryHandle( 158 mojo::ScopedSharedBufferHandle buffer_handle = mojo::WrapSharedMemoryHandle(
159 handle_to_send, memory->mapped_size(), true /* read_only */); 159 handle_to_send, memory->mapped_size(), true /* read_only */);
160 160
161 (*shared_bitmap_manager_ptr_) 161 (*shared_bitmap_manager_ptr_)
162 ->DidAllocateSharedBitmap(std::move(buffer_handle), id); 162 ->DidAllocateSharedBitmap(std::move(buffer_handle), id);
163 } 163 }
164 164
165 } // namespace ui 165 } // namespace ui
OLDNEW
« no previous file with comments | « services/preferences/tracked/pref_hash_store_impl.cc ('k') | services/video_capture/test/mock_device_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698