Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1410)

Side by Side Diff: content/browser/gamepad/gamepad_service.cc

Issue 2522843002: Convert Gamepad IPC messages into mojo interface. (Closed)
Patch Set: hide the "sharedmemory wrap" in GamepadService. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « content/browser/gamepad/gamepad_service.h ('k') | content/browser/renderer_host/gamepad_browser_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698