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

Side by Side Diff: ppapi/proxy/gamepad_resource.cc

Issue 11312017: Avoid leaking SerializedHandles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 | Annotate | Revision Log
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 "ppapi/proxy/gamepad_resource.h" 5 #include "ppapi/proxy/gamepad_resource.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/threading/platform_thread.h" 10 #include "base/threading/platform_thread.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // hardware thread is taking unusally long). 91 // hardware thread is taking unusally long).
92 if (contention_count < kMaximumContentionCount) 92 if (contention_count < kMaximumContentionCount)
93 ConvertWebKitGamepadData(read_into, &last_read_); 93 ConvertWebKitGamepadData(read_into, &last_read_);
94 94
95 memcpy(data, &last_read_, sizeof(PP_GamepadsSampleData)); 95 memcpy(data, &last_read_, sizeof(PP_GamepadsSampleData));
96 } 96 }
97 97
98 void GamepadResource::OnPluginMsgSendMemory( 98 void GamepadResource::OnPluginMsgSendMemory(
99 const ResourceMessageReplyParams& params) { 99 const ResourceMessageReplyParams& params) {
100 // On failure, the handle will be null and the CHECK below will be tripped. 100 // On failure, the handle will be null and the CHECK below will be tripped.
101 base::SharedMemoryHandle handle; 101 base::SharedMemoryHandle handle = base::SharedMemory::NULLHandle();
102 params.GetSharedMemoryHandleAtIndex(0, &handle); 102 params.TakeSharedMemoryHandleAtIndex(0, &handle);
103 103
104 shared_memory_.reset(new base::SharedMemory(handle, true)); 104 shared_memory_.reset(new base::SharedMemory(handle, true));
105 CHECK(shared_memory_->Map(sizeof(ContentGamepadHardwareBuffer))); 105 CHECK(shared_memory_->Map(sizeof(ContentGamepadHardwareBuffer)));
106 buffer_ = static_cast<const ContentGamepadHardwareBuffer*>( 106 buffer_ = static_cast<const ContentGamepadHardwareBuffer*>(
107 shared_memory_->memory()); 107 shared_memory_->memory());
108 } 108 }
109 109
110 } // namespace proxy 110 } // namespace proxy
111 } // namespace ppapi 111 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698