Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 base::Bind(&GamepadResource::OnPluginMsgSendMemory, this)); | 55 base::Bind(&GamepadResource::OnPluginMsgSendMemory, this)); |
| 56 } | 56 } |
| 57 | 57 |
| 58 GamepadResource::~GamepadResource() { | 58 GamepadResource::~GamepadResource() { |
| 59 } | 59 } |
| 60 | 60 |
| 61 thunk::PPB_Gamepad_API* GamepadResource::AsPPB_Gamepad_API() { | 61 thunk::PPB_Gamepad_API* GamepadResource::AsPPB_Gamepad_API() { |
| 62 return this; | 62 return this; |
| 63 } | 63 } |
| 64 | 64 |
| 65 void GamepadResource::Sample(PP_GamepadsSampleData* data) { | 65 void GamepadResource::Sample(PP_Instance instance, |
|
dmichael (off chromium)
2013/03/19 19:01:06
see other nit
teravest
2013/03/19 19:39:33
Done.
| |
| 66 PP_GamepadsSampleData* data) { | |
| 66 if (!buffer_) { | 67 if (!buffer_) { |
| 67 // Browser hasn't sent back our shared memory, give the plugin gamepad | 68 // Browser hasn't sent back our shared memory, give the plugin gamepad |
| 68 // data corresponding to "not connected". | 69 // data corresponding to "not connected". |
| 69 memset(data, 0, sizeof(PP_GamepadsSampleData)); | 70 memset(data, 0, sizeof(PP_GamepadsSampleData)); |
| 70 return; | 71 return; |
| 71 } | 72 } |
| 72 | 73 |
| 73 // ========== | 74 // ========== |
| 74 // DANGER | 75 // DANGER |
| 75 // ========== | 76 // ========== |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 106 params.TakeSharedMemoryHandleAtIndex(0, &handle); | 107 params.TakeSharedMemoryHandleAtIndex(0, &handle); |
| 107 | 108 |
| 108 shared_memory_.reset(new base::SharedMemory(handle, true)); | 109 shared_memory_.reset(new base::SharedMemory(handle, true)); |
| 109 CHECK(shared_memory_->Map(sizeof(ContentGamepadHardwareBuffer))); | 110 CHECK(shared_memory_->Map(sizeof(ContentGamepadHardwareBuffer))); |
| 110 buffer_ = static_cast<const ContentGamepadHardwareBuffer*>( | 111 buffer_ = static_cast<const ContentGamepadHardwareBuffer*>( |
| 111 shared_memory_->memory()); | 112 shared_memory_->memory()); |
| 112 } | 113 } |
| 113 | 114 |
| 114 } // namespace proxy | 115 } // namespace proxy |
| 115 } // namespace ppapi | 116 } // namespace ppapi |
| OLD | NEW |