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

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

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
« no previous file with comments | « chrome/common/safe_browsing/file_type_policies_test_util.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/safe_browsing/file_type_policies_test_util.cc
diff --git a/chrome/common/safe_browsing/file_type_policies_test_util.cc b/chrome/common/safe_browsing/file_type_policies_test_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d0520b9d176d192317dc08f9c177f224f3b58063
--- /dev/null
+++ b/chrome/common/safe_browsing/file_type_policies_test_util.cc
@@ -0,0 +1,36 @@
+// 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 "chrome/common/safe_browsing/file_type_policies_test_util.h"
+
+namespace safe_browsing {
+
+FileTypePoliciesTestOverlay::FileTypePoliciesTestOverlay()
+ : orig_config_(new DownloadFileTypeConfig()) {
+ // Make a copy of the global config so we can put it back later.
+ // Swap out, copy, swap back in.
+ SwapConfig(orig_config_);
+ std::unique_ptr<DownloadFileTypeConfig> copy_config = DuplicateConfig();
+ SwapConfig(copy_config);
+}
+
+FileTypePoliciesTestOverlay::~FileTypePoliciesTestOverlay() {
+ SwapConfig(orig_config_);
+}
+
+void FileTypePoliciesTestOverlay::SwapConfig(
+ std::unique_ptr<DownloadFileTypeConfig>& new_config) const {
+ FileTypePolicies::GetInstance()->SwapConfig(new_config);
+}
+
+std::unique_ptr<DownloadFileTypeConfig>
+FileTypePoliciesTestOverlay::DuplicateConfig() const {
+ std::unique_ptr<DownloadFileTypeConfig> new_config(
+ new DownloadFileTypeConfig());
+ // Deep copy
+ new_config->CopyFrom(*orig_config_);
+ return new_config;
+}
+
+} // namespace safe_browsing
« no previous file with comments | « chrome/common/safe_browsing/file_type_policies_test_util.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698