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

Side by Side Diff: content/browser/vr/vr_device_manager.cc

Issue 1832813002: Add mojom module suffix in .mojom files in content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Tom's comment Created 4 years, 8 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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/vr/vr_device_manager.h" 5 #include "content/browser/vr/vr_device_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
(...skipping 27 matching lines...) Expand all
38 thread_checker_.DetachFromThread(); 38 thread_checker_.DetachFromThread();
39 RegisterProvider(std::move(provider)); 39 RegisterProvider(std::move(provider));
40 SetInstance(this); 40 SetInstance(this);
41 } 41 }
42 42
43 VRDeviceManager::~VRDeviceManager() { 43 VRDeviceManager::~VRDeviceManager() {
44 DCHECK(thread_checker_.CalledOnValidThread()); 44 DCHECK(thread_checker_.CalledOnValidThread());
45 g_vr_device_manager = nullptr; 45 g_vr_device_manager = nullptr;
46 } 46 }
47 47
48 void VRDeviceManager::BindRequest(mojo::InterfaceRequest<VRService> request) { 48 void VRDeviceManager::BindRequest(
49 mojo::InterfaceRequest<mojom::VRService> request) {
49 VRDeviceManager* device_manager = GetInstance(); 50 VRDeviceManager* device_manager = GetInstance();
50 device_manager->bindings_.AddBinding(device_manager, std::move(request)); 51 device_manager->bindings_.AddBinding(device_manager, std::move(request));
51 } 52 }
52 53
53 void VRDeviceManager::OnConnectionError() { 54 void VRDeviceManager::OnConnectionError() {
54 DCHECK(thread_checker_.CalledOnValidThread()); 55 DCHECK(thread_checker_.CalledOnValidThread());
55 if (bindings_.empty() && !keep_alive_) { 56 if (bindings_.empty() && !keep_alive_) {
56 // Delete the device manager when it has no active connections. 57 // Delete the device manager when it has no active connections.
57 delete g_vr_device_manager; 58 delete g_vr_device_manager;
58 } 59 }
(...skipping 11 matching lines...) Expand all
70 // non-nullptr and vica versa. 71 // non-nullptr and vica versa.
71 CHECK_NE(!!instance, !!g_vr_device_manager); 72 CHECK_NE(!!instance, !!g_vr_device_manager);
72 g_vr_device_manager = instance; 73 g_vr_device_manager = instance;
73 } 74 }
74 75
75 bool VRDeviceManager::HasInstance() { 76 bool VRDeviceManager::HasInstance() {
76 // For testing. Checks to see if a VRDeviceManager instance is active. 77 // For testing. Checks to see if a VRDeviceManager instance is active.
77 return !!g_vr_device_manager; 78 return !!g_vr_device_manager;
78 } 79 }
79 80
80 mojo::Array<VRDeviceInfoPtr> VRDeviceManager::GetVRDevices() { 81 mojo::Array<mojom::VRDeviceInfoPtr> VRDeviceManager::GetVRDevices() {
81 DCHECK(thread_checker_.CalledOnValidThread()); 82 DCHECK(thread_checker_.CalledOnValidThread());
82 83
83 InitializeProviders(); 84 InitializeProviders();
84 85
85 std::vector<VRDevice*> devices; 86 std::vector<VRDevice*> devices;
86 for (const auto& provider : providers_) 87 for (const auto& provider : providers_)
87 provider->GetDevices(&devices); 88 provider->GetDevices(&devices);
88 89
89 mojo::Array<VRDeviceInfoPtr> out_devices; 90 mojo::Array<mojom::VRDeviceInfoPtr> out_devices;
90 for (const auto& device : devices) { 91 for (const auto& device : devices) {
91 if (device->id() == VR_DEVICE_LAST_ID) 92 if (device->id() == VR_DEVICE_LAST_ID)
92 continue; 93 continue;
93 94
94 if (devices_.find(device->id()) == devices_.end()) 95 if (devices_.find(device->id()) == devices_.end())
95 devices_[device->id()] = device; 96 devices_[device->id()] = device;
96 97
97 VRDeviceInfoPtr vr_device_info = device->GetVRDevice(); 98 mojom::VRDeviceInfoPtr vr_device_info = device->GetVRDevice();
98 if (vr_device_info.is_null()) 99 if (vr_device_info.is_null())
99 continue; 100 continue;
100 101
101 vr_device_info->index = device->id(); 102 vr_device_info->index = device->id();
102 out_devices.push_back(std::move(vr_device_info)); 103 out_devices.push_back(std::move(vr_device_info));
103 } 104 }
104 105
105 return out_devices; 106 return out_devices;
106 } 107 }
107 108
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 145 }
145 } 146 }
146 147
147 void VRDeviceManager::ResetSensor(uint32_t index) { 148 void VRDeviceManager::ResetSensor(uint32_t index) {
148 VRDevice* device = GetDevice(index); 149 VRDevice* device = GetDevice(index);
149 if (device) 150 if (device)
150 device->ResetSensor(); 151 device->ResetSensor();
151 } 152 }
152 153
153 } // namespace content 154 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/vr/vr_device_manager.h ('k') | content/browser/vr/vr_device_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698