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

Unified Diff: chrome/browser/download/save_page_browsertest.cc

Issue 11363222: Persist download interrupt reason, both target and current paths, and url_chain. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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
Index: chrome/browser/download/save_page_browsertest.cc
diff --git a/chrome/browser/download/save_page_browsertest.cc b/chrome/browser/download/save_page_browsertest.cc
index 37eab12071580e2d57907af1f281d373cb91162a..ed07299f1cac1998944b34e2af79227f775f501c 100644
--- a/chrome/browser/download/save_page_browsertest.cc
+++ b/chrome/browser/download/save_page_browsertest.cc
@@ -291,18 +291,18 @@ class SavePageBrowserTest : public InProcessBrowserTest {
struct DownloadPersistentStoreInfoMatch
: public std::unary_function<DownloadPersistentStoreInfo, bool> {
- DownloadPersistentStoreInfoMatch(const GURL& url,
- const FilePath& path,
+ DownloadPersistentStoreInfoMatch(const std::vector<GURL>& url_chain,
+ const FilePath& target_path,
int64 num_files,
DownloadItem::DownloadState state)
- : url_(url),
- path_(path),
+ : url_chain_(url_chain),
+ target_path_(target_path),
num_files_(num_files),
state_(state) {}
bool operator() (const DownloadPersistentStoreInfo& info) const {
- return info.url == url_ &&
- info.path == path_ &&
+ return info.url_chain == url_chain_ &&
+ info.target_path == target_path_ &&
// For non-MHTML save packages, received_bytes is actually the
// number of files.
((num_files_ < 0) ||
@@ -311,14 +311,14 @@ class SavePageBrowserTest : public InProcessBrowserTest {
info.state == state_;
}
- GURL url_;
- FilePath path_;
+ std::vector<GURL> url_chain_;
+ FilePath target_path_;
int64 num_files_;
DownloadItem::DownloadState state_;
};
void CheckDownloadHistory(const GURL& url,
- const FilePath& path,
+ const FilePath& target_path,
int64 num_files,
DownloadItem::DownloadState state) {
// Make sure the relevant download item made it into the history.
@@ -328,20 +328,22 @@ class SavePageBrowserTest : public InProcessBrowserTest {
QueryDownloadHistory();
+ std::vector<GURL> url_chain;
+ url_chain.push_back(url);
std::vector<DownloadPersistentStoreInfo>::iterator found =
std::find_if(history_entries_.begin(), history_entries_.end(),
- DownloadPersistentStoreInfoMatch(url, path, num_files,
- state));
+ DownloadPersistentStoreInfoMatch(
+ url_chain, target_path, num_files, state));
if (found == history_entries_.end()) {
- LOG(ERROR) << "Missing url=" << url.spec()
- << " path=" << path.value()
+ LOG(ERROR) << "Missing target_path=" << target_path.value()
<< " received=" << num_files
<< " state=" << state;
for (size_t index = 0; index < history_entries_.size(); ++index) {
LOG(ERROR) << "History@" << index << ": url="
- << history_entries_[index].url.spec()
- << " path=" << history_entries_[index].path.value()
+ << "<url chain>"
+ << " target_path="
+ << history_entries_[index].target_path.value()
<< " received=" << history_entries_[index].received_bytes
<< " total=" << history_entries_[index].total_bytes
<< " state=" << history_entries_[index].state;
@@ -601,9 +603,12 @@ IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, RemoveFromList) {
// Should not be in history.
QueryDownloadHistory();
+ std::vector<GURL> url_chain;
+ url_chain.push_back(url);
EXPECT_EQ(std::find_if(history_entries_.begin(), history_entries_.end(),
DownloadPersistentStoreInfoMatch(
- url, full_file_name, 1, DownloadItem::COMPLETE)),
+ url_chain, full_file_name, 1,
+ DownloadItem::COMPLETE)),
history_entries_.end());
EXPECT_TRUE(file_util::PathExists(full_file_name));

Powered by Google App Engine
This is Rietveld 408576698