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

Side by Side Diff: chromecast/base/chromecast_config_android.cc

Issue 1180633002: Chromecast: don't try to upload crash immediately. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: address slan's comments Created 5 years, 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 "chromecast/android/chromecast_config_android.h" 5 #include "chromecast/base/chromecast_config_android.h"
6
7 #include "base/android/jni_android.h"
8 #include "base/lazy_instance.h"
9 #include "jni/ChromecastConfigAndroid_jni.h"
6 10
7 namespace chromecast { 11 namespace chromecast {
8 namespace android { 12 namespace android {
9 13
10 namespace { 14 namespace {
11 base::LazyInstance<ChromecastConfigAndroid> g_instance = 15 base::LazyInstance<ChromecastConfigAndroid> g_instance =
12 LAZY_INSTANCE_INITIALIZER; 16 LAZY_INSTANCE_INITIALIZER;
13 } // namespace 17 } // namespace
14 18
15 // static 19 // static
16 ChromecastConfigAndroid* ChromecastConfigAndroid::GetInstance() { 20 ChromecastConfigAndroid* ChromecastConfigAndroid::GetInstance() {
17 return g_instance.Pointer(); 21 return g_instance.Pointer();
18 } 22 }
19 23
24 // static
25 bool ChromecastConfigAndroid::RegisterJni(JNIEnv* env) {
26 return RegisterNativesImpl(env);
27 }
28
20 ChromecastConfigAndroid::ChromecastConfigAndroid() { 29 ChromecastConfigAndroid::ChromecastConfigAndroid() {
21 } 30 }
22 31
23 ChromecastConfigAndroid::~ChromecastConfigAndroid() { 32 ChromecastConfigAndroid::~ChromecastConfigAndroid() {
24 } 33 }
25 34
35 bool ChromecastConfigAndroid::CanSendUsageStats() {
36 JNIEnv* env = base::android::AttachCurrentThread();
37 return Java_ChromecastConfigAndroid_canSendUsageStats(
38 env, base::android::GetApplicationContext());
39 }
40
26 // Registers a handler to be notified when SendUsageStats is changed. 41 // Registers a handler to be notified when SendUsageStats is changed.
27 void ChromecastConfigAndroid::SetSendUsageStatsChangedCallback( 42 void ChromecastConfigAndroid::SetSendUsageStatsChangedCallback(
28 const base::Callback<void(bool)>& callback) { 43 const base::Callback<void(bool)>& callback) {
29 send_usage_stats_changed_callback_ = callback; 44 send_usage_stats_changed_callback_ = callback;
30 } 45 }
31 46
47 // Called from Java.
48 void SetSendUsageStatsEnabled(JNIEnv* env, jclass caller, jboolean enabled) {
49 ChromecastConfigAndroid::GetInstance()->
byungchul 2015/06/11 17:15:00 Why is ChromecastConfigAndroid static in Java and
gunsch 2015/06/12 00:30:30 We could probably simplify this code more if we up
byungchul 2015/06/12 05:57:00 Right, we should use chromecast preference for ATV
gunsch 2015/06/12 16:54:52 Done. (will upload after addressing other comments
50 send_usage_stats_changed_callback().Run(enabled);
51 }
52
32 } // namespace android 53 } // namespace android
33 } // namespace chromecast 54 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698