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

Side by Side Diff: chrome/browser/android/browsing_data/browsing_data_counter_bridge.cc

Issue 2121203002: Add BrowsingDataCounterFactory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_bd_counters_to_components
Patch Set: Fixed Android code and rebase Created 4 years, 5 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 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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698