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

Side by Side Diff: chrome/browser/download/save_page_browsertest.cc

Issue 2853363002: Rename the DownloadService to DownloadCoreService (Closed)
Patch Set: Created 3 years, 7 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
16 #include "base/files/scoped_temp_dir.h" 16 #include "base/files/scoped_temp_dir.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/path_service.h" 18 #include "base/path_service.h"
19 #include "base/run_loop.h" 19 #include "base/run_loop.h"
20 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
21 #include "base/strings/stringprintf.h" 21 #include "base/strings/stringprintf.h"
22 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
23 #include "base/test/test_file_util.h" 23 #include "base/test/test_file_util.h"
24 #include "base/threading/thread_restrictions.h" 24 #include "base/threading/thread_restrictions.h"
25 #include "build/build_config.h" 25 #include "build/build_config.h"
26 #include "chrome/app/chrome_command_ids.h" 26 #include "chrome/app/chrome_command_ids.h"
27 #include "chrome/browser/download/chrome_download_manager_delegate.h" 27 #include "chrome/browser/download/chrome_download_manager_delegate.h"
28 #include "chrome/browser/download/download_core_service.h"
29 #include "chrome/browser/download/download_core_service_factory.h"
28 #include "chrome/browser/download/download_history.h" 30 #include "chrome/browser/download/download_history.h"
29 #include "chrome/browser/download/download_prefs.h" 31 #include "chrome/browser/download/download_prefs.h"
30 #include "chrome/browser/download/download_service.h"
31 #include "chrome/browser/download/download_service_factory.h"
32 #include "chrome/browser/download/save_package_file_picker.h" 32 #include "chrome/browser/download/save_package_file_picker.h"
33 #include "chrome/browser/net/url_request_mock_util.h" 33 #include "chrome/browser/net/url_request_mock_util.h"
34 #include "chrome/browser/profiles/profile.h" 34 #include "chrome/browser/profiles/profile.h"
35 #include "chrome/browser/ui/browser.h" 35 #include "chrome/browser/ui/browser.h"
36 #include "chrome/browser/ui/browser_commands.h" 36 #include "chrome/browser/ui/browser_commands.h"
37 #include "chrome/browser/ui/browser_window.h" 37 #include "chrome/browser/ui/browser_window.h"
38 #include "chrome/browser/ui/tabs/tab_strip_model.h" 38 #include "chrome/browser/ui/tabs/tab_strip_model.h"
39 #include "chrome/common/chrome_paths.h" 39 #include "chrome/common/chrome_paths.h"
40 #include "chrome/common/chrome_switches.h" 40 #include "chrome/common/chrome_switches.h"
41 #include "chrome/common/pref_names.h" 41 #include "chrome/common/pref_names.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 class DownloadPersistedObserver : public DownloadHistory::Observer { 94 class DownloadPersistedObserver : public DownloadHistory::Observer {
95 public: 95 public:
96 typedef base::Callback<bool( 96 typedef base::Callback<bool(
97 DownloadItem* item, 97 DownloadItem* item,
98 const history::DownloadRow&)> PersistedFilter; 98 const history::DownloadRow&)> PersistedFilter;
99 99
100 DownloadPersistedObserver(Profile* profile, const PersistedFilter& filter) 100 DownloadPersistedObserver(Profile* profile, const PersistedFilter& filter)
101 : profile_(profile), 101 : profile_(profile),
102 filter_(filter), 102 filter_(filter),
103 persisted_(false) { 103 persisted_(false) {
104 DownloadServiceFactory::GetForBrowserContext(profile_)-> 104 DownloadCoreServiceFactory::GetForBrowserContext(profile_)
105 GetDownloadHistory()->AddObserver(this); 105 ->GetDownloadHistory()
106 ->AddObserver(this);
106 } 107 }
107 108
108 ~DownloadPersistedObserver() override { 109 ~DownloadPersistedObserver() override {
109 DownloadService* service = DownloadServiceFactory::GetForBrowserContext( 110 DownloadCoreService* service =
110 profile_); 111 DownloadCoreServiceFactory::GetForBrowserContext(profile_);
111 if (service && service->GetDownloadHistory()) 112 if (service && service->GetDownloadHistory())
112 service->GetDownloadHistory()->RemoveObserver(this); 113 service->GetDownloadHistory()->RemoveObserver(this);
113 } 114 }
114 115
115 bool WaitForPersisted() { 116 bool WaitForPersisted() {
116 if (persisted_) 117 if (persisted_)
117 return true; 118 return true;
118 base::RunLoop run_loop; 119 base::RunLoop run_loop;
119 quit_waiting_callback_ = run_loop.QuitClosure(); 120 quit_waiting_callback_ = run_loop.QuitClosure();
120 run_loop.Run(); 121 run_loop.Run();
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 #define MAYBE_SaveHTMLOnlyTabDestroy DISABLED_SaveHTMLOnlyTabDestroy 502 #define MAYBE_SaveHTMLOnlyTabDestroy DISABLED_SaveHTMLOnlyTabDestroy
502 #else 503 #else
503 #define MAYBE_SaveHTMLOnlyTabDestroy SaveHTMLOnlyTabDestroy 504 #define MAYBE_SaveHTMLOnlyTabDestroy SaveHTMLOnlyTabDestroy
504 #endif 505 #endif
505 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, MAYBE_SaveHTMLOnlyTabDestroy) { 506 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, MAYBE_SaveHTMLOnlyTabDestroy) {
506 GURL url = NavigateToMockURL("a"); 507 GURL url = NavigateToMockURL("a");
507 std::unique_ptr<DelayingDownloadManagerDelegate> delaying_delegate( 508 std::unique_ptr<DelayingDownloadManagerDelegate> delaying_delegate(
508 new DelayingDownloadManagerDelegate(browser()->profile())); 509 new DelayingDownloadManagerDelegate(browser()->profile()));
509 delaying_delegate->GetDownloadIdReceiverCallback().Run( 510 delaying_delegate->GetDownloadIdReceiverCallback().Run(
510 content::DownloadItem::kInvalidId + 1); 511 content::DownloadItem::kInvalidId + 1);
511 DownloadServiceFactory::GetForBrowserContext(browser()->profile()) 512 DownloadCoreServiceFactory::GetForBrowserContext(browser()->profile())
512 ->SetDownloadManagerDelegateForTesting(std::move(delaying_delegate)); 513 ->SetDownloadManagerDelegateForTesting(std::move(delaying_delegate));
513 DownloadManager* manager(GetDownloadManager()); 514 DownloadManager* manager(GetDownloadManager());
514 std::vector<DownloadItem*> downloads; 515 std::vector<DownloadItem*> downloads;
515 manager->GetAllDownloads(&downloads); 516 manager->GetAllDownloads(&downloads);
516 ASSERT_EQ(0u, downloads.size()); 517 ASSERT_EQ(0u, downloads.size());
517 518
518 base::FilePath full_file_name, dir; 519 base::FilePath full_file_name, dir;
519 GetDestinationPaths("a", &full_file_name, &dir); 520 GetDestinationPaths("a", &full_file_name, &dir);
520 DownloadItemCreatedObserver creation_observer(manager); 521 DownloadItemCreatedObserver creation_observer(manager);
521 ASSERT_TRUE(GetCurrentTab(browser())->SavePage(full_file_name, dir, 522 ASSERT_TRUE(GetCurrentTab(browser())->SavePage(full_file_name, dir,
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 TestOriginalVsSavedPage(save_page_type, url, 1, 1, expected_substrings); 1348 TestOriginalVsSavedPage(save_page_type, url, 1, 1, expected_substrings);
1348 } 1349 }
1349 1350
1350 INSTANTIATE_TEST_CASE_P( 1351 INSTANTIATE_TEST_CASE_P(
1351 SaveType, 1352 SaveType,
1352 SavePageOriginalVsSavedComparisonTest, 1353 SavePageOriginalVsSavedComparisonTest,
1353 ::testing::Values(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, 1354 ::testing::Values(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML,
1354 content::SAVE_PAGE_TYPE_AS_MHTML)); 1355 content::SAVE_PAGE_TYPE_AS_MHTML));
1355 1356
1356 } // namespace 1357 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698