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

Side by Side Diff: content/browser/download/download_manager_impl_unittest.cc

Issue 2705283003: Added last_access_time to DownloadItem and History DB (Closed)
Patch Set: rebase origin/master Created 3 years, 9 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
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 "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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 uint32_t download_id, 132 uint32_t download_id,
133 const base::FilePath& current_path, 133 const base::FilePath& current_path,
134 const base::FilePath& target_path, 134 const base::FilePath& target_path,
135 const std::vector<GURL>& url_chain, 135 const std::vector<GURL>& url_chain,
136 const GURL& referrer_url, 136 const GURL& referrer_url,
137 const GURL& site_url, 137 const GURL& site_url,
138 const GURL& tab_url, 138 const GURL& tab_url,
139 const GURL& tab_referrer_url, 139 const GURL& tab_referrer_url,
140 const std::string& mime_type, 140 const std::string& mime_type,
141 const std::string& original_mime_type, 141 const std::string& original_mime_type,
142 const base::Time& start_time, 142 base::Time start_time,
143 const base::Time& end_time, 143 base::Time end_time,
144 const std::string& etag, 144 const std::string& etag,
145 const std::string& last_modofied, 145 const std::string& last_modofied,
146 int64_t received_bytes, 146 int64_t received_bytes,
147 int64_t total_bytes, 147 int64_t total_bytes,
148 const std::string& hash, 148 const std::string& hash,
149 DownloadItem::DownloadState state, 149 DownloadItem::DownloadState state,
150 DownloadDangerType danger_type, 150 DownloadDangerType danger_type,
151 DownloadInterruptReason interrupt_reason, 151 DownloadInterruptReason interrupt_reason,
152 bool opened, 152 bool opened,
153 base::Time last_access_time,
153 const std::vector<DownloadItem::ReceivedSlice>& received_slices, 154 const std::vector<DownloadItem::ReceivedSlice>& received_slices,
154 const net::NetLogWithSource& net_log) override; 155 const net::NetLogWithSource& net_log) override;
155 DownloadItemImpl* CreateActiveItem( 156 DownloadItemImpl* CreateActiveItem(
156 DownloadItemImplDelegate* delegate, 157 DownloadItemImplDelegate* delegate,
157 uint32_t download_id, 158 uint32_t download_id,
158 const DownloadCreateInfo& info, 159 const DownloadCreateInfo& info,
159 const net::NetLogWithSource& net_log) override; 160 const net::NetLogWithSource& net_log) override;
160 DownloadItemImpl* CreateSavePageItem( 161 DownloadItemImpl* CreateSavePageItem(
161 DownloadItemImplDelegate* delegate, 162 DownloadItemImplDelegate* delegate,
162 uint32_t download_id, 163 uint32_t download_id,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 uint32_t download_id, 206 uint32_t download_id,
206 const base::FilePath& current_path, 207 const base::FilePath& current_path,
207 const base::FilePath& target_path, 208 const base::FilePath& target_path,
208 const std::vector<GURL>& url_chain, 209 const std::vector<GURL>& url_chain,
209 const GURL& referrer_url, 210 const GURL& referrer_url,
210 const GURL& site_url, 211 const GURL& site_url,
211 const GURL& tab_url, 212 const GURL& tab_url,
212 const GURL& tab_referrer_url, 213 const GURL& tab_referrer_url,
213 const std::string& mime_type, 214 const std::string& mime_type,
214 const std::string& original_mime_type, 215 const std::string& original_mime_type,
215 const base::Time& start_time, 216 base::Time start_time,
216 const base::Time& end_time, 217 base::Time end_time,
217 const std::string& etag, 218 const std::string& etag,
218 const std::string& last_modified, 219 const std::string& last_modified,
219 int64_t received_bytes, 220 int64_t received_bytes,
220 int64_t total_bytes, 221 int64_t total_bytes,
221 const std::string& hash, 222 const std::string& hash,
222 DownloadItem::DownloadState state, 223 DownloadItem::DownloadState state,
223 DownloadDangerType danger_type, 224 DownloadDangerType danger_type,
224 DownloadInterruptReason interrupt_reason, 225 DownloadInterruptReason interrupt_reason,
225 bool opened, 226 bool opened,
227 base::Time last_access_time,
226 const std::vector<DownloadItem::ReceivedSlice>& received_slices, 228 const std::vector<DownloadItem::ReceivedSlice>& received_slices,
227 const net::NetLogWithSource& net_log) { 229 const net::NetLogWithSource& net_log) {
228 DCHECK(items_.find(download_id) == items_.end()); 230 DCHECK(items_.find(download_id) == items_.end());
229 MockDownloadItemImpl* result = 231 MockDownloadItemImpl* result =
230 new StrictMock<MockDownloadItemImpl>(&item_delegate_); 232 new StrictMock<MockDownloadItemImpl>(&item_delegate_);
231 EXPECT_CALL(*result, GetId()) 233 EXPECT_CALL(*result, GetId())
232 .WillRepeatedly(Return(download_id)); 234 .WillRepeatedly(Return(download_id));
233 EXPECT_CALL(*result, GetGuid()).WillRepeatedly(ReturnRefOfCopy(guid)); 235 EXPECT_CALL(*result, GetGuid()).WillRepeatedly(ReturnRefOfCopy(guid));
234 items_[download_id] = result; 236 items_[download_id] = result;
235 return result; 237 return result;
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 ASSERT_FALSE(download_manager_->GetDownloadByGuid("")); 602 ASSERT_FALSE(download_manager_->GetDownloadByGuid(""));
601 603
602 const char kGuid[] = "8DF158E8-C980-4618-BB03-EBA3242EB48B"; 604 const char kGuid[] = "8DF158E8-C980-4618-BB03-EBA3242EB48B";
603 DownloadItem* persisted_item = download_manager_->CreateDownloadItem( 605 DownloadItem* persisted_item = download_manager_->CreateDownloadItem(
604 kGuid, 10, base::FilePath(), base::FilePath(), std::vector<GURL>(), 606 kGuid, 10, base::FilePath(), base::FilePath(), std::vector<GURL>(),
605 GURL("http://example.com/a"), GURL("http://example.com/a"), 607 GURL("http://example.com/a"), GURL("http://example.com/a"),
606 GURL("http://example.com/a"), GURL("http://example.com/a"), 608 GURL("http://example.com/a"), GURL("http://example.com/a"),
607 "application/octet-stream", "application/octet-stream", base::Time::Now(), 609 "application/octet-stream", "application/octet-stream", base::Time::Now(),
608 base::Time::Now(), std::string(), std::string(), 10, 10, std::string(), 610 base::Time::Now(), std::string(), std::string(), 10, 10, std::string(),
609 DownloadItem::INTERRUPTED, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 611 DownloadItem::INTERRUPTED, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
610 DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED, false, 612 DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED, false, base::Time::Now(),
611 std::vector<DownloadItem::ReceivedSlice>()); 613 std::vector<DownloadItem::ReceivedSlice>());
612 ASSERT_TRUE(persisted_item); 614 ASSERT_TRUE(persisted_item);
613 615
614 ASSERT_EQ(persisted_item, download_manager_->GetDownloadByGuid(kGuid)); 616 ASSERT_EQ(persisted_item, download_manager_->GetDownloadByGuid(kGuid));
615 } 617 }
616 618
617 namespace { 619 namespace {
618 620
619 base::Callback<bool(const GURL&)> GetSingleURLFilter(const GURL& url) { 621 base::Callback<bool(const GURL&)> GetSingleURLFilter(const GURL& url) {
620 return base::Bind(static_cast<bool (*)(const GURL&, const GURL&)>(operator==), 622 return base::Bind(static_cast<bool (*)(const GURL&, const GURL&)>(operator==),
(...skipping 16 matching lines...) Expand all
637 EXPECT_CALL(GetMockDownloadItem(1), Remove()).Times(0); 639 EXPECT_CALL(GetMockDownloadItem(1), Remove()).Times(0);
638 640
639 base::Callback<bool(const GURL&)> url_filter = 641 base::Callback<bool(const GURL&)> url_filter =
640 GetSingleURLFilter(download_urls_[0]); 642 GetSingleURLFilter(download_urls_[0]);
641 int remove_count = download_manager_->RemoveDownloadsByURLAndTime( 643 int remove_count = download_manager_->RemoveDownloadsByURLAndTime(
642 url_filter, base::Time(), base::Time::Max()); 644 url_filter, base::Time(), base::Time::Max());
643 EXPECT_EQ(remove_count, 1); 645 EXPECT_EQ(remove_count, 1);
644 } 646 }
645 647
646 } // namespace content 648 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/download_manager_impl.cc ('k') | content/browser/download/mock_download_item_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698