| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // hardware thread is taking unusally long). | 96 // hardware thread is taking unusally long). |
| 97 if (contention_count < kMaximumContentionCount) | 97 if (contention_count < kMaximumContentionCount) |
| 98 ConvertWebKitGamepadData(read_into, &last_read_); | 98 ConvertWebKitGamepadData(read_into, &last_read_); |
| 99 | 99 |
| 100 memcpy(data, &last_read_, sizeof(PP_GamepadsSampleData)); | 100 memcpy(data, &last_read_, sizeof(PP_GamepadsSampleData)); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void GamepadResource::OnPluginMsgSendMemory( | 103 void GamepadResource::OnPluginMsgSendMemory( |
| 104 const ResourceMessageReplyParams& params) { | 104 const ResourceMessageReplyParams& params) { |
| 105 // On failure, the handle will be null and the CHECK below will be tripped. | 105 // On failure, the handle will be null and the CHECK below will be tripped. |
| 106 base::SharedMemoryHandle handle = base::SharedMemory::NULLHandle(); | 106 base::SharedMemoryHandle handle; |
| 107 params.TakeSharedMemoryHandleAtIndex(0, &handle); | 107 params.TakeSharedMemoryHandleAtIndex(0, &handle); |
| 108 | 108 |
| 109 shared_memory_.reset(new base::SharedMemory(handle, true)); | 109 shared_memory_.reset(new base::SharedMemory(handle, true)); |
| 110 CHECK(shared_memory_->Map(sizeof(ContentGamepadHardwareBuffer))); | 110 CHECK(shared_memory_->Map(sizeof(ContentGamepadHardwareBuffer))); |
| 111 buffer_ = static_cast<const ContentGamepadHardwareBuffer*>( | 111 buffer_ = static_cast<const ContentGamepadHardwareBuffer*>( |
| 112 shared_memory_->memory()); | 112 shared_memory_->memory()); |
| 113 } | 113 } |
| 114 | 114 |
| 115 } // namespace proxy | 115 } // namespace proxy |
| 116 } // namespace ppapi | 116 } // namespace ppapi |
| OLD | NEW |