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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 base::Time(), | 95 base::Time(), |
96 std::string(), | 96 std::string(), |
97 std::string(), | 97 std::string(), |
98 0, | 98 0, |
99 0, | 99 0, |
100 std::string(), | 100 std::string(), |
101 DownloadItem::COMPLETE, | 101 DownloadItem::COMPLETE, |
102 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, | 102 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, |
103 DOWNLOAD_INTERRUPT_REASON_NONE, | 103 DOWNLOAD_INTERRUPT_REASON_NONE, |
104 false, | 104 false, |
| 105 base::Time(), |
105 std::vector<DownloadItem::ReceivedSlice>(), | 106 std::vector<DownloadItem::ReceivedSlice>(), |
106 net::NetLogWithSource()) {} | 107 net::NetLogWithSource()) {} |
107 virtual ~MockDownloadItemImpl() {} | 108 virtual ~MockDownloadItemImpl() {} |
108 | 109 |
109 MOCK_METHOD4(OnDownloadTargetDetermined, | 110 MOCK_METHOD4(OnDownloadTargetDetermined, |
110 void(const base::FilePath&, TargetDisposition, | 111 void(const base::FilePath&, TargetDisposition, |
111 DownloadDangerType, const base::FilePath&)); | 112 DownloadDangerType, const base::FilePath&)); |
112 MOCK_METHOD1(AddObserver, void(DownloadItem::Observer*)); | 113 MOCK_METHOD1(AddObserver, void(DownloadItem::Observer*)); |
113 MOCK_METHOD1(RemoveObserver, void(DownloadItem::Observer*)); | 114 MOCK_METHOD1(RemoveObserver, void(DownloadItem::Observer*)); |
114 MOCK_METHOD0(UpdateObservers, void()); | 115 MOCK_METHOD0(UpdateObservers, void()); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 const base::Time& end_time, | 263 const base::Time& end_time, |
263 const std::string& etag, | 264 const std::string& etag, |
264 const std::string& last_modofied, | 265 const std::string& last_modofied, |
265 int64_t received_bytes, | 266 int64_t received_bytes, |
266 int64_t total_bytes, | 267 int64_t total_bytes, |
267 const std::string& hash, | 268 const std::string& hash, |
268 DownloadItem::DownloadState state, | 269 DownloadItem::DownloadState state, |
269 DownloadDangerType danger_type, | 270 DownloadDangerType danger_type, |
270 DownloadInterruptReason interrupt_reason, | 271 DownloadInterruptReason interrupt_reason, |
271 bool opened, | 272 bool opened, |
| 273 const base::Time& last_access_time, |
272 const std::vector<DownloadItem::ReceivedSlice>& received_slices, | 274 const std::vector<DownloadItem::ReceivedSlice>& received_slices, |
273 const net::NetLogWithSource& net_log) override; | 275 const net::NetLogWithSource& net_log) override; |
274 DownloadItemImpl* CreateActiveItem( | 276 DownloadItemImpl* CreateActiveItem( |
275 DownloadItemImplDelegate* delegate, | 277 DownloadItemImplDelegate* delegate, |
276 uint32_t download_id, | 278 uint32_t download_id, |
277 const DownloadCreateInfo& info, | 279 const DownloadCreateInfo& info, |
278 const net::NetLogWithSource& net_log) override; | 280 const net::NetLogWithSource& net_log) override; |
279 DownloadItemImpl* CreateSavePageItem( | 281 DownloadItemImpl* CreateSavePageItem( |
280 DownloadItemImplDelegate* delegate, | 282 DownloadItemImplDelegate* delegate, |
281 uint32_t download_id, | 283 uint32_t download_id, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 const base::Time& end_time, | 337 const base::Time& end_time, |
336 const std::string& etag, | 338 const std::string& etag, |
337 const std::string& last_modified, | 339 const std::string& last_modified, |
338 int64_t received_bytes, | 340 int64_t received_bytes, |
339 int64_t total_bytes, | 341 int64_t total_bytes, |
340 const std::string& hash, | 342 const std::string& hash, |
341 DownloadItem::DownloadState state, | 343 DownloadItem::DownloadState state, |
342 DownloadDangerType danger_type, | 344 DownloadDangerType danger_type, |
343 DownloadInterruptReason interrupt_reason, | 345 DownloadInterruptReason interrupt_reason, |
344 bool opened, | 346 bool opened, |
| 347 const base::Time& last_access_time, |
345 const std::vector<DownloadItem::ReceivedSlice>& received_slices, | 348 const std::vector<DownloadItem::ReceivedSlice>& received_slices, |
346 const net::NetLogWithSource& net_log) { | 349 const net::NetLogWithSource& net_log) { |
347 DCHECK(items_.find(download_id) == items_.end()); | 350 DCHECK(items_.find(download_id) == items_.end()); |
348 MockDownloadItemImpl* result = | 351 MockDownloadItemImpl* result = |
349 new StrictMock<MockDownloadItemImpl>(&item_delegate_); | 352 new StrictMock<MockDownloadItemImpl>(&item_delegate_); |
350 EXPECT_CALL(*result, GetId()) | 353 EXPECT_CALL(*result, GetId()) |
351 .WillRepeatedly(Return(download_id)); | 354 .WillRepeatedly(Return(download_id)); |
352 EXPECT_CALL(*result, GetGuid()).WillRepeatedly(ReturnRefOfCopy(guid)); | 355 EXPECT_CALL(*result, GetGuid()).WillRepeatedly(ReturnRefOfCopy(guid)); |
353 items_[download_id] = result; | 356 items_[download_id] = result; |
354 return result; | 357 return result; |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 ASSERT_FALSE(download_manager_->GetDownloadByGuid("")); | 722 ASSERT_FALSE(download_manager_->GetDownloadByGuid("")); |
720 | 723 |
721 const char kGuid[] = "8DF158E8-C980-4618-BB03-EBA3242EB48B"; | 724 const char kGuid[] = "8DF158E8-C980-4618-BB03-EBA3242EB48B"; |
722 DownloadItem* persisted_item = download_manager_->CreateDownloadItem( | 725 DownloadItem* persisted_item = download_manager_->CreateDownloadItem( |
723 kGuid, 10, base::FilePath(), base::FilePath(), std::vector<GURL>(), | 726 kGuid, 10, base::FilePath(), base::FilePath(), std::vector<GURL>(), |
724 GURL("http://example.com/a"), GURL("http://example.com/a"), | 727 GURL("http://example.com/a"), GURL("http://example.com/a"), |
725 GURL("http://example.com/a"), GURL("http://example.com/a"), | 728 GURL("http://example.com/a"), GURL("http://example.com/a"), |
726 "application/octet-stream", "application/octet-stream", base::Time::Now(), | 729 "application/octet-stream", "application/octet-stream", base::Time::Now(), |
727 base::Time::Now(), std::string(), std::string(), 10, 10, std::string(), | 730 base::Time::Now(), std::string(), std::string(), 10, 10, std::string(), |
728 DownloadItem::INTERRUPTED, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, | 731 DownloadItem::INTERRUPTED, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, |
729 DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED, false, | 732 DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED, false, base::Time::Now(), |
730 std::vector<DownloadItem::ReceivedSlice>()); | 733 std::vector<DownloadItem::ReceivedSlice>()); |
731 ASSERT_TRUE(persisted_item); | 734 ASSERT_TRUE(persisted_item); |
732 | 735 |
733 ASSERT_EQ(persisted_item, download_manager_->GetDownloadByGuid(kGuid)); | 736 ASSERT_EQ(persisted_item, download_manager_->GetDownloadByGuid(kGuid)); |
734 } | 737 } |
735 | 738 |
736 namespace { | 739 namespace { |
737 | 740 |
738 base::Callback<bool(const GURL&)> GetSingleURLFilter(const GURL& url) { | 741 base::Callback<bool(const GURL&)> GetSingleURLFilter(const GURL& url) { |
739 return base::Bind(static_cast<bool (*)(const GURL&, const GURL&)>(operator==), | 742 return base::Bind(static_cast<bool (*)(const GURL&, const GURL&)>(operator==), |
(...skipping 16 matching lines...) Expand all Loading... |
756 EXPECT_CALL(GetMockDownloadItem(1), Remove()).Times(0); | 759 EXPECT_CALL(GetMockDownloadItem(1), Remove()).Times(0); |
757 | 760 |
758 base::Callback<bool(const GURL&)> url_filter = | 761 base::Callback<bool(const GURL&)> url_filter = |
759 GetSingleURLFilter(download_urls_[0]); | 762 GetSingleURLFilter(download_urls_[0]); |
760 int remove_count = download_manager_->RemoveDownloadsByURLAndTime( | 763 int remove_count = download_manager_->RemoveDownloadsByURLAndTime( |
761 url_filter, base::Time(), base::Time::Max()); | 764 url_filter, base::Time(), base::Time::Max()); |
762 EXPECT_EQ(remove_count, 1); | 765 EXPECT_EQ(remove_count, 1); |
763 } | 766 } |
764 | 767 |
765 } // namespace content | 768 } // namespace content |
OLD | NEW |