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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "device/vr/android/gvr/gvr_delegate.h"
6
7 #include "base/logging.h"
8 #include "base/memory/singleton.h"
9
10 namespace device {
11
12 GvrDelegateManager* GvrDelegateManager::GetInstance() {
13 return base::Singleton<GvrDelegateManager>::get();
14 }
15
16 GvrDelegateManager::GvrDelegateManager() : delegate_(nullptr) {}
17
18 GvrDelegateManager::~GvrDelegateManager() {}
19
20 void GvrDelegateManager::AddClient(GvrDelegateClient* client) {
21 clients_.push_back(client);
22
23 if (delegate_)
24 client->OnDelegateInitialized(delegate_);
25 }
26
27 void GvrDelegateManager::RemoveClient(GvrDelegateClient* client) {
28 clients_.erase(std::remove(clients_.begin(), clients_.end(), client),
29 clients_.end());
30 }
31
32 void GvrDelegateManager::Initialize(GvrDelegate* delegate) {
33 // Don't initialize the delegate manager twice.
34 DCHECK(!delegate_);
35
36 delegate_ = delegate;
37
38 for (const auto& client : clients_)
39 client->OnDelegateInitialized(delegate_);
40 }
41
42 void GvrDelegateManager::Shutdown() {
43 if (!delegate_)
44 return;
45
46 delegate_ = nullptr;
47
48 for (const auto& client : clients_)
49 client->OnDelegateShutdown();
50 }
51
52 } // namespace device
OLDNEW
« 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