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 <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 } | 62 } |
63 | 63 |
64 class MockDownloadItemImpl : public DownloadItemImpl { | 64 class MockDownloadItemImpl : public DownloadItemImpl { |
65 public: | 65 public: |
66 // Use history constructor for minimal base object. | 66 // Use history constructor for minimal base object. |
67 MockDownloadItemImpl(DownloadItemImplDelegate* delegate) | 67 MockDownloadItemImpl(DownloadItemImplDelegate* delegate) |
68 : DownloadItemImpl( | 68 : DownloadItemImpl( |
69 delegate, | 69 delegate, |
70 content::DownloadId(), | 70 content::DownloadId(), |
71 FilePath(), | 71 FilePath(), |
72 GURL(), | 72 FilePath(), |
| 73 std::vector<GURL>(), |
73 GURL(), | 74 GURL(), |
74 base::Time(), | 75 base::Time(), |
75 base::Time(), | 76 base::Time(), |
76 0, | 77 0, |
77 0, | 78 0, |
78 DownloadItem::IN_PROGRESS, | 79 DownloadItem::IN_PROGRESS, |
| 80 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, |
| 81 DOWNLOAD_INTERRUPT_REASON_NONE, |
79 false, | 82 false, |
80 net::BoundNetLog()) {} | 83 net::BoundNetLog()) {} |
81 virtual ~MockDownloadItemImpl() {} | 84 virtual ~MockDownloadItemImpl() {} |
82 | 85 |
83 MOCK_METHOD4(OnDownloadTargetDetermined, | 86 MOCK_METHOD4(OnDownloadTargetDetermined, |
84 void(const FilePath&, TargetDisposition, | 87 void(const FilePath&, TargetDisposition, |
85 DownloadDangerType, const FilePath&)); | 88 DownloadDangerType, const FilePath&)); |
86 MOCK_METHOD1(AddObserver, void(DownloadItem::Observer*)); | 89 MOCK_METHOD1(AddObserver, void(DownloadItem::Observer*)); |
87 MOCK_METHOD1(RemoveObserver, void(DownloadItem::Observer*)); | 90 MOCK_METHOD1(RemoveObserver, void(DownloadItem::Observer*)); |
88 MOCK_METHOD0(UpdateObservers, void()); | 91 MOCK_METHOD0(UpdateObservers, void()); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 MockDownloadItemImpl* PopItem(); | 219 MockDownloadItemImpl* PopItem(); |
217 | 220 |
218 // Should be called when the item of this id is removed so that | 221 // Should be called when the item of this id is removed so that |
219 // we don't keep dangling pointers. | 222 // we don't keep dangling pointers. |
220 void RemoveItem(int id); | 223 void RemoveItem(int id); |
221 | 224 |
222 // Overridden methods from DownloadItemFactory. | 225 // Overridden methods from DownloadItemFactory. |
223 virtual DownloadItemImpl* CreatePersistedItem( | 226 virtual DownloadItemImpl* CreatePersistedItem( |
224 DownloadItemImplDelegate* delegate, | 227 DownloadItemImplDelegate* delegate, |
225 DownloadId download_id, | 228 DownloadId download_id, |
226 const FilePath& path, | 229 const FilePath& current_path, |
227 const GURL& url, | 230 const FilePath& target_path, |
| 231 const std::vector<GURL>& url_chain, |
228 const GURL& referrer_url, | 232 const GURL& referrer_url, |
229 const base::Time& start_time, | 233 const base::Time& start_time, |
230 const base::Time& end_time, | 234 const base::Time& end_time, |
231 int64 received_bytes, | 235 int64 received_bytes, |
232 int64 total_bytes, | 236 int64 total_bytes, |
233 DownloadItem::DownloadState state, | 237 DownloadItem::DownloadState state, |
| 238 DownloadDangerType danger_type, |
| 239 DownloadInterruptReason interrupt_reason, |
234 bool opened, | 240 bool opened, |
235 const net::BoundNetLog& bound_net_log) OVERRIDE; | 241 const net::BoundNetLog& bound_net_log) OVERRIDE; |
236 virtual DownloadItemImpl* CreateActiveItem( | 242 virtual DownloadItemImpl* CreateActiveItem( |
237 DownloadItemImplDelegate* delegate, | 243 DownloadItemImplDelegate* delegate, |
238 const DownloadCreateInfo& info, | 244 const DownloadCreateInfo& info, |
239 const net::BoundNetLog& bound_net_log) OVERRIDE; | 245 const net::BoundNetLog& bound_net_log) OVERRIDE; |
240 virtual DownloadItemImpl* CreateSavePageItem( | 246 virtual DownloadItemImpl* CreateSavePageItem( |
241 DownloadItemImplDelegate* delegate, | 247 DownloadItemImplDelegate* delegate, |
242 const FilePath& path, | 248 const FilePath& path, |
243 const GURL& url, | 249 const GURL& url, |
(...skipping 30 matching lines...) Expand all Loading... |
274 } | 280 } |
275 | 281 |
276 void MockDownloadItemFactory::RemoveItem(int id) { | 282 void MockDownloadItemFactory::RemoveItem(int id) { |
277 DCHECK(items_.find(id) != items_.end()); | 283 DCHECK(items_.find(id) != items_.end()); |
278 items_.erase(id); | 284 items_.erase(id); |
279 } | 285 } |
280 | 286 |
281 DownloadItemImpl* MockDownloadItemFactory::CreatePersistedItem( | 287 DownloadItemImpl* MockDownloadItemFactory::CreatePersistedItem( |
282 DownloadItemImplDelegate* delegate, | 288 DownloadItemImplDelegate* delegate, |
283 DownloadId download_id, | 289 DownloadId download_id, |
284 const FilePath& path, | 290 const FilePath& current_path, |
285 const GURL& url, | 291 const FilePath& target_path, |
| 292 const std::vector<GURL>& url_chain, |
286 const GURL& referrer_url, | 293 const GURL& referrer_url, |
287 const base::Time& start_time, | 294 const base::Time& start_time, |
288 const base::Time& end_time, | 295 const base::Time& end_time, |
289 int64 received_bytes, | 296 int64 received_bytes, |
290 int64 total_bytes, | 297 int64 total_bytes, |
291 DownloadItem::DownloadState state, | 298 DownloadItem::DownloadState state, |
| 299 DownloadDangerType danger_type, |
| 300 DownloadInterruptReason interrupt_reason, |
292 bool opened, | 301 bool opened, |
293 const net::BoundNetLog& bound_net_log) { | 302 const net::BoundNetLog& bound_net_log) { |
294 int local_id = download_id.local(); | 303 int local_id = download_id.local(); |
295 DCHECK(items_.find(local_id) == items_.end()); | 304 DCHECK(items_.find(local_id) == items_.end()); |
296 | 305 |
297 MockDownloadItemImpl* result = | 306 MockDownloadItemImpl* result = |
298 new StrictMock<MockDownloadItemImpl>(&item_delegate_); | 307 new StrictMock<MockDownloadItemImpl>(&item_delegate_); |
299 EXPECT_CALL(*result, GetId()) | 308 EXPECT_CALL(*result, GetId()) |
300 .WillRepeatedly(Return(local_id)); | 309 .WillRepeatedly(Return(local_id)); |
301 items_[local_id] = result; | 310 items_[local_id] = result; |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 callback_called_ = false; | 651 callback_called_ = false; |
643 DetermineDownloadTarget(&item); | 652 DetermineDownloadTarget(&item); |
644 EXPECT_TRUE(callback_called_); | 653 EXPECT_TRUE(callback_called_); |
645 EXPECT_EQ(path, target_path_); | 654 EXPECT_EQ(path, target_path_); |
646 EXPECT_EQ(DownloadItem::TARGET_DISPOSITION_OVERWRITE, target_disposition_); | 655 EXPECT_EQ(DownloadItem::TARGET_DISPOSITION_OVERWRITE, target_disposition_); |
647 EXPECT_EQ(DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, danger_type_); | 656 EXPECT_EQ(DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, danger_type_); |
648 EXPECT_EQ(path, intermediate_path_); | 657 EXPECT_EQ(path, intermediate_path_); |
649 } | 658 } |
650 | 659 |
651 } // namespace content | 660 } // namespace content |
OLD | NEW |