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 "content/browser/download/download_manager_impl.h" | 5 #include "content/browser/download/download_manager_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 explicit MockDownloadItemImpl(DownloadItemImplDelegate* delegate) | 80 explicit MockDownloadItemImpl(DownloadItemImplDelegate* delegate) |
81 : DownloadItemImpl(delegate, | 81 : DownloadItemImpl(delegate, |
82 std::string("7d122682-55b5-4a47-a253-36cadc3e5bee"), | 82 std::string("7d122682-55b5-4a47-a253-36cadc3e5bee"), |
83 content::DownloadItem::kInvalidId, | 83 content::DownloadItem::kInvalidId, |
84 base::FilePath(), | 84 base::FilePath(), |
85 base::FilePath(), | 85 base::FilePath(), |
86 std::vector<GURL>(), | 86 std::vector<GURL>(), |
87 GURL(), | 87 GURL(), |
88 GURL(), | 88 GURL(), |
89 GURL(), | 89 GURL(), |
| 90 GURL(), |
90 "application/octet-stream", | 91 "application/octet-stream", |
91 "application/octet-stream", | 92 "application/octet-stream", |
92 base::Time(), | 93 base::Time(), |
93 base::Time(), | 94 base::Time(), |
94 std::string(), | 95 std::string(), |
95 std::string(), | 96 std::string(), |
96 0, | 97 0, |
97 0, | 98 0, |
98 std::string(), | 99 std::string(), |
99 DownloadItem::COMPLETE, | 100 DownloadItem::COMPLETE, |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 | 245 |
245 // Overridden methods from DownloadItemFactory. | 246 // Overridden methods from DownloadItemFactory. |
246 DownloadItemImpl* CreatePersistedItem( | 247 DownloadItemImpl* CreatePersistedItem( |
247 DownloadItemImplDelegate* delegate, | 248 DownloadItemImplDelegate* delegate, |
248 const std::string& guid, | 249 const std::string& guid, |
249 uint32_t download_id, | 250 uint32_t download_id, |
250 const base::FilePath& current_path, | 251 const base::FilePath& current_path, |
251 const base::FilePath& target_path, | 252 const base::FilePath& target_path, |
252 const std::vector<GURL>& url_chain, | 253 const std::vector<GURL>& url_chain, |
253 const GURL& referrer_url, | 254 const GURL& referrer_url, |
| 255 const GURL& site_instance_url, |
254 const GURL& tab_url, | 256 const GURL& tab_url, |
255 const GURL& tab_referrer_url, | 257 const GURL& tab_referrer_url, |
256 const std::string& mime_type, | 258 const std::string& mime_type, |
257 const std::string& original_mime_type, | 259 const std::string& original_mime_type, |
258 const base::Time& start_time, | 260 const base::Time& start_time, |
259 const base::Time& end_time, | 261 const base::Time& end_time, |
260 const std::string& etag, | 262 const std::string& etag, |
261 const std::string& last_modofied, | 263 const std::string& last_modofied, |
262 int64_t received_bytes, | 264 int64_t received_bytes, |
263 int64_t total_bytes, | 265 int64_t total_bytes, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 } | 317 } |
316 | 318 |
317 DownloadItemImpl* MockDownloadItemFactory::CreatePersistedItem( | 319 DownloadItemImpl* MockDownloadItemFactory::CreatePersistedItem( |
318 DownloadItemImplDelegate* delegate, | 320 DownloadItemImplDelegate* delegate, |
319 const std::string& guid, | 321 const std::string& guid, |
320 uint32_t download_id, | 322 uint32_t download_id, |
321 const base::FilePath& current_path, | 323 const base::FilePath& current_path, |
322 const base::FilePath& target_path, | 324 const base::FilePath& target_path, |
323 const std::vector<GURL>& url_chain, | 325 const std::vector<GURL>& url_chain, |
324 const GURL& referrer_url, | 326 const GURL& referrer_url, |
| 327 const GURL& site_instance_url, |
325 const GURL& tab_url, | 328 const GURL& tab_url, |
326 const GURL& tab_referrer_url, | 329 const GURL& tab_referrer_url, |
327 const std::string& mime_type, | 330 const std::string& mime_type, |
328 const std::string& original_mime_type, | 331 const std::string& original_mime_type, |
329 const base::Time& start_time, | 332 const base::Time& start_time, |
330 const base::Time& end_time, | 333 const base::Time& end_time, |
331 const std::string& etag, | 334 const std::string& etag, |
332 const std::string& last_modified, | 335 const std::string& last_modified, |
333 int64_t received_bytes, | 336 int64_t received_bytes, |
334 int64_t total_bytes, | 337 int64_t total_bytes, |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 | 747 |
745 MockDownloadItemImpl& item = GetMockDownloadItem(0); | 748 MockDownloadItemImpl& item = GetMockDownloadItem(0); |
746 DownloadItem* result = download_manager_->GetDownloadByGuid(item.GetGuid()); | 749 DownloadItem* result = download_manager_->GetDownloadByGuid(item.GetGuid()); |
747 ASSERT_TRUE(result); | 750 ASSERT_TRUE(result); |
748 ASSERT_EQ(static_cast<DownloadItem*>(&item), result); | 751 ASSERT_EQ(static_cast<DownloadItem*>(&item), result); |
749 | 752 |
750 ASSERT_FALSE(download_manager_->GetDownloadByGuid("")); | 753 ASSERT_FALSE(download_manager_->GetDownloadByGuid("")); |
751 | 754 |
752 const char kGuid[] = "8DF158E8-C980-4618-BB03-EBA3242EB48B"; | 755 const char kGuid[] = "8DF158E8-C980-4618-BB03-EBA3242EB48B"; |
753 DownloadItem* persisted_item = download_manager_->CreateDownloadItem( | 756 DownloadItem* persisted_item = download_manager_->CreateDownloadItem( |
754 kGuid, | 757 kGuid, 10, base::FilePath(), base::FilePath(), std::vector<GURL>(), |
755 10, | 758 GURL("http://example.com/a"), GURL("http://example.com/a"), |
756 base::FilePath(), | 759 GURL("http://example.com/a"), GURL("http://example.com/a"), |
757 base::FilePath(), | 760 "application/octet-stream", "application/octet-stream", base::Time::Now(), |
758 std::vector<GURL>(), | 761 base::Time::Now(), std::string(), std::string(), 10, 10, std::string(), |
759 GURL("http://example.com/a"), | 762 DownloadItem::INTERRUPTED, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, |
760 GURL("http://example.com/a"), | 763 DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED, false); |
761 GURL("http://example.com/a"), | |
762 "application/octet-stream", | |
763 "application/octet-stream", | |
764 base::Time::Now(), | |
765 base::Time::Now(), | |
766 std::string(), | |
767 std::string(), | |
768 10, | |
769 10, | |
770 std::string(), | |
771 DownloadItem::INTERRUPTED, | |
772 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, | |
773 DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED, | |
774 false); | |
775 ASSERT_TRUE(persisted_item); | 764 ASSERT_TRUE(persisted_item); |
776 | 765 |
777 ASSERT_EQ(persisted_item, download_manager_->GetDownloadByGuid(kGuid)); | 766 ASSERT_EQ(persisted_item, download_manager_->GetDownloadByGuid(kGuid)); |
778 } | 767 } |
779 | 768 |
780 namespace { | 769 namespace { |
781 | 770 |
782 base::Callback<bool(const GURL&)> GetSingleURLFilter(const GURL& url) { | 771 base::Callback<bool(const GURL&)> GetSingleURLFilter(const GURL& url) { |
783 return base::Bind(&GURL::operator==, base::Owned(new GURL(url))); | 772 return base::Bind(&GURL::operator==, base::Owned(new GURL(url))); |
784 } | 773 } |
(...skipping 14 matching lines...) Expand all Loading... |
799 EXPECT_CALL(GetMockDownloadItem(1), Remove()).Times(0); | 788 EXPECT_CALL(GetMockDownloadItem(1), Remove()).Times(0); |
800 | 789 |
801 base::Callback<bool(const GURL&)> url_filter = | 790 base::Callback<bool(const GURL&)> url_filter = |
802 GetSingleURLFilter(download_urls_[0]); | 791 GetSingleURLFilter(download_urls_[0]); |
803 int remove_count = download_manager_->RemoveDownloadsByURLAndTime( | 792 int remove_count = download_manager_->RemoveDownloadsByURLAndTime( |
804 url_filter, base::Time(), base::Time::Max()); | 793 url_filter, base::Time(), base::Time::Max()); |
805 EXPECT_EQ(remove_count, 1); | 794 EXPECT_EQ(remove_count, 1); |
806 } | 795 } |
807 | 796 |
808 } // namespace content | 797 } // namespace content |
OLD | NEW |