// Copyright 2017 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_SUBRESOURCE_FILTER_CORE_BROWSER_VERIFIED_RULESET_DEALER_H_ #define COMPONENTS_SUBRESOURCE_FILTER_CORE_BROWSER_VERIFIED_RULESET_DEALER_H_ #include <memory> #include "base/files/file_path.h" #include "base/functional/callback_forward.h" #include "base/memory/raw_ptr.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/sequence_checker.h" #include "base/task/sequenced_task_runner.h" #include "components/subresource_filter/core/common/ruleset_config.h" #include "components/subresource_filter/core/common/ruleset_dealer.h" namespace base { class File; } // namespace base namespace subresource_filter { class MemoryMappedRuleset; // The integrity verification status of a given ruleset version. // // A ruleset file starts from the kNotVerified state, after which it can be // classified as kIntact, kCorrupt, or kInvalidFile upon integrity verification. // // These values are persisted to logs. Entries should not be renumbered and // numeric values should never be reused. enum class RulesetVerificationStatus { … }; // The unique_ptr ensures that the file is always closed on the proper task // runner. See crbug.com/1182000 RulesetFilePtr; // This class is the same as RulesetDealer, but additionally does a one-time // integrity checking on the ruleset before handing it out from GetRuleset(). // // The |status| of verification is persisted throughout the entire lifetime of // |this| object, and is reset to kNotVerified only when a new ruleset is // supplied to SetRulesetFile() method. class VerifiedRulesetDealer : public RulesetDealer { … }; // The UI-thread handle that owns a VerifiedRulesetDealer living on a dedicated // sequenced |task_runner|. Provides asynchronous access to the instance, and // destroys it asynchronously. class VerifiedRulesetDealer::Handle { … }; // Holds a strong reference to MemoryMappedRuleset, and provides acceess to it. // // Initially holds an empty reference, allowing this object to be created on the // UI-thread synchronously, hence letting the Handle to be created synchronously // and be immediately used by clients on the UI-thread, while the // MemoryMappedRuleset is retrieved on the |task_runner| in a deferred manner. class VerifiedRuleset { … }; // The UI-thread handle that owns a VerifiedRuleset living on a dedicated // sequenced |task_runner|, same as the VerifiedRulesetDealer lives on. Provides // asynchronous access to the instance, and destroys it asynchronously. class VerifiedRuleset::Handle { … }; } // namespace subresource_filter #endif // COMPONENTS_SUBRESOURCE_FILTER_CORE_BROWSER_VERIFIED_RULESET_DEALER_H_