// Copyright 2016 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // This file contains the top-level class for the RulesetService. There are // associated classes that tie this into the dealer as well as the filter // agents. The distribution pipeline looks like this: // // RulesetService // | // v Browser // RulesetPublisher(Impl) // | | // - - - - - - -|- - - - - - - |- - - - - - - - - - // | | | // v v // *RulesetDealer | *RulesetDealer // | | | // | | | v // v | SubresourceFilterAgent // SubresourceFilterAgent | v // SubresourceFilterAgent // | // // Renderer #1 | Renderer #n // // Note: UnverifiedRulesetDealer is shortened to *RulesetDealer above. There is // also a VerifiedRulesetDealer which is used similarly on the browser side. #ifndef COMPONENTS_SUBRESOURCE_FILTER_CONTENT_SHARED_BROWSER_RULESET_SERVICE_H_ #define COMPONENTS_SUBRESOURCE_FILTER_CONTENT_SHARED_BROWSER_RULESET_SERVICE_H_ #include <stdint.h> #include <memory> #include "base/files/file.h" #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/functional/callback.h" #include "base/gtest_prod_util.h" #include "base/memory/raw_ptr.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/task/single_thread_task_runner.h" #include "base/version.h" #include "components/subresource_filter/content/shared/browser/ruleset_publisher.h" #include "components/subresource_filter/core/browser/ruleset_version.h" #include "components/subresource_filter/core/browser/verified_ruleset_dealer.h" #include "components/subresource_filter/core/common/ruleset_config.h" namespace base { class SequencedTaskRunner; } // namespace base namespace subresource_filter { class RulesetIndexer; class UnindexedRulesetStreamGenerator; // Contains all utility functions that govern how files pertaining to indexed // ruleset version should be organized on disk. // // The various indexed ruleset versions are kept in a two-level directory // hierarchy based on their format and content version numbers, like so: // // |base_dir| // | // +--10 (format_version) // | | // | +--1 (content_version) // | | \... // | | // | +--2 (content_version) // | \... // | // +--11 (format_version) // | // +--2 (content_version) // \... // class IndexedRulesetLocator { … }; // Responsible for indexing subresource filtering rules that are downloaded // through the component updater; for versioned storage of the indexed ruleset; // and for supplying the most up-to-date version of the indexed ruleset to the // RulesetPublisher, provided in the constructor, that abstracts away // distribution of the ruleset to renderers. // // The service is parametrized for different rulesets via |config|. Files // corresponding to each version of the indexed ruleset are stored in a separate // subdirectory inside |indexed_ruleset_base_dir| named after the version. The // version information of the most recent successfully stored ruleset is written // into |local_state|. The invariant is maintained that the version pointed to // by preferences, if valid, will exist on disk at any point in time. // // Obsolete files deletion and rulesets indexing are posted to // |background_task_runner|. class RulesetService { … }; } // namespace subresource_filter #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_SHARED_BROWSER_RULESET_SERVICE_H_