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

Unified Diff: content/browser/vr/vr_device_manager.h

Issue 829803003: Adding Chrome-side WebVR interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Missed one cardboard reference Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/vr/vr_device.cc ('k') | content/browser/vr/vr_device_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/vr/vr_device_manager.h
diff --git a/content/browser/vr/vr_device_manager.h b/content/browser/vr/vr_device_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..6c8dc9646a8d882c1b656ef1aa2b8d94aaa2005a
--- /dev/null
+++ b/content/browser/vr/vr_device_manager.h
@@ -0,0 +1,78 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_VR_VR_DEVICE_MANAGER_H
+#define CONTENT_BROWSER_VR_VR_DEVICE_MANAGER_H
+
+#include <map>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/memory/linked_ptr.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/threading/thread_checker.h"
+#include "content/browser/vr/vr_device.h"
+#include "content/browser/vr/vr_device_provider.h"
+#include "content/common/content_export.h"
+#include "content/common/vr_service.mojom.h"
+#include "mojo/common/weak_binding_set.h"
+
+namespace content {
+
+class VRDeviceManager : public VRService, public mojo::ErrorHandler {
+ public:
+ ~VRDeviceManager() override;
+
+ static void BindRequest(mojo::InterfaceRequest<VRService> request);
+
+ // Returns the VRDeviceManager singleton.
+ static VRDeviceManager* GetInstance();
+
+ mojo::Array<VRDeviceInfoPtr> GetVRDevices();
+ VRDevice* GetDevice(unsigned int index);
+
+ private:
+ friend class VRDeviceManagerTest;
+
+ VRDeviceManager();
+ // Constructor for testing.
+ explicit VRDeviceManager(scoped_ptr<VRDeviceProvider> provider);
+
+ static void SetInstance(VRDeviceManager* service);
+ static bool HasInstance();
+
+ void InitializeProviders();
+ void RegisterProvider(scoped_ptr<VRDeviceProvider> provider);
+
+ // VRService implementation
+ void GetDevices(const GetDevicesCallback& callback) override;
+ void GetSensorState(uint32_t index,
+ const GetSensorStateCallback& callback) override;
+ void ResetSensor(uint32_t index) override;
+
+ // mojo::ErrorHandler implementation
+ void OnConnectionError() override;
+
+ using ProviderList = std::vector<linked_ptr<VRDeviceProvider>>;
+ ProviderList providers_;
+
+ // Devices are owned by their providers.
+ using DeviceMap = std::map<unsigned int, VRDevice*>;
+ DeviceMap devices_;
+
+ bool vr_initialized_;
+
+ mojo::WeakBindingSet<VRService> bindings_;
+
+ // For testing. If true will not delete self when consumer count reaches 0.
+ bool keep_alive_;
+
+ base::ThreadChecker thread_checker_;
+
+ DISALLOW_COPY_AND_ASSIGN(VRDeviceManager);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_VR_VR_DEVICE_MANAGER_H
« no previous file with comments | « content/browser/vr/vr_device.cc ('k') | content/browser/vr/vr_device_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698