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

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

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.h
diff --git a/chrome/browser/android/data_usage/data_use_matcher.h b/chrome/browser/android/data_usage/data_use_matcher.h
index 731bf002f222766b0a609852fc232baa2a020a73..700211ba0403d7777862f117f8e8c4e6812f5087 100644
--- a/chrome/browser/android/data_usage/data_use_matcher.h
+++ b/chrome/browser/android/data_usage/data_use_matcher.h
@@ -9,14 +9,13 @@
#include <string>
#include <vector>
+#include "base/callback_forward.h"
#include "base/compiler_specific.h"
#include "base/containers/hash_tables.h"
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/threading/thread_checker.h"
#include "base/time/time.h"
-#include "chrome/browser/android/data_usage/data_use_tab_model.h"
-
namespace base {
class TickClock;
}
@@ -31,16 +30,15 @@ namespace chrome {
namespace android {
-class ExternalDataUseObserverBridge;
-
// DataUseMatcher stores the matching URL patterns and package names along with
// the labels. It also provides functionality to get the matching label for a
// given URL or package. DataUseMatcher is not thread safe.
class DataUseMatcher {
public:
DataUseMatcher(
tbansal1 2016/07/18 17:04:38 add comments about the callback.
Raj 2016/07/19 00:19:02 Done.
- 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);
~DataUseMatcher();
@@ -64,10 +62,6 @@ class DataUseMatcher {
bool MatchesAppPackageName(const std::string& app_package_name,
std::string* label) const WARN_UNUSED_RESULT;
- // Fetches the matching rules asynchronously from
- // |external_data_use_observer_bridge_|.
- void FetchMatchingRules();
-
// Returns true if there is any matching rule. HasRules may return true even
// if all rules are expired.
bool HasRules() const;
@@ -129,10 +123,6 @@ class DataUseMatcher {
std::vector<std::unique_ptr<MatchingRule>> matching_rules_;
- // |data_use_tab_model_| is notified if a label is removed from the set of
- // matching labels.
- base::WeakPtr<DataUseTabModel> data_use_tab_model_;
-
// Default expiration duration of a matching rule, if expiration is not
// specified in the rule.
const base::TimeDelta default_matching_rule_expiration_duration_;
@@ -140,12 +130,12 @@ class DataUseMatcher {
// TickClock used for obtaining the current time.
std::unique_ptr<base::TickClock> tick_clock_;
- // Pointer to the ExternalDataUseObserverBridge owned by
- // ExternalDataUseObserver. DataUseTabModel (owner of |this|) and
- // ExternalDataUseObserverBridge are owned by ExternalDataUseObserver, and are
- // destroyed in that order. So |external_data_use_observer_bridge_| is
- // guaranteed to be non-null.
- const ExternalDataUseObserverBridge* external_data_use_observer_bridge_;
+ // Callback to be run when a label is removed from the set of matching labels.
+ const base::Callback<void(const std::string&)>&
+ on_tracking_label_removed_callback_;
+
+ // Callback to be run when matching rules are fetched.
+ const base::Callback<void(bool)>& on_matching_rules_fetched_callback_;
DISALLOW_COPY_AND_ASSIGN(DataUseMatcher);
};

Powered by Google App Engine
This is Rietveld 408576698