| 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/browser/gamepad/gamepad_service.h" | 5 #include "content/browser/gamepad/gamepad_service.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
| 12 #include "content/browser/gamepad/gamepad_consumer.h" | 12 #include "content/browser/gamepad/gamepad_consumer.h" |
| 13 #include "content/browser/gamepad/gamepad_data_fetcher.h" | 13 #include "content/browser/gamepad/gamepad_data_fetcher.h" |
| 14 #include "content/browser/gamepad/gamepad_provider.h" | 14 #include "content/browser/gamepad/gamepad_provider.h" |
| 15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 16 #include "content/public/browser/render_process_host.h" | 16 #include "content/public/browser/render_process_host.h" |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 GamepadService* g_gamepad_service = 0; | 21 GamepadService* g_gamepad_service = 0; |
| 22 } | 22 } |
| 23 | 23 |
| 24 GamepadService::GamepadService() | 24 GamepadService::GamepadService() |
| 25 : num_active_consumers_(0), | 25 : num_active_consumers_(0), |
| 26 gesture_callback_pending_(false) { | 26 gesture_callback_pending_(false) { |
| 27 SetInstance(this); | 27 SetInstance(this); |
| 28 } | 28 } |
| 29 | 29 |
| 30 GamepadService::GamepadService(scoped_ptr<GamepadDataFetcher> fetcher) | 30 GamepadService::GamepadService(std::unique_ptr<GamepadDataFetcher> fetcher) |
| 31 : provider_(new GamepadProvider(std::move(fetcher))), | 31 : provider_(new GamepadProvider(std::move(fetcher))), |
| 32 num_active_consumers_(0), | 32 num_active_consumers_(0), |
| 33 gesture_callback_pending_(false) { | 33 gesture_callback_pending_(false) { |
| 34 SetInstance(this); | 34 SetInstance(this); |
| 35 thread_checker_.DetachFromThread(); | 35 thread_checker_.DetachFromThread(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 GamepadService::~GamepadService() { | 38 GamepadService::~GamepadService() { |
| 39 SetInstance(NULL); | 39 SetInstance(NULL); |
| 40 } | 40 } |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 for (unsigned i = 0; i < blink::WebGamepads::itemsLengthCap; ++i) { | 153 for (unsigned i = 0; i < blink::WebGamepads::itemsLengthCap; ++i) { |
| 154 const blink::WebGamepad& pad = gamepads.items[i]; | 154 const blink::WebGamepad& pad = gamepads.items[i]; |
| 155 if (pad.connected) | 155 if (pad.connected) |
| 156 info.consumer->OnGamepadConnected(i, pad); | 156 info.consumer->OnGamepadConnected(i, pad); |
| 157 } | 157 } |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 } | 160 } |
| 161 | 161 |
| 162 } // namespace content | 162 } // namespace content |
| OLD | NEW |