OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 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 "chromecast/android/chromecast_config_android.h" | |
6 | |
7 #include "base/logging.h" | |
8 | |
9 namespace chromecast { | |
10 namespace android { | |
11 | |
12 namespace { | |
13 ChromecastConfigAndroid* g_instance = NULL; | |
Yaron
2014/08/20 18:11:01
Why not use LazyInstance?
gunsch
2014/08/21 22:31:27
Done.
| |
14 } // namespace | |
15 | |
16 // static | |
17 ChromecastConfigAndroid* ChromecastConfigAndroid::GetInstance() { | |
18 // Note: ChromecastConfigAndroid is expected to be thread-safe, and this is | |
19 // potentially called across multiple threads. However, the first call is very | |
20 // early, when starting up breakpad (before creating browser threads), so | |
21 // this is expected to be safe. | |
22 if (!g_instance) { | |
23 new ChromecastConfigAndroid(); | |
24 } | |
25 DCHECK(g_instance); | |
26 return g_instance; | |
27 } | |
28 | |
29 ChromecastConfigAndroid::ChromecastConfigAndroid() { | |
30 DCHECK(!g_instance); | |
31 g_instance = this; | |
32 } | |
33 | |
34 ChromecastConfigAndroid::~ChromecastConfigAndroid() { | |
35 DCHECK_EQ(g_instance, this); | |
36 g_instance = NULL; | |
37 } | |
38 | |
39 // Registers a handler to be notified when SendUsageStats is changed. | |
40 void ChromecastConfigAndroid::SetSendUsageStatsChangedCallback( | |
41 const base::Callback<void(bool)>& callback) { | |
42 send_usage_stats_changed_callback_ = callback; | |
43 } | |
44 | |
45 } // namespace android | |
46 } // namespace chromecast | |
OLD | NEW |