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

Side by Side Diff: device/vr/android/gvr/gvr_delegate.cc

Issue 2727873002: Implement lazy initialization for VrShellDelegate (Closed)
Patch Set: Fix FindBugs errors - neat! Created 3 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 unified diff | Download patch
« no previous file with comments | « device/vr/android/gvr/gvr_delegate.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "device/vr/android/gvr/gvr_delegate.h" 5 #include "device/vr/android/gvr/gvr_delegate.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace device { 9 namespace device {
10 10
11 GvrDelegateProvider* GvrDelegateProvider::delegate_provider_ = nullptr; 11 base::Callback<GvrDelegateProvider*()> GvrDelegateProvider::delegate_provider_;
12 12
13 GvrDelegateProvider* GvrDelegateProvider::GetInstance() { 13 GvrDelegateProvider* GvrDelegateProvider::GetInstance() {
14 return delegate_provider_; 14 if (delegate_provider_.is_null())
15 return nullptr;
16 return delegate_provider_.Run();
15 } 17 }
16 18
17 void GvrDelegateProvider::SetInstance(GvrDelegateProvider* delegate_provider) { 19 void GvrDelegateProvider::SetInstance(
18 if (delegate_provider) { 20 const base::Callback<GvrDelegateProvider*()>& provider_callback) {
19 // Don't initialize the delegate_provider_ twice. Re-enable 21 delegate_provider_ = provider_callback;
20 // (crbug.com/655297)
21 // DCHECK(!delegate_provider_);
22 }
23 delegate_provider_ = delegate_provider;
24 } 22 }
25 23
26 } // namespace device 24 } // namespace device
OLDNEW
« no previous file with comments | « device/vr/android/gvr/gvr_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698