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 30 matching lines...) Expand all Loading... |
41 return base::subtle::Release_Load(sequence) != version; | 41 return base::subtle::Release_Load(sequence) != version; |
42 } | 42 } |
43 | 43 |
44 } // namespace | 44 } // namespace |
45 | 45 |
46 GamepadResource::GamepadResource(Connection connection, PP_Instance instance) | 46 GamepadResource::GamepadResource(Connection connection, PP_Instance instance) |
47 : PluginResource(connection, instance), | 47 : PluginResource(connection, instance), |
48 buffer_(NULL) { | 48 buffer_(NULL) { |
49 memset(&last_read_, 0, sizeof(last_read_)); | 49 memset(&last_read_, 0, sizeof(last_read_)); |
50 | 50 |
51 SendCreateToBrowser(PpapiHostMsg_Gamepad_Create()); | 51 SendCreate(BROWSER, PpapiHostMsg_Gamepad_Create()); |
52 CallBrowser<PpapiPluginMsg_Gamepad_SendMemory>( | 52 Call<PpapiPluginMsg_Gamepad_SendMemory>( |
| 53 BROWSER, |
53 PpapiHostMsg_Gamepad_RequestMemory(), | 54 PpapiHostMsg_Gamepad_RequestMemory(), |
54 base::Bind(&GamepadResource::OnPluginMsgSendMemory, this)); | 55 base::Bind(&GamepadResource::OnPluginMsgSendMemory, this)); |
55 } | 56 } |
56 | 57 |
57 GamepadResource::~GamepadResource() { | 58 GamepadResource::~GamepadResource() { |
58 } | 59 } |
59 | 60 |
60 void GamepadResource::Sample(PP_GamepadsSampleData* data) { | 61 void GamepadResource::Sample(PP_GamepadsSampleData* data) { |
61 if (!buffer_) { | 62 if (!buffer_) { |
62 // Browser hasn't sent back our shared memory, give the plugin gamepad | 63 // Browser hasn't sent back our shared memory, give the plugin gamepad |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 params.GetSharedMemoryHandleAtIndex(0, &handle); | 102 params.GetSharedMemoryHandleAtIndex(0, &handle); |
102 | 103 |
103 shared_memory_.reset(new base::SharedMemory(handle, true)); | 104 shared_memory_.reset(new base::SharedMemory(handle, true)); |
104 CHECK(shared_memory_->Map(sizeof(ContentGamepadHardwareBuffer))); | 105 CHECK(shared_memory_->Map(sizeof(ContentGamepadHardwareBuffer))); |
105 buffer_ = static_cast<const ContentGamepadHardwareBuffer*>( | 106 buffer_ = static_cast<const ContentGamepadHardwareBuffer*>( |
106 shared_memory_->memory()); | 107 shared_memory_->memory()); |
107 } | 108 } |
108 | 109 |
109 } // namespace proxy | 110 } // namespace proxy |
110 } // namespace ppapi | 111 } // namespace ppapi |
OLD | NEW |