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

Side by Side Diff: content/renderer/pepper/ppb_image_data_impl.cc

Issue 2847033003: Get rid of SharedMemory::GiveToProcess. (Closed)
Patch Set: Comments from avi. 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 | « content/browser/renderer_host/render_message_filter.cc ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/renderer/pepper/ppb_image_data_impl.h" 5 #include "content/renderer/pepper/ppb_image_data_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <memory> 9 #include <memory>
10 10
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 width_ = width; 140 width_ = width;
141 height_ = height; 141 height_ = height;
142 uint32_t buffer_size = width_ * height_ * 4; 142 uint32_t buffer_size = width_ * height_ * 4;
143 std::unique_ptr<base::SharedMemory> shared_memory = 143 std::unique_ptr<base::SharedMemory> shared_memory =
144 RenderThread::Get()->HostAllocateSharedMemoryBuffer(buffer_size); 144 RenderThread::Get()->HostAllocateSharedMemoryBuffer(buffer_size);
145 if (!shared_memory) 145 if (!shared_memory)
146 return false; 146 return false;
147 147
148 // The TransportDIB is always backed by shared memory, so give the shared 148 // The TransportDIB is always backed by shared memory, so give the shared
149 // memory handle to it. 149 // memory handle to it.
150 base::SharedMemoryHandle handle; 150 base::SharedMemoryHandle handle = shared_memory->handle().Duplicate();
151 if (!shared_memory->GiveToProcess(base::GetCurrentProcessHandle(), &handle)) 151 shared_memory->Unmap();
152 shared_memory->Close();
153 if (!handle.IsValid())
152 return false; 154 return false;
153 155
154 dib_.reset(TransportDIB::CreateWithHandle(handle)); 156 dib_.reset(TransportDIB::CreateWithHandle(handle));
155 157
156 return !!dib_; 158 return !!dib_;
157 } 159 }
158 160
159 bool ImageDataPlatformBackend::IsMapped() const { 161 bool ImageDataPlatformBackend::IsMapped() const {
160 return !!mapped_canvas_.get(); 162 return !!mapped_canvas_.get();
161 } 163 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 return skia_canvas_.get(); 267 return skia_canvas_.get();
266 } 268 }
267 269
268 SkBitmap ImageDataSimpleBackend::GetMappedBitmap() const { 270 SkBitmap ImageDataSimpleBackend::GetMappedBitmap() const {
269 if (!IsMapped()) 271 if (!IsMapped())
270 return SkBitmap(); 272 return SkBitmap();
271 return skia_bitmap_; 273 return skia_bitmap_;
272 } 274 }
273 275
274 } // namespace content 276 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_message_filter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698