Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/renderer_host/gamepad_monitor.h" | 5 #include "device/gamepad/gamepad_monitor.h" |
| 6 | 6 |
| 7 #include "base/memory/shared_memory.h" | 7 #include "base/memory/shared_memory.h" |
| 8 #include "content/browser/gamepad/gamepad_service.h" | 8 #include "device/gamepad/gamepad_service.h" |
| 9 #include "content/common/gamepad_hardware_buffer.h" | 9 #include "device/gamepad/gamepad_shared_buffer.h" |
| 10 #include "content/public/browser/browser_thread.h" | |
| 11 #include "mojo/public/cpp/bindings/strong_binding.h" | 10 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 12 | 11 |
| 13 namespace content { | 12 namespace device { |
| 14 | 13 |
| 15 GamepadMonitor::GamepadMonitor() : is_started_(false) {} | 14 GamepadMonitor::GamepadMonitor() : is_started_(false) {} |
| 16 | 15 |
| 17 GamepadMonitor::~GamepadMonitor() { | 16 GamepadMonitor::~GamepadMonitor() { |
| 18 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
|
ke.he
2016/12/09 07:44:55
GamepadMonitor is created in "StrongBinding" way,
| |
| 19 if (is_started_) | 17 if (is_started_) |
| 20 GamepadService::GetInstance()->RemoveConsumer(this); | 18 GamepadService::GetInstance()->RemoveConsumer(this); |
| 21 } | 19 } |
| 22 | 20 |
| 23 // static | 21 // static |
| 24 void GamepadMonitor::Create(device::mojom::GamepadMonitorRequest request) { | 22 void GamepadMonitor::Create(mojom::GamepadMonitorRequest request) { |
| 25 mojo::MakeStrongBinding(base::MakeUnique<GamepadMonitor>(), | 23 mojo::MakeStrongBinding(base::MakeUnique<GamepadMonitor>(), |
| 26 std::move(request)); | 24 std::move(request)); |
| 27 } | 25 } |
| 28 | 26 |
| 29 void GamepadMonitor::OnGamepadConnected(unsigned index, | 27 void GamepadMonitor::OnGamepadConnected(unsigned index, |
| 30 const blink::WebGamepad& gamepad) { | 28 const blink::WebGamepad& gamepad) { |
| 31 if (gamepad_observer_) | 29 if (gamepad_observer_) |
| 32 gamepad_observer_->GamepadConnected(index, gamepad); | 30 gamepad_observer_->GamepadConnected(index, gamepad); |
| 33 } | 31 } |
| 34 | 32 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 50 | 48 |
| 51 void GamepadMonitor::GamepadStopPolling( | 49 void GamepadMonitor::GamepadStopPolling( |
| 52 const GamepadStopPollingCallback& callback) { | 50 const GamepadStopPollingCallback& callback) { |
| 53 DCHECK(is_started_); | 51 DCHECK(is_started_); |
| 54 is_started_ = false; | 52 is_started_ = false; |
| 55 | 53 |
| 56 GamepadService::GetInstance()->ConsumerBecameInactive(this); | 54 GamepadService::GetInstance()->ConsumerBecameInactive(this); |
| 57 callback.Run(); | 55 callback.Run(); |
| 58 } | 56 } |
| 59 | 57 |
| 60 void GamepadMonitor::SetObserver( | 58 void GamepadMonitor::SetObserver(mojom::GamepadObserverPtr gamepad_observer) { |
| 61 device::mojom::GamepadObserverPtr gamepad_observer) { | |
| 62 gamepad_observer_ = std::move(gamepad_observer); | 59 gamepad_observer_ = std::move(gamepad_observer); |
| 63 } | 60 } |
| 64 | 61 |
| 65 } // namespace content | 62 } // namespace device |
| OLD | NEW |