OLD | NEW |
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 Loading... |
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 1778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2149 " \"state\": {" | 2154 " \"state\": {" |
2150 " \"previous\": \"in_progress\"," | 2155 " \"previous\": \"in_progress\"," |
2151 " \"current\": \"complete\"}}]", | 2156 " \"current\": \"complete\"}}]", |
2152 result_id, | 2157 result_id, |
2153 GetFilename("on_record.txt.crdownload").c_str(), | 2158 GetFilename("on_record.txt.crdownload").c_str(), |
2154 GetFilename("on_record.txt").c_str()))); | 2159 GetFilename("on_record.txt").c_str()))); |
2155 std::string disk_data; | 2160 std::string disk_data; |
2156 EXPECT_TRUE(file_util::ReadFileToString(item->GetFullPath(), &disk_data)); | 2161 EXPECT_TRUE(file_util::ReadFileToString(item->GetFullPath(), &disk_data)); |
2157 EXPECT_STREQ(kPayloadData, disk_data.c_str()); | 2162 EXPECT_STREQ(kPayloadData, disk_data.c_str()); |
2158 } | 2163 } |
OLD | NEW |