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

Side by Side Diff: third_party/WebKit/Source/platform/vr/vr_dispatcher.cc

Issue 1808203005: [OnionSoup] Moving VR service from content to Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "platform/vr/vr_dispatcher.h"
6
7 #include "platform/threading/BindForMojo.h"
8 #include "platform/vr/vr_type_converters.h"
9 #include "public/platform/Platform.h"
10
11 namespace blink {
12
13 WebVRClient* VRDispatcher::create()
haraken 2016/03/19 00:45:18 VRDispatcher is not GarbageCollected, so you canno
RaviKasibhatla 2016/03/21 15:12:01 PTAL at my current approach. Since WebVRClient is
14 {
15 return new VRDispatcher();
16 }
17
18 VRDispatcher::VRDispatcher() {
19 }
20
21 VRDispatcher::~VRDispatcher() {
22 }
23
24 content::VRServicePtr& VRDispatcher::GetVRServicePtr() {
25 if (!vr_service_)
26 Platform::current()->connectToRemoteService(mojo::GetProxy(&vr_service_));
27 return vr_service_;
28 }
29
30 void VRDispatcher::getDevices(WebVRGetDevicesCallback* callback) {
31 int request_id = pending_requests_.Add(callback);
32 GetVRServicePtr()->GetDevices(
33 sameThreadBindForMojoWithBoundArgs(&VRDispatcher::OnGetDevices, this, &req uest_id));
34 }
35
36 void VRDispatcher::getSensorState(unsigned int index,
37 WebHMDSensorState& state) {
38 GetVRServicePtr()->GetSensorState(
39 index,
40 sameThreadBindForMojoWithBoundArgs(&VRDispatcher::OnGetSensorState, this, &state));
41
42 // This call needs to return results synchronously in order to be useful and
43 // provide the lowest latency results possible.
44 GetVRServicePtr().WaitForIncomingResponse();
45 }
46
47 void VRDispatcher::resetSensor(unsigned int index) {
48 GetVRServicePtr()->ResetSensor(index);
49 }
50
51 void VRDispatcher::OnGetDevices(int* request_id,
52 const mojo::Array<content::VRDeviceInfoPtr>& dev ices) {
53 WebVector<WebVRDevice> web_devices(devices.size());
54
55 WebVRGetDevicesCallback* callback =
56 pending_requests_.Lookup(*request_id);
57 if (!callback)
58 return;
59
60 for (size_t i = 0; i < devices.size(); ++i) {
61 web_devices[i] = devices[i].To<WebVRDevice>();
62 }
63
64 callback->onSuccess(web_devices);
65 pending_requests_.Remove(*request_id);
66 }
67
68 void VRDispatcher::OnGetSensorState(WebHMDSensorState* state,
69 const content::VRSensorStatePtr& mojo_state) {
70 *state = mojo_state.To<WebHMDSensorState>();
71 }
72
73 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698