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

Unified Diff: components/subresource_filter/core/browser/ruleset_service.h

Issue 2272593002: Safeguard against crash-looping if subresource filter rule indexing fails. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments by pkalinnikov@. Created 4 years, 4 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
« no previous file with comments | « no previous file | components/subresource_filter/core/browser/ruleset_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/subresource_filter/core/browser/ruleset_service.h
diff --git a/components/subresource_filter/core/browser/ruleset_service.h b/components/subresource_filter/core/browser/ruleset_service.h
index 5e33ab3f6fedc1c2f0f2084752beb6579a7b4161..d01579a68461b975dc185cea4979eae63cede902 100644
--- a/components/subresource_filter/core/browser/ruleset_service.h
+++ b/components/subresource_filter/core/browser/ruleset_service.h
@@ -14,6 +14,7 @@
#include "base/callback_forward.h"
#include "base/files/file.h"
#include "base/files/file_path.h"
+#include "base/files/file_util.h"
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
@@ -111,6 +112,10 @@ class RulesetService : public base::SupportsWeakPtr<RulesetService> {
FAILED_DELETE_PREEXISTING,
FAILED_OPENING_UNINDEXED_RULESET,
FAILED_PARSING_UNINDEXED_RULESET,
+ FAILED_CREATING_VERSION_DIR,
+ FAILED_CREATING_SENTINEL_FILE,
+ FAILED_DELETING_SENTINEL_FILE,
+ ABORTED_BECAUSE_SENTINEL_FILE_PRESENT,
// Insert new values before this line.
MAX,
@@ -144,6 +149,10 @@ class RulesetService : public base::SupportsWeakPtr<RulesetService> {
private:
friend class SubresourceFilteringRulesetServiceTest;
+ FRIEND_TEST_ALL_PREFIXES(SubresourceFilteringRulesetServiceTest,
+ NewRuleset_WriteFailure);
+ FRIEND_TEST_ALL_PREFIXES(SubresourceFilteringRulesetServiceDeathTest,
+ NewRuleset_IndexingCrash);
using WriteRulesetCallback =
base::Callback<void(const IndexedRulesetVersion&)>;
@@ -152,6 +161,8 @@ class RulesetService : public base::SupportsWeakPtr<RulesetService> {
const base::FilePath& version_directory);
static base::FilePath GetLicenseFilePath(
const base::FilePath& version_directory);
+ static base::FilePath GetSentinelFilePath(
+ const base::FilePath& version_directory);
// Reads the ruleset described in |unindexed_ruleset_info|, indexes it, and
// calls WriteRuleset() to persist the indexed ruleset. Returns the resulting
@@ -177,12 +188,16 @@ class RulesetService : public base::SupportsWeakPtr<RulesetService> {
// Writing is factored out into this separate function so it can be
// independently exercised in tests.
static IndexAndWriteRulesetResult WriteRuleset(
- const base::FilePath& indexed_ruleset_base_dir,
- const IndexedRulesetVersion& indexed_version,
- const base::FilePath& license_path,
+ const base::FilePath& indexed_ruleset_version_dir,
+ const base::FilePath& license_source_path,
const uint8_t* indexed_ruleset_data,
size_t indexed_ruleset_size);
+ // Indirections for accessing these routines, so as to allow overriding and
+ // injecting faults in tests.
+ static decltype(&IndexRuleset) g_index_ruleset_func;
+ static decltype(&base::ReplaceFile) g_replace_file_func;
+
// Posts a task to the |blocking_task_runner_| to index and persist the given
// unindexed ruleset. Then, on success, updates the most recently indexed
// version in preferences and invokes |success_callback| on the calling
« no previous file with comments | « no previous file | components/subresource_filter/core/browser/ruleset_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698