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

Unified Diff: components/subresource_filter/core/common/test_ruleset_creator.cc

Issue 2158833002: Factor DocumentSubresourceFilter out of SubresourceFilterAgent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments from pkalinnikov@ 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
« no previous file with comments | « components/subresource_filter/core/common/test_ruleset_creator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/subresource_filter/core/common/test_ruleset_creator.cc
diff --git a/components/subresource_filter/core/common/test_ruleset_creator.cc b/components/subresource_filter/core/common/test_ruleset_creator.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b2255fd3e38bc7f90e6a2d84f694c78953bbfb72
--- /dev/null
+++ b/components/subresource_filter/core/common/test_ruleset_creator.cc
@@ -0,0 +1,35 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/subresource_filter/core/common/test_ruleset_creator.h"
+
+#include "base/files/file_util.h"
+#include "base/logging.h"
+#include "base/strings/string_number_conversions.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace subresource_filter {
+namespace testing {
+
+TestRulesetCreator::TestRulesetCreator() = default;
+TestRulesetCreator::~TestRulesetCreator() = default;
+
+void TestRulesetCreator::CreateRulesetToDisallowURLsWithPathSuffix(
+ base::StringPiece suffix,
+ base::File* ruleset_file) {
+ DCHECK(ruleset_file);
+ ASSERT_TRUE(scoped_temp_dir_.IsValid() ||
+ scoped_temp_dir_.CreateUniqueTempDir());
+ base::FilePath unique_temp_path = scoped_temp_dir_.path().AppendASCII(
+ base::IntToString(next_ruleset_version_++));
+ int ruleset_size = base::checked_cast<int>(suffix.size());
+ ASSERT_EQ(ruleset_size,
+ base::WriteFile(unique_temp_path, suffix.data(), ruleset_size));
+ ruleset_file->Initialize(unique_temp_path, base::File::FLAG_OPEN |
+ base::File::FLAG_READ |
+ base::File::FLAG_SHARE_DELETE);
+}
+
+} // namespace testing
+} // namespace subresource_filter
« no previous file with comments | « components/subresource_filter/core/common/test_ruleset_creator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698