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

Side by Side Diff: content/browser/renderer_host/pepper/pepper_gamepad_host.cc

Issue 11312017: Avoid leaking SerializedHandles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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
« no previous file with comments | « no previous file | content/browser/renderer_host/pepper/pepper_gamepad_host_unittest.cc » ('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) 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/browser/renderer_host/pepper/pepper_gamepad_host.h" 5 #include "content/browser/renderer_host/pepper/pepper_gamepad_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "content/browser/gamepad/gamepad_service.h" 8 #include "content/browser/gamepad/gamepad_service.h"
9 #include "content/public/browser/browser_ppapi_host.h" 9 #include "content/public/browser/browser_ppapi_host.h"
10 #include "ppapi/c/pp_errors.h" 10 #include "ppapi/c/pp_errors.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 // gamepad. This is to prevent fingerprinting and matches what the web 64 // gamepad. This is to prevent fingerprinting and matches what the web
65 // platform does. 65 // platform does.
66 gamepad_service_->RegisterForUserGesture( 66 gamepad_service_->RegisterForUserGesture(
67 base::Bind(&PepperGamepadHost::GotUserGesture, 67 base::Bind(&PepperGamepadHost::GotUserGesture,
68 weak_factory_.GetWeakPtr(), 68 weak_factory_.GetWeakPtr(),
69 context->MakeReplyMessageContext())); 69 context->MakeReplyMessageContext()));
70 return PP_OK_COMPLETIONPENDING; 70 return PP_OK_COMPLETIONPENDING;
71 } 71 }
72 72
73 void PepperGamepadHost::GotUserGesture( 73 void PepperGamepadHost::GotUserGesture(
74 const ppapi::host::ReplyMessageContext& in_context) { 74 const ppapi::host::ReplyMessageContext& context) {
75 base::SharedMemoryHandle handle = 75 base::SharedMemoryHandle handle =
76 gamepad_service_->GetSharedMemoryHandleForProcess( 76 gamepad_service_->GetSharedMemoryHandleForProcess(
77 browser_ppapi_host_->GetPluginProcessHandle()); 77 browser_ppapi_host_->GetPluginProcessHandle());
78 78
79 // The shared memory handle is sent in the params struct
80 // (in the reply context), so we have to make a copy to mutate it.
81 ppapi::host::ReplyMessageContext context = in_context;
82 context.params.AppendHandle(ppapi::proxy::SerializedHandle( 79 context.params.AppendHandle(ppapi::proxy::SerializedHandle(
83 handle, sizeof(ppapi::ContentGamepadHardwareBuffer))); 80 handle, sizeof(ppapi::ContentGamepadHardwareBuffer)));
84 host()->SendReply(context, PpapiPluginMsg_Gamepad_SendMemory()); 81 host()->SendReply(context, PpapiPluginMsg_Gamepad_SendMemory());
85 } 82 }
86 83
87 } // namespace content 84 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/pepper/pepper_gamepad_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698