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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 SendCreate(BROWSER, PpapiHostMsg_Gamepad_Create()); | 51 SendCreate(BROWSER, PpapiHostMsg_Gamepad_Create()); |
52 Call<PpapiPluginMsg_Gamepad_SendMemory>( | 52 Call<PpapiPluginMsg_Gamepad_SendMemory>( |
53 BROWSER, | 53 BROWSER, |
54 PpapiHostMsg_Gamepad_RequestMemory(), | 54 PpapiHostMsg_Gamepad_RequestMemory(), |
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() { |
| 62 return this; |
| 63 } |
| 64 |
61 void GamepadResource::Sample(PP_GamepadsSampleData* data) { | 65 void GamepadResource::Sample(PP_GamepadsSampleData* data) { |
62 if (!buffer_) { | 66 if (!buffer_) { |
63 // Browser hasn't sent back our shared memory, give the plugin gamepad | 67 // Browser hasn't sent back our shared memory, give the plugin gamepad |
64 // data corresponding to "not connected". | 68 // data corresponding to "not connected". |
65 memset(data, 0, sizeof(PP_GamepadsSampleData)); | 69 memset(data, 0, sizeof(PP_GamepadsSampleData)); |
66 return; | 70 return; |
67 } | 71 } |
68 | 72 |
69 // ========== | 73 // ========== |
70 // DANGER | 74 // DANGER |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 params.TakeSharedMemoryHandleAtIndex(0, &handle); | 106 params.TakeSharedMemoryHandleAtIndex(0, &handle); |
103 | 107 |
104 shared_memory_.reset(new base::SharedMemory(handle, true)); | 108 shared_memory_.reset(new base::SharedMemory(handle, true)); |
105 CHECK(shared_memory_->Map(sizeof(ContentGamepadHardwareBuffer))); | 109 CHECK(shared_memory_->Map(sizeof(ContentGamepadHardwareBuffer))); |
106 buffer_ = static_cast<const ContentGamepadHardwareBuffer*>( | 110 buffer_ = static_cast<const ContentGamepadHardwareBuffer*>( |
107 shared_memory_->memory()); | 111 shared_memory_->memory()); |
108 } | 112 } |
109 | 113 |
110 } // namespace proxy | 114 } // namespace proxy |
111 } // namespace ppapi | 115 } // namespace ppapi |
OLD | NEW |