Index: chromecast/android/chromecast_config_android.cc |
diff --git a/chromecast/android/chromecast_config_android.cc b/chromecast/android/chromecast_config_android.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b369f0cbf065660d269da0985d082be30735d6ce |
--- /dev/null |
+++ b/chromecast/android/chromecast_config_android.cc |
@@ -0,0 +1,46 @@ |
+// Copyright 2014 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 "chromecast/android/chromecast_config_android.h" |
+ |
+#include "base/logging.h" |
+ |
+namespace chromecast { |
+namespace android { |
+ |
+namespace { |
+ChromecastConfigAndroid* g_instance = NULL; |
Yaron
2014/08/20 18:11:01
Why not use LazyInstance?
gunsch
2014/08/21 22:31:27
Done.
|
+} // namespace |
+ |
+// static |
+ChromecastConfigAndroid* ChromecastConfigAndroid::GetInstance() { |
+ // Note: ChromecastConfigAndroid is expected to be thread-safe, and this is |
+ // potentially called across multiple threads. However, the first call is very |
+ // early, when starting up breakpad (before creating browser threads), so |
+ // this is expected to be safe. |
+ if (!g_instance) { |
+ new ChromecastConfigAndroid(); |
+ } |
+ DCHECK(g_instance); |
+ return g_instance; |
+} |
+ |
+ChromecastConfigAndroid::ChromecastConfigAndroid() { |
+ DCHECK(!g_instance); |
+ g_instance = this; |
+} |
+ |
+ChromecastConfigAndroid::~ChromecastConfigAndroid() { |
+ DCHECK_EQ(g_instance, this); |
+ g_instance = NULL; |
+} |
+ |
+// Registers a handler to be notified when SendUsageStats is changed. |
+void ChromecastConfigAndroid::SetSendUsageStatsChangedCallback( |
+ const base::Callback<void(bool)>& callback) { |
+ send_usage_stats_changed_callback_ = callback; |
+} |
+ |
+} // namespace android |
+} // namespace chromecast |