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

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

Issue 1154613006: Update pepper to not assume that SharedMemoryHandle is an int. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another nits pass. Created 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/pepper_compositor_host.h" 5 #include "content/renderer/pepper/pepper_compositor_host.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 return PP_ERROR_BADARGUMENT; 109 return PP_ERROR_BADARGUMENT;
110 } 110 }
111 111
112 // Make sure the source rect is not beyond the dimensions of the 112 // Make sure the source rect is not beyond the dimensions of the
113 // image. 113 // image.
114 if (!CheckPPFloatRect(new_layer->image->source_rect, 114 if (!CheckPPFloatRect(new_layer->image->source_rect,
115 desc.size.width, desc.size.height)) { 115 desc.size.width, desc.size.height)) {
116 return PP_ERROR_BADARGUMENT; 116 return PP_ERROR_BADARGUMENT;
117 } 117 }
118 118
119 int handle; 119 base::SharedMemoryHandle handle;
120 uint32_t byte_count; 120 uint32_t byte_count;
121 if (enter.object()->GetSharedMemory(&handle, &byte_count) != PP_OK) 121 if (enter.object()->GetSharedMemory(&handle, &byte_count) != PP_OK)
122 return PP_ERROR_FAILED; 122 return PP_ERROR_FAILED;
123 123
124 #if defined(OS_WIN) 124 #if defined(OS_WIN)
125 base::SharedMemoryHandle shm_handle; 125 base::SharedMemoryHandle shm_handle;
126 if (!::DuplicateHandle(::GetCurrentProcess(), 126 if (!::DuplicateHandle(::GetCurrentProcess(), handle, ::GetCurrentProcess(),
127 reinterpret_cast<base::SharedMemoryHandle>(handle), 127 &shm_handle, 0, FALSE, DUPLICATE_SAME_ACCESS)) {
128 ::GetCurrentProcess(),
129 &shm_handle,
130 0,
131 FALSE,
132 DUPLICATE_SAME_ACCESS)) {
133 return PP_ERROR_FAILED; 128 return PP_ERROR_FAILED;
134 } 129 }
135 #else 130 #else
136 base::SharedMemoryHandle shm_handle(dup(handle), false); 131 base::SharedMemoryHandle shm_handle =
132 base::SharedMemory::DeepCopyHandle(handle, false);
137 #endif 133 #endif
138 image_shm->reset(new base::SharedMemory(shm_handle, true)); 134 image_shm->reset(new base::SharedMemory(shm_handle, true));
139 if (!(*image_shm)->Map(desc.stride * desc.size.height)) { 135 if (!(*image_shm)->Map(desc.stride * desc.size.height)) {
140 image_shm->reset(); 136 image_shm->reset();
141 return PP_ERROR_NOMEMORY; 137 return PP_ERROR_NOMEMORY;
142 } 138 }
143 return PP_OK; 139 return PP_OK;
144 } 140 }
145 141
146 return PP_ERROR_BADARGUMENT; 142 return PP_ERROR_BADARGUMENT;
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 410
415 // If the host is not bound to the instance, return PP_OK immediately. 411 // If the host is not bound to the instance, return PP_OK immediately.
416 if (!bound_instance_) 412 if (!bound_instance_)
417 return PP_OK; 413 return PP_OK;
418 414
419 commit_layers_reply_context_ = context->MakeReplyMessageContext(); 415 commit_layers_reply_context_ = context->MakeReplyMessageContext();
420 return PP_OK_COMPLETIONPENDING; 416 return PP_OK_COMPLETIONPENDING;
421 } 417 }
422 418
423 } // namespace content 419 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698