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

Unified Diff: chrome/browser/android/data_usage/data_use_matcher.cc

Issue 2158913002: Make DataUseTabModel and DataUseMatcher more independent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/data_usage/data_use_matcher.cc
diff --git a/chrome/browser/android/data_usage/data_use_matcher.cc b/chrome/browser/android/data_usage/data_use_matcher.cc
index be21c004ae8952ba04856282268896dbfb01b45e..6f83a7cad91f5fa0df169af9a43a511aec38c1ea 100644
--- a/chrome/browser/android/data_usage/data_use_matcher.cc
+++ b/chrome/browser/android/data_usage/data_use_matcher.cc
@@ -9,6 +9,7 @@
#include <utility>
+#include "base/callback.h"
#include "base/memory/ptr_util.h"
#include "base/memory/weak_ptr.h"
tbansal1 2016/07/18 17:04:38 include not needed anymore.
Raj 2016/07/19 00:19:02 Done.
#include "base/metrics/histogram_macros.h"
@@ -16,7 +17,6 @@
#include "base/time/default_tick_clock.h"
#include "base/time/tick_clock.h"
#include "base/time/time.h"
-#include "chrome/browser/android/data_usage/external_data_use_observer_bridge.h"
#include "third_party/re2/src/re2/re2.h"
#include "url/gurl.h"
@@ -25,16 +25,15 @@ namespace chrome {
namespace android {
DataUseMatcher::DataUseMatcher(
- const base::WeakPtr<DataUseTabModel>& data_use_tab_model,
- const ExternalDataUseObserverBridge* external_data_use_observer_bridge,
+ const base::Callback<void(const std::string&)>&
+ on_tracking_label_removed_callback,
+ const base::Callback<void(bool)>& on_matching_rules_fetched_callback,
const base::TimeDelta& default_matching_rule_expiration_duration)
- : data_use_tab_model_(data_use_tab_model),
- default_matching_rule_expiration_duration_(
+ : default_matching_rule_expiration_duration_(
default_matching_rule_expiration_duration),
tick_clock_(new base::DefaultTickClock()),
- external_data_use_observer_bridge_(external_data_use_observer_bridge) {
- DCHECK(external_data_use_observer_bridge_);
-}
+ on_tracking_label_removed_callback_(on_tracking_label_removed_callback),
+ on_matching_rules_fetched_callback_(on_matching_rules_fetched_callback) {}
DataUseMatcher::~DataUseMatcher() {}
@@ -83,16 +82,14 @@ void DataUseMatcher::RegisterURLRegexes(
}
for (const std::string& label : removed_matching_rule_labels) {
- if (data_use_tab_model_)
- data_use_tab_model_->OnTrackingLabelRemoved(label);
+ on_tracking_label_removed_callback_.Run(label);
}
UMA_HISTOGRAM_COUNTS_100("DataUsage.MatchingRulesCount.Valid",
matching_rules_.size());
UMA_HISTOGRAM_COUNTS_100("DataUsage.MatchingRulesCount.Invalid",
invalid_rules);
- external_data_use_observer_bridge_->ShouldRegisterAsDataUseObserver(
- !matching_rules_.empty());
+ on_matching_rules_fetched_callback_.Run(!matching_rules_.empty());
tbansal1 2016/07/18 17:04:38 Would this callback run on UI thread? Is it expect
Raj 2016/07/19 00:19:02 The callback runs on UI thread. The bridge expects
}
bool DataUseMatcher::MatchesURL(const GURL& url, std::string* label) const {
@@ -140,11 +137,6 @@ bool DataUseMatcher::MatchesAppPackageName(const std::string& app_package_name,
return false;
}
-void DataUseMatcher::FetchMatchingRules() {
- DCHECK(thread_checker_.CalledOnValidThread());
- external_data_use_observer_bridge_->FetchMatchingRules();
-}
-
bool DataUseMatcher::HasRules() const {
return !matching_rules_.empty();
}

Powered by Google App Engine
This is Rietveld 408576698