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

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

Issue 829803003: Adding Chrome-side WebVR interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed the rest of sievers@ input Created 5 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/vr/vr_service.h
diff --git a/content/browser/vr/vr_service.h b/content/browser/vr/vr_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..25e314ba810c908930db1a8018177b6294906462
--- /dev/null
+++ b/content/browser/vr/vr_service.h
@@ -0,0 +1,70 @@
+// 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_SERVICE_H
+#define CONTENT_BROWSER_VR_VR_SERVICE_H
+
+#include <map>
+#include <set>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/memory/singleton.h"
+#include "base/threading/thread_checker.h"
+#include "content/browser/vr/vr_device.h"
+#include "content/browser/vr/vr_device_provider.h"
+#include "content/browser/vr/vr_service_consumer.h"
+#include "content/common/content_export.h"
+
+namespace blink {
+class WebVRDevice;
+}
+
+namespace content {
+
+class CONTENT_EXPORT VRService {
+ public:
+ // Returns the VRService singleton.
+ static VRService* GetInstance();
+
+ void GetVRDevices(std::vector<blink::WebVRDevice>* webvr_devices);
+ VRDevice* GetDevice(unsigned int index);
+
+ private:
+ friend struct DefaultSingletonTraits<VRService>;
+ friend class VRServiceTest;
+ friend class VRServiceConsumer;
+
+ VRService();
+ // Constructor for testing. Takes ownership of the given provider.
no sievers 2015/03/26 19:55:15 If so, then you can pass scoped_ptr
+ explicit VRService(VRDeviceProvider* provider);
+ virtual ~VRService();
+
+ void AddConsumer(VRServiceConsumer* consumer);
+ void RemoveConsumer(VRServiceConsumer* consumer);
+
+ void InitializeProviders();
+ void ReleaseProviderDevices();
+
+ void RegisterProvider(VRDeviceProvider* provider);
+
+ typedef std::vector<VRDeviceProvider*> ProviderList;
+ ProviderList providers_;
+
+ typedef std::map<unsigned int, VRDevice*> DeviceMap;
+ DeviceMap devices_;
+
+ bool vr_initialized_;
+
+ typedef std::set<VRServiceConsumer*> ConsumerSet;
+ ConsumerSet consumers_;
+
+ base::ThreadChecker thread_checker_;
+
+ DISALLOW_COPY_AND_ASSIGN(VRService);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_VR_VR_SERVICE_H

Powered by Google App Engine
This is Rietveld 408576698