| 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 "content/renderer/gamepad_shared_memory_reader.h" | 5 #include "content/renderer/gamepad_shared_memory_reader.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "content/common/gamepad_hardware_buffer.h" | 9 #include "content/common/gamepad_hardware_buffer.h" |
| 10 #include "content/common/gamepad_user_gesture.h" | 10 #include "content/common/gamepad_user_gesture.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // Clear the connected flag if the user hasn't interacted with any of the | 98 // Clear the connected flag if the user hasn't interacted with any of the |
| 99 // gamepads to prevent fingerprinting. The actual data is not cleared. | 99 // gamepads to prevent fingerprinting. The actual data is not cleared. |
| 100 // WebKit will only copy out data into the JS buffers for connected | 100 // WebKit will only copy out data into the JS buffers for connected |
| 101 // gamepads so this is sufficient. | 101 // gamepads so this is sufficient. |
| 102 for (unsigned i = 0; i < blink::WebGamepads::itemsLengthCap; i++) | 102 for (unsigned i = 0; i < blink::WebGamepads::itemsLengthCap; i++) |
| 103 gamepads.items[i].connected = false; | 103 gamepads.items[i].connected = false; |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 | 106 |
| 107 GamepadSharedMemoryReader::~GamepadSharedMemoryReader() { | 107 GamepadSharedMemoryReader::~GamepadSharedMemoryReader() { |
| 108 StopIfObserving(); |
| 108 } | 109 } |
| 109 | 110 |
| 110 bool GamepadSharedMemoryReader::OnControlMessageReceived( | 111 bool GamepadSharedMemoryReader::OnControlMessageReceived( |
| 111 const IPC::Message& message) { | 112 const IPC::Message& message) { |
| 112 bool handled = true; | 113 bool handled = true; |
| 113 IPC_BEGIN_MESSAGE_MAP(GamepadSharedMemoryReader, message) | 114 IPC_BEGIN_MESSAGE_MAP(GamepadSharedMemoryReader, message) |
| 114 IPC_MESSAGE_HANDLER(GamepadMsg_GamepadConnected, OnGamepadConnected) | 115 IPC_MESSAGE_HANDLER(GamepadMsg_GamepadConnected, OnGamepadConnected) |
| 115 IPC_MESSAGE_HANDLER(GamepadMsg_GamepadDisconnected, OnGamepadDisconnected) | 116 IPC_MESSAGE_HANDLER(GamepadMsg_GamepadDisconnected, OnGamepadDisconnected) |
| 116 IPC_MESSAGE_UNHANDLED(handled = false) | 117 IPC_MESSAGE_UNHANDLED(handled = false) |
| 117 IPC_END_MESSAGE_MAP() | 118 IPC_END_MESSAGE_MAP() |
| (...skipping 11 matching lines...) Expand all Loading... |
| 129 } | 130 } |
| 130 | 131 |
| 131 void GamepadSharedMemoryReader::OnGamepadDisconnected( | 132 void GamepadSharedMemoryReader::OnGamepadDisconnected( |
| 132 int index, | 133 int index, |
| 133 const blink::WebGamepad& gamepad) { | 134 const blink::WebGamepad& gamepad) { |
| 134 if (listener()) | 135 if (listener()) |
| 135 listener()->didDisconnectGamepad(index, gamepad); | 136 listener()->didDisconnectGamepad(index, gamepad); |
| 136 } | 137 } |
| 137 | 138 |
| 138 } // namespace content | 139 } // namespace content |
| OLD | NEW |