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

Side by Side Diff: chrome/browser/extensions/api/downloads/downloads_api_unittest.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: Merged to r180302 Created 7 years, 10 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 | Annotate | Revision Log
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 <algorithm> 5 #include <algorithm>
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 // |items| will contain |count| DownloadItems in the order that they were 344 // |items| will contain |count| DownloadItems in the order that they were
345 // specified in |history_info|. Returns true on success and false otherwise. 345 // specified in |history_info|. Returns true on success and false otherwise.
346 bool CreateHistoryDownloads(const HistoryDownloadInfo* history_info, 346 bool CreateHistoryDownloads(const HistoryDownloadInfo* history_info,
347 size_t count, 347 size_t count,
348 DownloadManager::DownloadVector* items) { 348 DownloadManager::DownloadVector* items) {
349 DownloadIdComparator download_id_comparator; 349 DownloadIdComparator download_id_comparator;
350 base::Time current = base::Time::Now(); 350 base::Time current = base::Time::Now();
351 items->clear(); 351 items->clear();
352 GetOnRecordManager()->GetAllDownloads(items); 352 GetOnRecordManager()->GetAllDownloads(items);
353 CHECK_EQ(0, static_cast<int>(items->size())); 353 CHECK_EQ(0, static_cast<int>(items->size()));
354 std::vector<GURL> url_chain;
355 url_chain.push_back(GURL());
354 for (size_t i = 0; i < count; ++i) { 356 for (size_t i = 0; i < count; ++i) {
355 DownloadItem* item = GetOnRecordManager()->CreateDownloadItem( 357 DownloadItem* item = GetOnRecordManager()->CreateDownloadItem(
356 downloads_directory().Append(history_info[i].filename), 358 downloads_directory().Append(history_info[i].filename),
357 GURL(), GURL(), // URL, referrer 359 downloads_directory().Append(history_info[i].filename),
360 url_chain, GURL(), // URL Chain, referrer
358 current, current, // start_time, end_time 361 current, current, // start_time, end_time
359 1, 1, // received_bytes, total_bytes 362 1, 1, // received_bytes, total_bytes
360 history_info[i].state, // state 363 history_info[i].state, // state
364 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
365 content::DOWNLOAD_INTERRUPT_REASON_NONE,
361 false); // opened 366 false); // opened
362 items->push_back(item); 367 items->push_back(item);
363 } 368 }
364 369
365 // Order by ID so that they are in the order that we created them. 370 // Order by ID so that they are in the order that we created them.
366 std::sort(items->begin(), items->end(), download_id_comparator); 371 std::sort(items->begin(), items->end(), download_id_comparator);
367 // Set the danger type if necessary. 372 // Set the danger type if necessary.
368 for (size_t i = 0; i < count; ++i) { 373 for (size_t i = 0; i < count; ++i) {
369 if (history_info[i].danger_type != 374 if (history_info[i].danger_type !=
370 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS) { 375 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS) {
(...skipping 1752 matching lines...) Expand 10 before | Expand all | Expand 10 after
2123 " \"state\": {" 2128 " \"state\": {"
2124 " \"previous\": \"in_progress\"," 2129 " \"previous\": \"in_progress\","
2125 " \"current\": \"complete\"}}]", 2130 " \"current\": \"complete\"}}]",
2126 result_id, 2131 result_id,
2127 GetFilename("on_record.txt.crdownload").c_str(), 2132 GetFilename("on_record.txt.crdownload").c_str(),
2128 GetFilename("on_record.txt").c_str()))); 2133 GetFilename("on_record.txt").c_str())));
2129 std::string disk_data; 2134 std::string disk_data;
2130 EXPECT_TRUE(file_util::ReadFileToString(item->GetFullPath(), &disk_data)); 2135 EXPECT_TRUE(file_util::ReadFileToString(item->GetFullPath(), &disk_data));
2131 EXPECT_STREQ(kPayloadData, disk_data.c_str()); 2136 EXPECT_STREQ(kPayloadData, disk_data.c_str());
2132 } 2137 }
OLDNEW
« no previous file with comments | « chrome/browser/download/save_page_browsertest.cc ('k') | chrome/browser/history/download_database.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698