Chromium Code Reviews| 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/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
| 13 #include "content/browser/gamepad/gamepad_shared_buffer_impl.h" | 13 #include "content/browser/gamepad/gamepad_shared_buffer_impl.h" |
| 14 #include "content/common/gamepad_hardware_buffer.h" | |
| 14 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 15 #include "content/public/browser/render_process_host.h" | 16 #include "content/public/browser/render_process_host.h" |
| 16 #include "device/gamepad/gamepad_consumer.h" | 17 #include "device/gamepad/gamepad_consumer.h" |
| 17 #include "device/gamepad/gamepad_data_fetcher.h" | 18 #include "device/gamepad/gamepad_data_fetcher.h" |
| 18 #include "device/gamepad/gamepad_provider.h" | 19 #include "device/gamepad/gamepad_provider.h" |
| 19 | 20 |
| 20 namespace content { | 21 namespace content { |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 GamepadService* g_gamepad_service = 0; | 24 GamepadService* g_gamepad_service = 0; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 it->consumer->OnGamepadDisconnected(index, pad); | 147 it->consumer->OnGamepadDisconnected(index, pad); |
| 147 } | 148 } |
| 148 } | 149 } |
| 149 | 150 |
| 150 base::SharedMemoryHandle GamepadService::GetSharedMemoryHandleForProcess( | 151 base::SharedMemoryHandle GamepadService::GetSharedMemoryHandleForProcess( |
| 151 base::ProcessHandle handle) { | 152 base::ProcessHandle handle) { |
| 152 DCHECK(thread_checker_.CalledOnValidThread()); | 153 DCHECK(thread_checker_.CalledOnValidThread()); |
| 153 return provider_->GetSharedMemoryHandleForProcess(handle); | 154 return provider_->GetSharedMemoryHandleForProcess(handle); |
| 154 } | 155 } |
| 155 | 156 |
| 157 mojo::ScopedSharedBufferHandle GamepadService::GetSharedMemoryHandle() { | |
| 158 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 159 | |
| 160 // TODO(heke): Use mojo::SharedBuffer rather than base::Sharedmemory in | |
| 161 // GamepadSharedBuffer. See crbug.com/670655 for details. | |
| 162 return mojo::WrapSharedMemoryHandle(provider_->GetSharedMemoryHandle(), | |
|
ke.he
2016/12/06 09:51:27
We add the "mojo::WrapSharedMemoryHandle(...)" her
| |
| 163 sizeof(GamepadHardwareBuffer), | |
| 164 true /* read_only */); | |
| 165 } | |
| 166 | |
| 156 void GamepadService::OnUserGesture() { | 167 void GamepadService::OnUserGesture() { |
| 157 DCHECK(thread_checker_.CalledOnValidThread()); | 168 DCHECK(thread_checker_.CalledOnValidThread()); |
| 158 | 169 |
| 159 gesture_callback_pending_ = false; | 170 gesture_callback_pending_ = false; |
| 160 | 171 |
| 161 if (!provider_ || | 172 if (!provider_ || |
| 162 num_active_consumers_ == 0) | 173 num_active_consumers_ == 0) |
| 163 return; | 174 return; |
| 164 | 175 |
| 165 for (ConsumerSet::iterator it = consumers_.begin(); | 176 for (ConsumerSet::iterator it = consumers_.begin(); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 176 } | 187 } |
| 177 } | 188 } |
| 178 } | 189 } |
| 179 } | 190 } |
| 180 | 191 |
| 181 void GamepadService::SetSanitizationEnabled(bool sanitize) { | 192 void GamepadService::SetSanitizationEnabled(bool sanitize) { |
| 182 provider_->SetSanitizationEnabled(sanitize); | 193 provider_->SetSanitizationEnabled(sanitize); |
| 183 } | 194 } |
| 184 | 195 |
| 185 } // namespace content | 196 } // namespace content |
| OLD | NEW |