Commit 98f9652e authored by bajones's avatar bajones Committed by Commit bot

Moving VR service from /content/browser to /device

BUG=612342
CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:linux_site_isolation

Review-Url: https://codereview.chromium.org/2029703002
Cr-Commit-Position: refs/heads/master@{#397828}
parent 73a640d4
...@@ -501,25 +501,6 @@ source_set("browser") { ...@@ -501,25 +501,6 @@ source_set("browser") {
configs += [ "//media/mojo/services:mojo_media_config" ] configs += [ "//media/mojo/services:mojo_media_config" ]
} }
if (enable_webvr) {
sources += [
"vr/vr_device.cc",
"vr/vr_device.h",
"vr/vr_device_manager.cc",
"vr/vr_device_manager.h",
"vr/vr_device_provider.h",
]
}
if (enable_webvr && is_android) {
sources += [
"vr/android/cardboard/cardboard_vr_device.cc",
"vr/android/cardboard/cardboard_vr_device.h",
"vr/android/cardboard/cardboard_vr_device_provider.cc",
"vr/android/cardboard/cardboard_vr_device_provider.h",
]
}
if (use_ozone) { if (use_ozone) {
deps += [ "//ui/ozone" ] deps += [ "//ui/ozone" ]
} }
...@@ -530,6 +511,10 @@ source_set("browser") { ...@@ -530,6 +511,10 @@ source_set("browser") {
"gpu/gpu_surface_tracker.h", "gpu/gpu_surface_tracker.h",
] ]
} }
if (enable_webvr) {
deps += [ "//device/vr" ]
}
} }
# See comment at the top of //content/BUILD.gn for how this works. # See comment at the top of //content/BUILD.gn for how this works.
......
...@@ -17,6 +17,7 @@ include_rules = [ ...@@ -17,6 +17,7 @@ include_rules = [
"+content/public/browser", "+content/public/browser",
"+device/battery", # For battery status service. "+device/battery", # For battery status service.
"+device/vibration", # For Vibration API "+device/vibration", # For Vibration API
"+device/vr", # For WebVR API
"+gin/v8_initializer.h", "+gin/v8_initializer.h",
"+mojo", "+mojo",
"+services", "+services",
......
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
#include "content/browser/screen_orientation/screen_orientation_delegate_android.h" #include "content/browser/screen_orientation/screen_orientation_delegate_android.h"
#include "content/browser/speech/speech_recognizer_impl_android.h" #include "content/browser/speech/speech_recognizer_impl_android.h"
#include "content/browser/time_zone_monitor_android.h" #include "content/browser/time_zone_monitor_android.h"
#include "content/browser/vr/android/cardboard/cardboard_vr_device.h"
#include "content/browser/web_contents/web_contents_android.h" #include "content/browser/web_contents/web_contents_android.h"
#include "mojo/android/system/core_impl.h" #include "mojo/android/system/core_impl.h"
...@@ -58,10 +57,6 @@ base::android::RegistrationMethod kContentRegisteredMethods[] = { ...@@ -58,10 +57,6 @@ base::android::RegistrationMethod kContentRegisteredMethods[] = {
RegisterNetworkObserver}, RegisterNetworkObserver},
{"BrowserAccessibilityManager", {"BrowserAccessibilityManager",
content::RegisterBrowserAccessibilityManager}, content::RegisterBrowserAccessibilityManager},
#if defined(ENABLE_WEBVR)
{"CardboardVRDevice",
content::CardboardVRDevice::RegisterCardboardVRDevice},
#endif
{"ContentViewCore", content::RegisterContentViewCore}, {"ContentViewCore", content::RegisterContentViewCore},
{"ContentViewRenderView", {"ContentViewRenderView",
content::ContentViewRenderView::RegisterContentViewRenderView}, content::ContentViewRenderView::RegisterContentViewRenderView},
......
...@@ -95,8 +95,8 @@ ...@@ -95,8 +95,8 @@
#if defined(ENABLE_WEBVR) #if defined(ENABLE_WEBVR)
#include "base/command_line.h" #include "base/command_line.h"
#include "content/browser/vr/vr_device_manager.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "device/vr/vr_device_manager.h" // nogncheck
#endif #endif
using base::TimeDelta; using base::TimeDelta;
...@@ -2026,7 +2026,7 @@ void RenderFrameHostImpl::RegisterMojoServices() { ...@@ -2026,7 +2026,7 @@ void RenderFrameHostImpl::RegisterMojoServices() {
if (browser_command_line.HasSwitch(switches::kEnableWebVR)) { if (browser_command_line.HasSwitch(switches::kEnableWebVR)) {
GetServiceRegistry()->AddService<blink::mojom::VRService>( GetServiceRegistry()->AddService<blink::mojom::VRService>(
base::Bind(&VRDeviceManager::BindRequest)); base::Bind(&device::VRDeviceManager::BindRequest));
} }
#endif #endif
......
bajones@chromium.org
kbr@chromium.org
hendrikw@chromium.org
...@@ -38,6 +38,7 @@ android_library("content_java") { ...@@ -38,6 +38,7 @@ android_library("content_java") {
"//device/usb:java", "//device/usb:java",
"//device/vibration:mojo_bindings_java", "//device/vibration:mojo_bindings_java",
"//device/vibration/android:vibration_manager_android", "//device/vibration/android:vibration_manager_android",
"//device/vr:java",
"//media/base/android:media_java", "//media/base/android:media_java",
"//media/capture/video/android:capture_java", "//media/capture/video/android:capture_java",
"//media/midi:midi_java", "//media/midi:midi_java",
...@@ -159,7 +160,6 @@ android_library("content_java") { ...@@ -159,7 +160,6 @@ android_library("content_java") {
"java/src/org/chromium/content/browser/crypto/CipherFactory.java", "java/src/org/chromium/content/browser/crypto/CipherFactory.java",
"java/src/org/chromium/content/browser/framehost/NavigationControllerImpl.java", "java/src/org/chromium/content/browser/framehost/NavigationControllerImpl.java",
"java/src/org/chromium/content/browser/input/AnimationIntervalProvider.java", "java/src/org/chromium/content/browser/input/AnimationIntervalProvider.java",
"java/src/org/chromium/content/browser/input/CardboardVRDevice.java",
"java/src/org/chromium/content/browser/input/ChromiumBaseInputConnection.java", "java/src/org/chromium/content/browser/input/ChromiumBaseInputConnection.java",
"java/src/org/chromium/content/browser/input/CursorAnchorInfoController.java", "java/src/org/chromium/content/browser/input/CursorAnchorInfoController.java",
"java/src/org/chromium/content/browser/input/DateTimeChooserAndroid.java", "java/src/org/chromium/content/browser/input/DateTimeChooserAndroid.java",
...@@ -209,10 +209,6 @@ android_library("content_java") { ...@@ -209,10 +209,6 @@ android_library("content_java") {
"java/src/org/chromium/content_public/common/Referrer.java", "java/src/org/chromium/content_public/common/Referrer.java",
"java/src/org/chromium/content_public/common/ScreenOrientationConstants.java", "java/src/org/chromium/content_public/common/ScreenOrientationConstants.java",
] ]
if (enable_webvr) {
deps += [ "//third_party/cardboard-java:cardboard-java" ]
}
} }
java_strings_grd("content_strings_grd") { java_strings_grd("content_strings_grd") {
...@@ -294,13 +290,6 @@ generate_jar_jni("jar_jni") { ...@@ -294,13 +290,6 @@ generate_jar_jni("jar_jni") {
generate_jni("content_jni_headers") { generate_jni("content_jni_headers") {
sources = rebase_path(content_jni_gypi_values.sources, "", "../..") sources = rebase_path(content_jni_gypi_values.sources, "", "../..")
jni_package = "content" jni_package = "content"
if (enable_webvr) {
sources += [ "//content/public/android/java/src/org/chromium/content/browser/input/CardboardVRDevice.java" ]
public_deps = [
"//third_party/cardboard-java:cardboard-java",
]
}
} }
group("jni") { group("jni") {
......
...@@ -60,6 +60,7 @@ test("device_unittests") { ...@@ -60,6 +60,7 @@ test("device_unittests") {
"nfc/nfc_chromeos_unittest.cc", "nfc/nfc_chromeos_unittest.cc",
"nfc/nfc_ndef_record_unittest.cc", "nfc/nfc_ndef_record_unittest.cc",
"test/run_all_unittests.cc", "test/run_all_unittests.cc",
"vr/vr_device_manager_unittest.cc",
] ]
deps = [ deps = [
...@@ -69,6 +70,8 @@ test("device_unittests") { ...@@ -69,6 +70,8 @@ test("device_unittests") {
"//device/bluetooth", "//device/bluetooth",
"//device/bluetooth:mocks", "//device/bluetooth:mocks",
"//device/nfc", "//device/nfc",
"//device/vr",
"//device/vr:fakes",
"//mojo/common", "//mojo/common",
"//mojo/edk/system", "//mojo/edk/system",
"//mojo/public/cpp/bindings", "//mojo/public/cpp/bindings",
......
# Copyright 2016 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.
import("//build/config/features.gni")
import("//mojo/public/tools/bindings/mojom.gni")
if (is_android) {
import("//build/config/android/rules.gni") # For generate_jni().
}
component("vr") {
output_name = "device_vr"
sources = [
"vr_device.cc",
"vr_device.h",
"vr_device_manager.cc",
"vr_device_manager.h",
"vr_device_provider.h",
]
deps = [
"//base",
"//mojo/edk/system",
"//mojo/public/cpp/bindings",
"//third_party/WebKit/public:mojo_bindings",
"//ui/gfx",
]
defines = [ "DEVICE_VR_IMPLEMENTATION" ]
if (is_android) {
sources += [
"android/cardboard/cardboard_vr_device.cc",
"android/cardboard/cardboard_vr_device.h",
"android/cardboard/cardboard_vr_device_provider.cc",
"android/cardboard/cardboard_vr_device_provider.h",
]
deps += [ ":jni_headers" ]
}
}
static_library("fakes") {
testonly = true
sources = [
"test/fake_vr_device.cc",
"test/fake_vr_device.h",
"test/fake_vr_device_provider.cc",
"test/fake_vr_device_provider.h",
]
public_deps = [
":vr",
"//base",
"//mojo/public/cpp/bindings",
"//third_party/WebKit/public:mojo_bindings",
]
}
if (is_android) {
java_sources_needing_jni =
[ "android/java/src/org/chromium/device/vr/CardboardVRDevice.java" ]
generate_jni("jni_headers") {
sources = java_sources_needing_jni
jni_package = "vr"
public_deps = [
"//third_party/cardboard-java:cardboard-java",
]
}
android_library("java") {
java_files = java_sources_needing_jni
deps = [
"//base:base_java",
"//third_party/cardboard-java:cardboard-java",
]
}
}
include_rules = [
"+jni",
"+third_party/WebKit/public/platform/modules/vr/vr_service.mojom.h",
"+ui/gfx",
]
bajones@chromium.org
kbr@chromium.org
hendrikw@chromium.org
# Changes to Mojo interfaces require a security review to avoid
# introducing new sandbox escapes.
per-file *.mojom=set noparent
per-file *.mojom=dcheng@chromium.org
per-file *.mojom=inferno@chromium.org
per-file *.mojom=jln@chromium.org
per-file *.mojom=jschuh@chromium.org
per-file *.mojom=kenrb@chromium.org
per-file *.mojom=mkwst@chromium.org
per-file *.mojom=nasko@chromium.org
per-file *.mojom=palmer@chromium.org
per-file *.mojom=tsepez@chromium.org
per-file *.mojom=wfh@chromium.org
# Copyright 2016 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.
import("//build/config/android/config.gni")
import("//build/config/android/rules.gni")
android_library("vr_android") {
java_files = [ "java/src/org/chromium/device/vr/CardboardVRDevice.java" ]
deps = [
"//base:base_java",
]
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "content/browser/vr/android/cardboard/cardboard_vr_device.h" #include "device/vr/android/cardboard/cardboard_vr_device.h"
#include <math.h> #include <math.h>
#include <algorithm> #include <algorithm>
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
using base::android::AttachCurrentThread; using base::android::AttachCurrentThread;
namespace content { namespace device {
bool CardboardVRDevice::RegisterCardboardVRDevice(JNIEnv* env) { bool CardboardVRDevice::RegisterCardboardVRDevice(JNIEnv* env) {
return RegisterNativesImpl(env); return RegisterNativesImpl(env);
...@@ -85,7 +85,7 @@ blink::mojom::VRDisplayPtr CardboardVRDevice::GetVRDevice() { ...@@ -85,7 +85,7 @@ blink::mojom::VRDisplayPtr CardboardVRDevice::GetVRDevice() {
float ipd = Java_CardboardVRDevice_getIpd(env, j_cardboard_device_.obj()); float ipd = Java_CardboardVRDevice_getIpd(env, j_cardboard_device_.obj());
left_eye->offset= mojo::Array<float>::New(3); left_eye->offset = mojo::Array<float>::New(3);
left_eye->offset[0] = ipd * -0.5f; left_eye->offset[0] = ipd * -0.5f;
left_eye->offset[1] = 0.0f; left_eye->offset[1] = 0.0f;
left_eye->offset[2] = 0.0f; left_eye->offset[2] = 0.0f;
...@@ -154,4 +154,4 @@ void CardboardVRDevice::ResetPose() { ...@@ -154,4 +154,4 @@ void CardboardVRDevice::ResetPose() {
j_cardboard_device_.obj()); j_cardboard_device_.obj());
} }
} // namespace content } // namespace device
...@@ -2,16 +2,16 @@ ...@@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CONTENT_BROWSER_VR_CARDBOARD_VR_DEVICE_H #ifndef DEVICE_VR_CARDBOARD_VR_DEVICE_H
#define CONTENT_BROWSER_VR_CARDBOARD_VR_DEVICE_H #define DEVICE_VR_CARDBOARD_VR_DEVICE_H
#include <jni.h> #include <jni.h>
#include "base/android/jni_android.h" #include "base/android/jni_android.h"
#include "base/macros.h" #include "base/macros.h"
#include "content/browser/vr/vr_device.h" #include "device/vr/vr_device.h"
namespace content { namespace device {
class CardboardVRDevice : public VRDevice { class CardboardVRDevice : public VRDevice {
public: public:
...@@ -31,6 +31,6 @@ class CardboardVRDevice : public VRDevice { ...@@ -31,6 +31,6 @@ class CardboardVRDevice : public VRDevice {
DISALLOW_COPY_AND_ASSIGN(CardboardVRDevice); DISALLOW_COPY_AND_ASSIGN(CardboardVRDevice);
}; };
} // namespace content } // namespace device
#endif // CONTENT_BROWSER_VR_CARDBOARD_VR_DEVICE_H #endif // DEVICE_VR_CARDBOARD_VR_DEVICE_H
...@@ -2,17 +2,15 @@ ...@@ -2,17 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "content/browser/vr/android/cardboard/cardboard_vr_device_provider.h" #include "device/vr/android/cardboard/cardboard_vr_device_provider.h"
#include "content/browser/vr/android/cardboard/cardboard_vr_device.h" #include "device/vr/android/cardboard/cardboard_vr_device.h"
namespace content { namespace device {
CardboardVRDeviceProvider::CardboardVRDeviceProvider() : VRDeviceProvider() { CardboardVRDeviceProvider::CardboardVRDeviceProvider() : VRDeviceProvider() {}
}
CardboardVRDeviceProvider::~CardboardVRDeviceProvider() { CardboardVRDeviceProvider::~CardboardVRDeviceProvider() {}
}
void CardboardVRDeviceProvider::GetDevices(std::vector<VRDevice*>* devices) { void CardboardVRDeviceProvider::GetDevices(std::vector<VRDevice*>* devices) {
if (!cardboard_device_) { if (!cardboard_device_) {
...@@ -26,4 +24,4 @@ void CardboardVRDeviceProvider::Initialize() { ...@@ -26,4 +24,4 @@ void CardboardVRDeviceProvider::Initialize() {
// No initialization needed for Cardboard devices. // No initialization needed for Cardboard devices.
} }
} // namespace content } // namespace device
...@@ -2,17 +2,17 @@ ...@@ -2,17 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CONTENT_BROWSER_VR_CARDBOARD_VR_DEVICE_PROVIDER_H #ifndef DEVICE_VR_CARDBOARD_VR_DEVICE_PROVIDER_H
#define CONTENT_BROWSER_VR_CARDBOARD_VR_DEVICE_PROVIDER_H #define DEVICE_VR_CARDBOARD_VR_DEVICE_PROVIDER_H
#include <map> #include <map>
#include <memory> #include <memory>
#include "base/macros.h" #include "base/macros.h"
#include "content/browser/vr/vr_device.h" #include "device/vr/vr_device.h"
#include "content/browser/vr/vr_device_provider.h" #include "device/vr/vr_device_provider.h"
namespace content { namespace device {
class CardboardVRDeviceProvider : public VRDeviceProvider { class CardboardVRDeviceProvider : public VRDeviceProvider {
public: public:
...@@ -28,6 +28,6 @@ class CardboardVRDeviceProvider : public VRDeviceProvider { ...@@ -28,6 +28,6 @@ class CardboardVRDeviceProvider : public VRDeviceProvider {
DISALLOW_COPY_AND_ASSIGN(CardboardVRDeviceProvider); DISALLOW_COPY_AND_ASSIGN(CardboardVRDeviceProvider);
}; };
} // namespace content } // namespace device
#endif // CONTENT_BROWSER_VR_CARDBOARD_VR_DEVICE_PROVIDER_H #endif // DEVICE_VR_CARDBOARD_VR_DEVICE_PROVIDER_H
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
package org.chromium.content.browser.input; package org.chromium.device.vr;
import android.content.Context; import android.content.Context;
...@@ -19,7 +19,7 @@ import org.chromium.base.annotations.JNINamespace; ...@@ -19,7 +19,7 @@ import org.chromium.base.annotations.JNINamespace;
/** /**
* This is the implementation of the C++ counterpart CardboardVRDevice. * This is the implementation of the C++ counterpart CardboardVRDevice.
*/ */
@JNINamespace("content") @JNINamespace("device")
class CardboardVRDevice { class CardboardVRDevice {
private static final String TAG = "CardboardVRDevice"; private static final String TAG = "CardboardVRDevice";
private final HeadMountedDisplayManager mHMDManager; private final HeadMountedDisplayManager mHMDManager;
......
// 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.
#include "device/vr/android/vr_jni_registrar.h"
#include "base/android/jni_android.h"
#include "base/android/jni_registrar.h"
#include "base/macros.h"
#include "device/vr/android/cardboard/cardboard_vr_device.h"
namespace device {
namespace android {
namespace {
const base::android::RegistrationMethod kRegisteredMethods[] = {
{"CardboardVRDevice", device::CardboardVRDevice::RegisterJNI},
};
} // namespace
bool RegisterVRJni(JNIEnv* env) {
return RegisterNativeMethods(env, kRegisteredMethods,
arraysize(kRegisteredMethods));
}
} // namespace android
} // namespace device
// Copyright 2016 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 DEVICE_VR_ANDROID_VR_JNI_REGISTRAR_H_
#define DEVICE_VR_ANDROID_VR_JNI_REGISTRAR_H_
#include <jni.h>
#include "device/vr/vr_export.h"
namespace device {
namespace android {
// Registers C++ methods in device/vr classes with JNI.
// See https://www.chromium.org/developers/design-documents/android-jni
//
// Must be called before classes in the VR module are used.
DEVICE_VR_EXPORT bool RegisterVRJni(JNIEnv* env);
} // namespace android
} // namespace device
#endif // DEVICE_VR_ANDROID_VR_JNI_REGISTRAR_H_
...@@ -2,32 +2,33 @@ ...@@ -2,32 +2,33 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "content/browser/vr/test/fake_vr_device.h" #include "device/vr/test/fake_vr_device.h"
namespace content { namespace device {
FakeVRDevice::FakeVRDevice(VRDeviceProvider* provider) : VRDevice(provider) { FakeVRDevice::FakeVRDevice(VRDeviceProvider* provider) : VRDevice(provider) {
device_ = blink::mojom::VRDisplay::New(); device_ = blink::mojom::VRDisplay::New();
state_ = blink::mojom::VRPose::New(); pose_ = blink::mojom::VRPose::New();
} }
FakeVRDevice::~FakeVRDevice() { FakeVRDevice::~FakeVRDevice() {}
}
void FakeVRDevice::SetVRDevice(const blink::mojom::VRDisplayPtr& device) { void FakeVRDevice::SetVRDevice(const blink::mojom::VRDisplayPtr& device) {
device_ = device.Clone(); device_ = device.Clone();
} }
void FakeVRDevice::SetSensorState(const blink::mojom::VRPosePtr& state) { void FakeVRDevice::SetPose(const blink::mojom::VRPosePtr& pose) {
state_ = state.Clone(); pose_ = pose.Clone();
} }
blink::mojom::VRDisplayPtr FakeVRDevice::GetVRDevice() { blink::mojom::VRDisplayPtr FakeVRDevice::GetVRDevice() {
return device_.Clone(); return device_.Clone();
} }
blink::mojom::VRPosePtr FakeVRDevice::GetSensorState() { blink::mojom::VRPosePtr FakeVRDevice::GetPose() {
return state_.Clone(); return pose_.Clone();
} }
} // namespace content void FakeVRDevice::ResetPose() {}
\ No newline at end of file
} // namespace device
...@@ -2,34 +2,34 @@ ...@@ -2,34 +2,34 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CONTENT_BROWSER_VR_TEST_FAKE_VR_DEVICE_H_ #ifndef DEVICE_VR_TEST_FAKE_VR_DEVICE_H_
#define CONTENT_BROWSER_VR_TEST_FAKE_VR_DEVICE_H_ #define DEVICE_VR_TEST_FAKE_VR_DEVICE_H_
#include "base/macros.h" #include "base/macros.h"
#include "content/browser/vr/vr_device.h" #include "device/vr/vr_device.h"
#include "content/browser/vr/vr_device_provider.h" #include "device/vr/vr_device_provider.h"
namespace content { namespace device {
class FakeVRDevice : public VRDevice { class FakeVRDevice : public VRDevice {
public: public:
explicit FakeVRDevice(VRDeviceProvider* provider); explicit FakeVRDevice(VRDeviceProvider* provider);
~FakeVRDevice() override; ~FakeVRDevice() override;
void SetVRDevice(const mojom::VRDisplayPtr& device); void SetVRDevice(const blink::mojom::VRDisplayPtr& device);
void SetPose(const mojom::VRPosePtr& state); void SetPose(const blink::mojom::VRPosePtr& state);
blink::mojom::VRDisplayPtr GetVRDevice() override; blink::mojom::VRDisplayPtr GetVRDevice() override;
blink::mojom::VRPosePtr GetPose() override; blink::mojom::VRPosePtr GetPose() override;
void ResetPose() override; void ResetPose() override;
private: private:
mojom::VRDisplayPtr device_; blink::mojom::VRDisplayPtr device_;
mojom::VRPosePtr state_; blink::mojom::VRPosePtr pose_;
DISALLOW_COPY_AND_ASSIGN(FakeVRDevice); DISALLOW_COPY_AND_ASSIGN(FakeVRDevice);
}; };
} // namespace content } // namespace device
#endif // CONTENT_BROWSER_VR_TEST_FAKE_VR_DEVICE_H_ #endif // DEVICE_VR_TEST_FAKE_VR_DEVICE_H_
...@@ -2,16 +2,15 @@ ...@@ -2,16 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "content/browser/vr/test/fake_vr_device_provider.h" #include "device/vr/test/fake_vr_device_provider.h"
namespace content { namespace device {
FakeVRDeviceProvider::FakeVRDeviceProvider() : VRDeviceProvider() { FakeVRDeviceProvider::FakeVRDeviceProvider() : VRDeviceProvider() {
initialized_ = false; initialized_ = false;
} }
FakeVRDeviceProvider::~FakeVRDeviceProvider() { FakeVRDeviceProvider::~FakeVRDeviceProvider() {}
}
void FakeVRDeviceProvider::AddDevice(VRDevice* device) { void FakeVRDeviceProvider::AddDevice(VRDevice* device) {
devices_.push_back(device); devices_.push_back(device);
...@@ -28,11 +27,11 @@ void FakeVRDeviceProvider::RemoveDevice(VRDevice* device) { ...@@ -28,11 +27,11 @@ void FakeVRDeviceProvider::RemoveDevice(VRDevice* device) {
} }
} }
void FakeVRDeviceProvider::GetDevices(std::vector<VRDevice*>& devices) { void FakeVRDeviceProvider::GetDevices(std::vector<VRDevice*>* devices) {
std::vector<VRDevice*>::iterator iter; std::vector<VRDevice*>::iterator iter;
for (auto device : devices_) { for (auto device : devices_) {
devices.push_back(device); devices->push_back(device);
} }
} }
...@@ -40,4 +39,4 @@ void FakeVRDeviceProvider::Initialize() { ...@@ -40,4 +39,4 @@ void FakeVRDeviceProvider::Initialize() {
initialized_ = true; initialized_ = true;
} }
} // namespace content } // namespace device
\ No newline at end of file
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CONTENT_BROWSER_VR_TEST_FAKE_VR_DEVICE_PROVIDER_H_ #ifndef DEVICE_VR_TEST_FAKE_VR_DEVICE_PROVIDER_H_
#define CONTENT_BROWSER_VR_TEST_FAKE_VR_DEVICE_PROVIDER_H_ #define DEVICE_VR_TEST_FAKE_VR_DEVICE_PROVIDER_H_
#include <vector> #include <vector>
#include "content/browser/vr/vr_device.h" #include "device/vr/vr_device.h"
#include "content/browser/vr/vr_device_provider.h" #include "device/vr/vr_device_provider.h"
namespace content { namespace device {
class FakeVRDeviceProvider : public VRDeviceProvider { class FakeVRDeviceProvider : public VRDeviceProvider {
public: public:
...@@ -22,7 +22,7 @@ class FakeVRDeviceProvider : public VRDeviceProvider { ...@@ -22,7 +22,7 @@ class FakeVRDeviceProvider : public VRDeviceProvider {
void RemoveDevice(VRDevice* device); void RemoveDevice(VRDevice* device);
bool IsInitialized() { return initialized_; } bool IsInitialized() { return initialized_; }
void GetDevices(std::vector<VRDevice*>& devices) override; void GetDevices(std::vector<VRDevice*>* devices) override;
void Initialize() override; void Initialize() override;
private: private:
...@@ -30,6 +30,6 @@ class FakeVRDeviceProvider : public VRDeviceProvider { ...@@ -30,6 +30,6 @@ class FakeVRDeviceProvider : public VRDeviceProvider {
bool initialized_; bool initialized_;
}; };
} // namespace content } // namespace device
#endif // CONTENT_BROWSER_VR_TEST_FAKE_VR_DEVICE_PROVIDER_H_ #endif // DEVICE_VR_TEST_FAKE_VR_DEVICE_PROVIDER_H_
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "content/browser/vr/vr_device.h" #include "device/vr/vr_device.h"
#include "content/browser/vr/vr_device_provider.h" #include "device/vr/vr_device_provider.h"
namespace content { namespace device {
unsigned int VRDevice::next_id_ = 1; unsigned int VRDevice::next_id_ = 1;
...@@ -16,7 +16,6 @@ VRDevice::VRDevice(VRDeviceProvider* provider) ...@@ -16,7 +16,6 @@ VRDevice::VRDevice(VRDeviceProvider* provider)
next_id_++; next_id_++;
} }
VRDevice::~VRDevice() { VRDevice::~VRDevice() {}
}
} // namespace content } // namespace device
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CONTENT_BROWSER_VR_VR_DEVICE_H #ifndef DEVICE_VR_VR_DEVICE_H
#define CONTENT_BROWSER_VR_VR_DEVICE_H #define DEVICE_VR_VR_DEVICE_H
#include "base/macros.h" #include "base/macros.h"
#include "device/vr/vr_export.h"
#include "third_party/WebKit/public/platform/modules/vr/vr_service.mojom.h" #include "third_party/WebKit/public/platform/modules/vr/vr_service.mojom.h"
namespace blink { namespace blink {
...@@ -16,7 +17,7 @@ namespace ui { ...@@ -16,7 +17,7 @@ namespace ui {
class BaseWindow; class BaseWindow;
} }
namespace content { namespace device {
class VRDeviceProvider; class VRDeviceProvider;
...@@ -24,11 +25,11 @@ const unsigned int VR_DEVICE_LAST_ID = 0xFFFFFFFF; ...@@ -24,11 +25,11 @@ const unsigned int VR_DEVICE_LAST_ID = 0xFFFFFFFF;
class VRDevice { class VRDevice {
public: public:
explicit VRDevice(VRDeviceProvider* provider); DEVICE_VR_EXPORT explicit VRDevice(VRDeviceProvider* provider);
virtual ~VRDevice(); DEVICE_VR_EXPORT virtual ~VRDevice();
VRDeviceProvider* provider() const { return provider_; } DEVICE_VR_EXPORT VRDeviceProvider* provider() const { return provider_; }
unsigned int id() const { return id_; } DEVICE_VR_EXPORT unsigned int id() const { return id_; }
virtual blink::mojom::VRDisplayPtr GetVRDevice() = 0; virtual blink::mojom::VRDisplayPtr GetVRDevice() = 0;
virtual blink::mojom::VRPosePtr GetPose() = 0; virtual blink::mojom::VRPosePtr GetPose() = 0;
...@@ -43,6 +44,6 @@ class VRDevice { ...@@ -43,6 +44,6 @@ class VRDevice {
DISALLOW_COPY_AND_ASSIGN(VRDevice); DISALLOW_COPY_AND_ASSIGN(VRDevice);
}; };
} // namespace content } // namespace device
#endif // CONTENT_BROWSER_VR_VR_DEVICE_H #endif // DEVICE_VR_VR_DEVICE_H
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "content/browser/vr/vr_device_manager.h" #include "device/vr/vr_device_manager.h"
#include <utility> #include <utility>
...@@ -11,10 +11,10 @@ ...@@ -11,10 +11,10 @@
#include "build/build_config.h" #include "build/build_config.h"
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
#include "content/browser/vr/android/cardboard/cardboard_vr_device_provider.h" #include "device/vr/android/cardboard/cardboard_vr_device_provider.h"
#endif #endif
namespace content { namespace device {
namespace { namespace {
VRDeviceManager* g_vr_device_manager = nullptr; VRDeviceManager* g_vr_device_manager = nullptr;
...@@ -139,8 +139,7 @@ void VRDeviceManager::GetDisplays(const GetDisplaysCallback& callback) { ...@@ -139,8 +139,7 @@ void VRDeviceManager::GetDisplays(const GetDisplaysCallback& callback) {
callback.Run(GetVRDevices()); callback.Run(GetVRDevices());
} }
void VRDeviceManager::GetPose(uint32_t index, void VRDeviceManager::GetPose(uint32_t index, const GetPoseCallback& callback) {
const GetPoseCallback& callback) {
VRDevice* device = GetDevice(index); VRDevice* device = GetDevice(index);
if (device) { if (device) {
callback.Run(device->GetPose()); callback.Run(device->GetPose());
...@@ -155,4 +154,4 @@ void VRDeviceManager::ResetPose(uint32_t index) { ...@@ -155,4 +154,4 @@ void VRDeviceManager::ResetPose(uint32_t index) {
device->ResetPose(); device->ResetPose();
} }
} // namespace content } // namespace device
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CONTENT_BROWSER_VR_VR_DEVICE_MANAGER_H #ifndef DEVICE_VR_VR_DEVICE_MANAGER_H
#define CONTENT_BROWSER_VR_VR_DEVICE_MANAGER_H #define DEVICE_VR_VR_DEVICE_MANAGER_H
#include <stdint.h> #include <stdint.h>
...@@ -14,33 +14,34 @@ ...@@ -14,33 +14,34 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/linked_ptr.h" #include "base/memory/linked_ptr.h"
#include "base/threading/thread_checker.h" #include "base/threading/thread_checker.h"
#include "content/browser/vr/vr_device.h" #include "device/vr/vr_device.h"
#include "content/browser/vr/vr_device_provider.h" #include "device/vr/vr_device_provider.h"
#include "content/common/content_export.h" #include "device/vr/vr_export.h"
#include "mojo/public/cpp/bindings/binding_set.h" #include "mojo/public/cpp/bindings/binding_set.h"
#include "third_party/WebKit/public/platform/modules/vr/vr_service.mojom.h" #include "third_party/WebKit/public/platform/modules/vr/vr_service.mojom.h"
namespace content { namespace device {
class VRDeviceManager : public blink::mojom::VRService { class VRDeviceManager : public blink::mojom::VRService {
public: public:
~VRDeviceManager() override; DEVICE_VR_EXPORT ~VRDeviceManager() override;
static void BindRequest( DEVICE_VR_EXPORT static void BindRequest(
mojo::InterfaceRequest<blink::mojom::VRService> request); mojo::InterfaceRequest<blink::mojom::VRService> request);
// Returns the VRDeviceManager singleton. // Returns the VRDeviceManager singleton.
static VRDeviceManager* GetInstance(); static VRDeviceManager* GetInstance();
mojo::Array<blink::mojom::VRDisplayPtr> GetVRDevices(); DEVICE_VR_EXPORT mojo::Array<blink::mojom::VRDisplayPtr> GetVRDevices();
VRDevice* GetDevice(unsigned int index); DEVICE_VR_EXPORT VRDevice* GetDevice(unsigned int index);
private: private:
friend class VRDeviceManagerTest; friend class VRDeviceManagerTest;
VRDeviceManager(); VRDeviceManager();
// Constructor for testing. // Constructor for testing.
explicit VRDeviceManager(std::unique_ptr<VRDeviceProvider> provider); DEVICE_VR_EXPORT explicit VRDeviceManager(
std::unique_ptr<VRDeviceProvider> provider);
static void SetInstance(VRDeviceManager* service); static void SetInstance(VRDeviceManager* service);
static bool HasInstance(); static bool HasInstance();
...@@ -50,8 +51,7 @@ class VRDeviceManager : public blink::mojom::VRService { ...@@ -50,8 +51,7 @@ class VRDeviceManager : public blink::mojom::VRService {
// mojom::VRService implementation // mojom::VRService implementation
void GetDisplays(const GetDisplaysCallback& callback) override; void GetDisplays(const GetDisplaysCallback& callback) override;
void GetPose(uint32_t index, void GetPose(uint32_t index, const GetPoseCallback& callback) override;
const GetPoseCallback& callback) override;
void ResetPose(uint32_t index) override; void ResetPose(uint32_t index) override;
// Mojo connection error handler. // Mojo connection error handler.
......
...@@ -2,19 +2,19 @@ ...@@ -2,19 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "content/browser/vr/vr_device_manager.h" #include "device/vr/vr_device_manager.h"
#include <memory> #include <memory>
#include <utility> #include <utility>
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/linked_ptr.h" #include "base/memory/linked_ptr.h"
#include "content/browser/vr/test/fake_vr_device.h" #include "device/vr/test/fake_vr_device.h"
#include "content/browser/vr/test/fake_vr_device_provider.h" #include "device/vr/test/fake_vr_device_provider.h"
#include "content/browser/vr/vr_device_provider.h" #include "device/vr/vr_device_provider.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace content { namespace device {
class VRDeviceManagerTest : public testing::Test { class VRDeviceManagerTest : public testing::Test {
protected: protected:
...@@ -32,11 +32,9 @@ class VRDeviceManagerTest : public testing::Test { ...@@ -32,11 +32,9 @@ class VRDeviceManagerTest : public testing::Test {
DISALLOW_COPY_AND_ASSIGN(VRDeviceManagerTest); DISALLOW_COPY_AND_ASSIGN(VRDeviceManagerTest);
}; };
VRDeviceManagerTest::VRDeviceManagerTest() { VRDeviceManagerTest::VRDeviceManagerTest() {}
}
VRDeviceManagerTest::~VRDeviceManagerTest() { VRDeviceManagerTest::~VRDeviceManagerTest() {}
}
void VRDeviceManagerTest::SetUp() { void VRDeviceManagerTest::SetUp() {
std::unique_ptr<FakeVRDeviceProvider> provider(new FakeVRDeviceProvider()); std::unique_ptr<FakeVRDeviceProvider> provider(new FakeVRDeviceProvider());
...@@ -97,4 +95,4 @@ TEST_F(VRDeviceManagerTest, GetDevicesBasicTest) { ...@@ -97,4 +95,4 @@ TEST_F(VRDeviceManagerTest, GetDevicesBasicTest) {
EXPECT_EQ(webvr_devices[0]->index, device2->id()); EXPECT_EQ(webvr_devices[0]->index, device2->id());
} }
} // namespace content } // namespace device
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CONTENT_BROWSER_VR_VR_DEVICE_PROVIDER_H #ifndef DEVICE_VR_VR_DEVICE_PROVIDER_H
#define CONTENT_BROWSER_VR_VR_DEVICE_PROVIDER_H #define DEVICE_VR_VR_DEVICE_PROVIDER_H
#include <vector> #include <vector>
namespace content { namespace device {
class VRDevice; class VRDevice;
...@@ -22,6 +22,6 @@ class VRDeviceProvider { ...@@ -22,6 +22,6 @@ class VRDeviceProvider {
virtual void Initialize() = 0; virtual void Initialize() = 0;
}; };
} // namespace content } // namespace device
#endif // CONTENT_BROWSER_VR_VR_DEVICE_PROVIDER_H #endif // DEVICE_VR_VR_DEVICE_PROVIDER_H
// Copyright 2016 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 DEVICE_VR_DEVICE_VR_EXPORT_H_
#define DEVICE_VR_DEVICE_VR_EXPORT_H_
#if defined(COMPONENT_BUILD) && defined(WIN32)
#if defined(DEVICE_VR_IMPLEMENTATION)
#define DEVICE_VR_EXPORT __declspec(dllexport)
#else
#define DEVICE_VR_EXPORT __declspec(dllimport)
#endif
#elif defined(COMPONENT_BUILD) && !defined(WIN32)
#if defined(DEVICE_VR_IMPLEMENTATION)
#define DEVICE_VR_EXPORT __attribute__((visibility("default")))
#else
#define DEVICE_VR_EXPORT
#endif
#else
#define DEVICE_VR_EXPORT
#endif
#endif // DEVICE_VR_DEVICE_VR_EXPORT_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment