| 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..557e7f3a37fce54a090c3b59c9523f0621a9ce18 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.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,22 @@ 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.
|
| +// given URL or package. DataUseMatcher is not thread safe. It is created on IO
|
| +// thread, but immediately moved to the UI thread, and afterwards accessible
|
| +// only on the UI thread.
|
| class DataUseMatcher {
|
| public:
|
| + // |on_tracking_label_removed_callback| is the callback to be run when a
|
| + // tracking label is removed from the list of matching rules.
|
| + // |on_matching_rules_fetched_callback| is the callback to be run after
|
| + // matching rules are fetched, indicating if at least one valid matching rule
|
| + // is available.
|
| 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);
|
|
|
| ~DataUseMatcher();
|
| @@ -64,10 +69,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 +130,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 +137,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);
|
| };
|
|
|