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

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: minor fix 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..b00c9e7ba55ef2b2a0ca2f4c9a3d8536be30aac3 100644
--- a/chrome/browser/android/data_usage/data_use_matcher.cc
+++ b/chrome/browser/android/data_usage/data_use_matcher.cc
@@ -16,7 +16,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,15 +24,20 @@ 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) {
+ DCHECK(on_tracking_label_removed_callback_);
+ DCHECK(on_matching_rules_fetched_callback_);
+ // Detach from current thread since rest of DataUseMatcher lives on the UI
+ // thread and the current thread may not be UI thread..
+ thread_checker_.DetachFromThread();
}
DataUseMatcher::~DataUseMatcher() {}
@@ -82,17 +86,15 @@ void DataUseMatcher::RegisterURLRegexes(
removed_matching_rule_labels.erase(labels.at(i));
}
- for (const std::string& label : removed_matching_rule_labels) {
- if (data_use_tab_model_)
- data_use_tab_model_->OnTrackingLabelRemoved(label);
- }
+ for (const std::string& label : removed_matching_rule_labels)
+ 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());
}
bool DataUseMatcher::MatchesURL(const GURL& url, std::string* label) const {
@@ -140,11 +142,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();
}
« no previous file with comments | « chrome/browser/android/data_usage/data_use_matcher.h ('k') | chrome/browser/android/data_usage/data_use_matcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698