Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/android/browsing_data/browsing_data_counter_bridge.h" | 5 #include "chrome/browser/android/browsing_data/browsing_data_counter_bridge.h" |
| 6 | 6 |
| 7 #include "base/android/jni_string.h" | 7 #include "base/android/jni_string.h" |
| 8 #include "chrome/browser/browsing_data/browsing_data_counter_factory.h" | |
| 8 #include "chrome/browser/browsing_data/browsing_data_counter_utils.h" | 9 #include "chrome/browser/browsing_data/browsing_data_counter_utils.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/profiles/profile_manager.h" | 11 #include "chrome/browser/profiles/profile_manager.h" |
| 11 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
| 12 #include "components/browsing_data/browsing_data_utils.h" | 13 #include "components/browsing_data/browsing_data_utils.h" |
| 13 #include "jni/BrowsingDataCounterBridge_jni.h" | 14 #include "jni/BrowsingDataCounterBridge_jni.h" |
| 14 | 15 |
| 15 BrowsingDataCounterBridge::BrowsingDataCounterBridge( | 16 BrowsingDataCounterBridge::BrowsingDataCounterBridge( |
| 16 JNIEnv* env, const JavaParamRef<jobject>& obj, jint data_type) | 17 JNIEnv* env, const JavaParamRef<jobject>& obj, jint data_type) |
| 17 : jobject_(obj) { | 18 : jobject_(obj) { |
| 18 DCHECK_GE(data_type, 0); | 19 DCHECK_GE(data_type, 0); |
| 19 DCHECK_LT(data_type, browsing_data::NUM_TYPES); | 20 DCHECK_LT(data_type, browsing_data::NUM_TYPES); |
| 20 | 21 |
| 21 std::string pref; | 22 std::string pref; |
| 22 if (!GetDeletionPreferenceFromDataType( | 23 if (!GetDeletionPreferenceFromDataType( |
| 23 static_cast<browsing_data::BrowsingDataType>(data_type), &pref)) { | 24 static_cast<browsing_data::BrowsingDataType>(data_type), &pref)) { |
| 24 return; | 25 return; |
| 25 } | 26 } |
| 26 | 27 |
| 27 Profile* profile = | 28 Profile* profile = |
| 28 ProfileManager::GetActiveUserProfile()->GetOriginalProfile(); | 29 ProfileManager::GetActiveUserProfile()->GetOriginalProfile(); |
| 29 counter_.reset(CreateCounterForPreference(pref, profile)); | 30 counter_.reset(BrowsingDataCounterFactory::GetForPreference(pref, profile)); |
|
msramek
2016/07/07 11:55:32
Why don't we remove this method?
ioanap
2016/07/07 16:30:48
Oups! Removed it now.
| |
| 30 | 31 |
| 31 if (!counter_) | 32 if (!counter_) |
| 32 return; | 33 return; |
| 33 | 34 |
| 34 counter_->Init(profile->GetPrefs(), | 35 counter_->Init(profile->GetPrefs(), |
| 35 base::Bind(&BrowsingDataCounterBridge::onCounterFinished, | 36 base::Bind(&BrowsingDataCounterBridge::onCounterFinished, |
| 36 base::Unretained(this))); | 37 base::Unretained(this))); |
| 37 counter_->Restart(); | 38 counter_->Restart(); |
| 38 } | 39 } |
| 39 | 40 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 58 env, GetCounterTextFromResult(result.get())); | 59 env, GetCounterTextFromResult(result.get())); |
| 59 Java_BrowsingDataCounterBridge_onBrowsingDataCounterFinished( | 60 Java_BrowsingDataCounterBridge_onBrowsingDataCounterFinished( |
| 60 env, jobject_.obj(), result_string.obj()); | 61 env, jobject_.obj(), result_string.obj()); |
| 61 } | 62 } |
| 62 | 63 |
| 63 static jlong Init( | 64 static jlong Init( |
| 64 JNIEnv* env, const JavaParamRef<jobject>& obj, int data_type) { | 65 JNIEnv* env, const JavaParamRef<jobject>& obj, int data_type) { |
| 65 return reinterpret_cast<intptr_t>( | 66 return reinterpret_cast<intptr_t>( |
| 66 new BrowsingDataCounterBridge(env, obj, data_type)); | 67 new BrowsingDataCounterBridge(env, obj, data_type)); |
| 67 } | 68 } |
| OLD | NEW |