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

Unified Diff: chrome/common/safe_browsing/file_type_policies_test_util.h

Issue 2072933002: Add sampling of unknown filetypes in download protection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add int values for histograms to ensure they match Created 4 years, 6 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
Index: chrome/common/safe_browsing/file_type_policies_test_util.h
diff --git a/chrome/common/safe_browsing/file_type_policies_test_util.h b/chrome/common/safe_browsing/file_type_policies_test_util.h
new file mode 100644
index 0000000000000000000000000000000000000000..7d6fd54ceb1bb3541321c44f34525eb72c3a1a7a
--- /dev/null
+++ b/chrome/common/safe_browsing/file_type_policies_test_util.h
@@ -0,0 +1,41 @@
+// 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.
+
+#ifndef CHROME_COMMON_SAFE_BROWSING_FILE_TYPE_POLICIES_TEST_UTIL_H_
+#define CHROME_COMMON_SAFE_BROWSING_FILE_TYPE_POLICIES_TEST_UTIL_H_
+
+#include "chrome/common/safe_browsing/file_type_policies.h"
+
+namespace safe_browsing {
+
+// This is a test fixture for modifying the proto with FileTypePolicies.
+// While an object of this class is in scope, it will cause callers
+// of FileTypePolicies::GetInstance() to see the modified list.
+// When it goes out of scope, future callers will get the original list.
+//
+// Example:
+// FileTypePoliciesTestOverlay overlay_;
+// std::unique_ptr<DownloadFileTypesConfig> cfg =
+// overlay_.DuplicateConfig();
+// cfg.set_sampled_ping_probability(1.0);
+// overlay_.SwapConfig(cfg);
+// ...
+class FileTypePoliciesTestOverlay {
+ public:
+ FileTypePoliciesTestOverlay();
+ ~FileTypePoliciesTestOverlay();
+
+ // Swaps the contents bewtween the existing config and |new_config|.
+ void SwapConfig(std::unique_ptr<DownloadFileTypeConfig>& new_config) const;
+
+ // Return a new copy of the original config.
+ std::unique_ptr<DownloadFileTypeConfig> DuplicateConfig() const;
+
+ private:
+ std::unique_ptr<DownloadFileTypeConfig> orig_config_;
+};
+
+} // namespace safe_browsing
+
+#endif // CHROME_COMMON_SAFE_BROWSING_FILE_TYPE_POLICIES_TEST_UTIL_H_
« no previous file with comments | « chrome/common/safe_browsing/file_type_policies.cc ('k') | chrome/common/safe_browsing/file_type_policies_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698