| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/incident_reporting/last_download_finder.h
" | 5 #include "chrome/browser/safe_browsing/incident_reporting/last_download_finder.h
" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 13 #include "base/location.h" |
| 13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 16 #include "base/single_thread_task_runner.h" |
| 15 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 19 #include "base/thread_task_runner_handle.h" |
| 17 #include "chrome/browser/history/chrome_history_client.h" | 20 #include "chrome/browser/history/chrome_history_client.h" |
| 18 #include "chrome/browser/history/chrome_history_client_factory.h" | 21 #include "chrome/browser/history/chrome_history_client_factory.h" |
| 19 #include "chrome/browser/history/history_service_factory.h" | 22 #include "chrome/browser/history/history_service_factory.h" |
| 20 #include "chrome/browser/history/web_history_service_factory.h" | 23 #include "chrome/browser/history/web_history_service_factory.h" |
| 21 #include "chrome/browser/prefs/browser_prefs.h" | 24 #include "chrome/browser/prefs/browser_prefs.h" |
| 22 #include "chrome/browser/profiles/profile_manager.h" | 25 #include "chrome/browser/profiles/profile_manager.h" |
| 23 #include "chrome/common/chrome_constants.h" | 26 #include "chrome/common/chrome_constants.h" |
| 24 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
| 25 #include "chrome/common/safe_browsing/csd.pb.h" | 28 #include "chrome/common/safe_browsing/csd.pb.h" |
| 26 #include "chrome/test/base/testing_browser_process.h" | 29 #include "chrome/test/base/testing_browser_process.h" |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 | 332 |
| 330 // Tests that a download in profile added after the search is begun is found. | 333 // Tests that a download in profile added after the search is begun is found. |
| 331 TEST_F(LastDownloadFinderTest, AddProfileAfterStarting) { | 334 TEST_F(LastDownloadFinderTest, AddProfileAfterStarting) { |
| 332 // Create a profile with a history service that is opted-in. | 335 // Create a profile with a history service that is opted-in. |
| 333 CreateProfile(SAFE_BROWSING_OPT_IN); | 336 CreateProfile(SAFE_BROWSING_OPT_IN); |
| 334 | 337 |
| 335 scoped_ptr<ClientIncidentReport_DownloadDetails> last_download; | 338 scoped_ptr<ClientIncidentReport_DownloadDetails> last_download; |
| 336 base::RunLoop run_loop; | 339 base::RunLoop run_loop; |
| 337 | 340 |
| 338 // Post a task that will create a second profile once the main loop is run. | 341 // Post a task that will create a second profile once the main loop is run. |
| 339 base::MessageLoop::current()->PostTask( | 342 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 340 FROM_HERE, | 343 FROM_HERE, base::Bind(&LastDownloadFinderTest::CreateProfileWithDownload, |
| 341 base::Bind(&LastDownloadFinderTest::CreateProfileWithDownload, | |
| 342 base::Unretained(this))); | 344 base::Unretained(this))); |
| 343 | 345 |
| 344 // Create a finder that we expect will find a download in the second profile. | 346 // Create a finder that we expect will find a download in the second profile. |
| 345 scoped_ptr<LastDownloadFinder> finder(LastDownloadFinder::Create( | 347 scoped_ptr<LastDownloadFinder> finder(LastDownloadFinder::Create( |
| 346 GetDownloadDetailsGetter(), | 348 GetDownloadDetailsGetter(), |
| 347 base::Bind(&LastDownloadFinderTest::OnLastDownload, | 349 base::Bind(&LastDownloadFinderTest::OnLastDownload, |
| 348 base::Unretained(this), | 350 base::Unretained(this), |
| 349 &last_download, | 351 &last_download, |
| 350 run_loop.QuitClosure()))); | 352 run_loop.QuitClosure()))); |
| 351 | 353 |
| 352 run_loop.Run(); | 354 run_loop.Run(); |
| 353 | 355 |
| 354 ExpectFoundTestDownload(last_download.Pass()); | 356 ExpectFoundTestDownload(last_download.Pass()); |
| 355 } | 357 } |
| 356 | 358 |
| 357 } // namespace safe_browsing | 359 } // namespace safe_browsing |
| OLD | NEW |