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

Side by Side Diff: chrome/browser/safe_browsing/download_protection_service_unittest.cc

Issue 2957223002: TaskScheduler Migration for DownloadProtectionService. (Closed)
Patch Set: Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/safe_browsing/download_protection_service.h" 5 #include "chrome/browser/safe_browsing/download_protection_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 #include <string> 12 #include <string>
13 13
14 #include "base/base_paths.h" 14 #include "base/base_paths.h"
15 #include "base/bind.h" 15 #include "base/bind.h"
16 #include "base/callback.h" 16 #include "base/callback.h"
17 #include "base/command_line.h" 17 #include "base/command_line.h"
18 #include "base/files/file_path.h" 18 #include "base/files/file_path.h"
19 #include "base/files/file_util.h" 19 #include "base/files/file_util.h"
20 #include "base/files/scoped_temp_dir.h" 20 #include "base/files/scoped_temp_dir.h"
21 #include "base/location.h" 21 #include "base/location.h"
22 #include "base/macros.h" 22 #include "base/macros.h"
23 #include "base/memory/ref_counted.h" 23 #include "base/memory/ref_counted.h"
24 #include "base/path_service.h" 24 #include "base/path_service.h"
25 #include "base/run_loop.h" 25 #include "base/run_loop.h"
26 #include "base/sha1.h" 26 #include "base/sha1.h"
27 #include "base/single_thread_task_runner.h" 27 #include "base/single_thread_task_runner.h"
28 #include "base/strings/string_number_conversions.h" 28 #include "base/strings/string_number_conversions.h"
29 #include "base/threading/sequenced_worker_pool.h" 29 #include "base/task_scheduler/task_scheduler.h"
30 #include "base/threading/thread_task_runner_handle.h" 30 #include "base/threading/thread_task_runner_handle.h"
31 #include "chrome/browser/history/history_service_factory.h" 31 #include "chrome/browser/history/history_service_factory.h"
32 #include "chrome/browser/safe_browsing/download_feedback_service.h" 32 #include "chrome/browser/safe_browsing/download_feedback_service.h"
33 #include "chrome/browser/safe_browsing/incident_reporting/incident_reporting_ser vice.h" 33 #include "chrome/browser/safe_browsing/incident_reporting/incident_reporting_ser vice.h"
34 #include "chrome/browser/safe_browsing/local_database_manager.h" 34 #include "chrome/browser/safe_browsing/local_database_manager.h"
35 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 35 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
36 #include "chrome/common/safe_browsing/binary_feature_extractor.h" 36 #include "chrome/common/safe_browsing/binary_feature_extractor.h"
37 #include "chrome/common/safe_browsing/file_type_policies_test_util.h" 37 #include "chrome/common/safe_browsing/file_type_policies_test_util.h"
38 #include "chrome/test/base/testing_profile.h" 38 #include "chrome/test/base/testing_profile.h"
39 #include "components/history/core/browser/history_service.h" 39 #include "components/history/core/browser/history_service.h"
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 const std::string& file_basename) { 346 const std::string& file_basename) {
347 for (const auto& archived_binary : request.archived_binary()) { 347 for (const auto& archived_binary : request.archived_binary()) {
348 if (archived_binary.file_basename() == file_basename) 348 if (archived_binary.file_basename() == file_basename)
349 return &archived_binary; 349 return &archived_binary;
350 } 350 }
351 return nullptr; 351 return nullptr;
352 } 352 }
353 353
354 // Flushes any pending tasks in the message loops of all threads. 354 // Flushes any pending tasks in the message loops of all threads.
355 void FlushThreadMessageLoops() { 355 void FlushThreadMessageLoops() {
356 BrowserThread::GetBlockingPool()->FlushForTesting(); 356 base::TaskScheduler::GetInstance()->FlushForTesting();
357 FlushMessageLoop(BrowserThread::IO); 357 FlushMessageLoop(BrowserThread::IO);
358 RunLoop().RunUntilIdle(); 358 RunLoop().RunUntilIdle();
359 } 359 }
360 360
361 // Proxy for private method. 361 // Proxy for private method.
362 static void GetCertificateWhitelistStrings( 362 static void GetCertificateWhitelistStrings(
363 const net::X509Certificate& certificate, 363 const net::X509Certificate& certificate,
364 const net::X509Certificate& issuer, 364 const net::X509Certificate& issuer,
365 std::vector<std::string>* whitelist_strings) { 365 std::vector<std::string>* whitelist_strings) {
366 DownloadProtectionService::GetCertificateWhitelistStrings( 366 DownloadProtectionService::GetCertificateWhitelistStrings(
(...skipping 1978 matching lines...) Expand 10 before | Expand all | Expand 10 after
2345 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 2345 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
2346 base::Unretained(this), run_loop.QuitClosure())); 2346 base::Unretained(this), run_loop.QuitClosure()));
2347 run_loop.Run(); 2347 run_loop.Run();
2348 2348
2349 EXPECT_FALSE(HasClientDownloadRequest()); 2349 EXPECT_FALSE(HasClientDownloadRequest());
2350 // Overriden by flag: 2350 // Overriden by flag:
2351 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); 2351 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS));
2352 } 2352 }
2353 2353
2354 } // namespace safe_browsing 2354 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698