| 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" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "chrome/browser/prefs/browser_prefs.h" | 21 #include "chrome/browser/prefs/browser_prefs.h" |
| 22 #include "chrome/browser/profiles/profile_manager.h" | 22 #include "chrome/browser/profiles/profile_manager.h" |
| 23 #include "chrome/common/chrome_constants.h" | 23 #include "chrome/common/chrome_constants.h" |
| 24 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
| 25 #include "chrome/common/safe_browsing/csd.pb.h" | 25 #include "chrome/common/safe_browsing/csd.pb.h" |
| 26 #include "chrome/test/base/testing_browser_process.h" | 26 #include "chrome/test/base/testing_browser_process.h" |
| 27 #include "chrome/test/base/testing_pref_service_syncable.h" | 27 #include "chrome/test/base/testing_pref_service_syncable.h" |
| 28 #include "chrome/test/base/testing_profile.h" | 28 #include "chrome/test/base/testing_profile.h" |
| 29 #include "chrome/test/base/testing_profile_manager.h" | 29 #include "chrome/test/base/testing_profile_manager.h" |
| 30 #include "components/history/content/browser/download_constants_utils.h" | 30 #include "components/history/content/browser/download_constants_utils.h" |
| 31 #include "components/history/content/browser/history_database_helper.h" |
| 31 #include "components/history/core/browser/download_constants.h" | 32 #include "components/history/core/browser/download_constants.h" |
| 32 #include "components/history/core/browser/download_row.h" | 33 #include "components/history/core/browser/download_row.h" |
| 33 #include "components/history/core/browser/history_constants.h" | 34 #include "components/history/core/browser/history_constants.h" |
| 35 #include "components/history/core/browser/history_database_params.h" |
| 34 #include "content/public/test/test_browser_thread_bundle.h" | 36 #include "content/public/test/test_browser_thread_bundle.h" |
| 35 #include "content/public/test/test_utils.h" | 37 #include "content/public/test/test_utils.h" |
| 36 #include "testing/gtest/include/gtest/gtest.h" | 38 #include "testing/gtest/include/gtest/gtest.h" |
| 37 | 39 |
| 38 namespace { | 40 namespace { |
| 39 | 41 |
| 40 // A BrowserContextKeyedServiceFactory::TestingFactoryFunction that creates a | 42 // A BrowserContextKeyedServiceFactory::TestingFactoryFunction that creates a |
| 41 // HistoryService for a TestingProfile. | 43 // HistoryService for a TestingProfile. |
| 42 KeyedService* BuildHistoryService(content::BrowserContext* context) { | 44 KeyedService* BuildHistoryService(content::BrowserContext* context) { |
| 43 TestingProfile* profile = static_cast<TestingProfile*>(context); | 45 TestingProfile* profile = static_cast<TestingProfile*>(context); |
| 44 | 46 |
| 45 // Delete the file before creating the service. | 47 // Delete the file before creating the service. |
| 46 base::FilePath history_path( | 48 base::FilePath history_path( |
| 47 profile->GetPath().Append(history::kHistoryFilename)); | 49 profile->GetPath().Append(history::kHistoryFilename)); |
| 48 if (!base::DeleteFile(history_path, false) || | 50 if (!base::DeleteFile(history_path, false) || |
| 49 base::PathExists(history_path)) { | 51 base::PathExists(history_path)) { |
| 50 ADD_FAILURE() << "failed to delete history db file " | 52 ADD_FAILURE() << "failed to delete history db file " |
| 51 << history_path.value(); | 53 << history_path.value(); |
| 52 return NULL; | 54 return NULL; |
| 53 } | 55 } |
| 54 | 56 |
| 55 HistoryService* history_service = new HistoryService( | 57 HistoryService* history_service = new HistoryService( |
| 56 ChromeHistoryClientFactory::GetForProfile(profile), profile); | 58 ChromeHistoryClientFactory::GetForProfile(profile), profile); |
| 57 if (history_service->Init(profile->GetPath())) | 59 if (history_service->Init( |
| 60 history::HistoryDatabaseParamsForPath(profile->GetPath()))) { |
| 58 return history_service; | 61 return history_service; |
| 62 } |
| 59 | 63 |
| 60 ADD_FAILURE() << "failed to initialize history service"; | 64 ADD_FAILURE() << "failed to initialize history service"; |
| 61 delete history_service; | 65 delete history_service; |
| 62 return NULL; | 66 return NULL; |
| 63 } | 67 } |
| 64 | 68 |
| 65 } // namespace | 69 } // namespace |
| 66 | 70 |
| 67 namespace safe_browsing { | 71 namespace safe_browsing { |
| 68 | 72 |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 base::Unretained(this), | 342 base::Unretained(this), |
| 339 &last_download, | 343 &last_download, |
| 340 run_loop.QuitClosure()))); | 344 run_loop.QuitClosure()))); |
| 341 | 345 |
| 342 run_loop.Run(); | 346 run_loop.Run(); |
| 343 | 347 |
| 344 ExpectFoundTestDownload(last_download.Pass()); | 348 ExpectFoundTestDownload(last_download.Pass()); |
| 345 } | 349 } |
| 346 | 350 |
| 347 } // namespace safe_browsing | 351 } // namespace safe_browsing |
| OLD | NEW |