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

Unified Diff: device/vr/android/gvr/gvr_delegate.cc

Issue 2309523003: Plumbing through more WebVR presentation code (Closed)
Patch Set: Addressed Michael's feedack Created 4 years, 3 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 | « device/vr/android/gvr/gvr_delegate.h ('k') | device/vr/android/gvr/gvr_device.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/vr/android/gvr/gvr_delegate.cc
diff --git a/device/vr/android/gvr/gvr_delegate.cc b/device/vr/android/gvr/gvr_delegate.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d3ef0ba160b281e06c068b90e8e42b7561912911
--- /dev/null
+++ b/device/vr/android/gvr/gvr_delegate.cc
@@ -0,0 +1,52 @@
+// 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.
+
+#include "device/vr/android/gvr/gvr_delegate.h"
+
+#include "base/logging.h"
+#include "base/memory/singleton.h"
+
+namespace device {
+
+GvrDelegateManager* GvrDelegateManager::GetInstance() {
+ return base::Singleton<GvrDelegateManager>::get();
+}
+
+GvrDelegateManager::GvrDelegateManager() : delegate_(nullptr) {}
+
+GvrDelegateManager::~GvrDelegateManager() {}
+
+void GvrDelegateManager::AddClient(GvrDelegateClient* client) {
+ clients_.push_back(client);
+
+ if (delegate_)
+ client->OnDelegateInitialized(delegate_);
+}
+
+void GvrDelegateManager::RemoveClient(GvrDelegateClient* client) {
+ clients_.erase(std::remove(clients_.begin(), clients_.end(), client),
+ clients_.end());
+}
+
+void GvrDelegateManager::Initialize(GvrDelegate* delegate) {
+ // Don't initialize the delegate manager twice.
+ DCHECK(!delegate_);
+
+ delegate_ = delegate;
+
+ for (const auto& client : clients_)
+ client->OnDelegateInitialized(delegate_);
+}
+
+void GvrDelegateManager::Shutdown() {
+ if (!delegate_)
+ return;
+
+ delegate_ = nullptr;
+
+ for (const auto& client : clients_)
+ client->OnDelegateShutdown();
+}
+
+} // namespace device
« no previous file with comments | « device/vr/android/gvr/gvr_delegate.h ('k') | device/vr/android/gvr/gvr_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698