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/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 | 149 |
150 // Overridden methods from DownloadItemFactory. | 150 // Overridden methods from DownloadItemFactory. |
151 virtual content::DownloadItem* CreatePersistedItem( | 151 virtual content::DownloadItem* CreatePersistedItem( |
152 DownloadItemImpl::Delegate* delegate, | 152 DownloadItemImpl::Delegate* delegate, |
153 content::DownloadId download_id, | 153 content::DownloadId download_id, |
154 const content::DownloadPersistentStoreInfo& info, | 154 const content::DownloadPersistentStoreInfo& info, |
155 const net::BoundNetLog& bound_net_log) OVERRIDE; | 155 const net::BoundNetLog& bound_net_log) OVERRIDE; |
156 virtual content::DownloadItem* CreateActiveItem( | 156 virtual content::DownloadItem* CreateActiveItem( |
157 DownloadItemImpl::Delegate* delegate, | 157 DownloadItemImpl::Delegate* delegate, |
158 const DownloadCreateInfo& info, | 158 const DownloadCreateInfo& info, |
159 DownloadRequestHandleInterface* request_handle, | 159 scoped_ptr<DownloadRequestHandleInterface> request_handle, |
160 bool is_otr, | 160 bool is_otr, |
161 const net::BoundNetLog& bound_net_log) OVERRIDE; | 161 const net::BoundNetLog& bound_net_log) OVERRIDE; |
162 virtual content::DownloadItem* CreateSavePageItem( | 162 virtual content::DownloadItem* CreateSavePageItem( |
163 DownloadItemImpl::Delegate* delegate, | 163 DownloadItemImpl::Delegate* delegate, |
164 const FilePath& path, | 164 const FilePath& path, |
165 const GURL& url, | 165 const GURL& url, |
166 bool is_otr, | 166 bool is_otr, |
167 content::DownloadId download_id, | 167 content::DownloadId download_id, |
168 const std::string& mime_type, | 168 const std::string& mime_type, |
169 const net::BoundNetLog& bound_net_log) OVERRIDE; | 169 const net::BoundNetLog& bound_net_log) OVERRIDE; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 EXPECT_CALL(*result, GetId()) | 213 EXPECT_CALL(*result, GetId()) |
214 .WillRepeatedly(Return(local_id)); | 214 .WillRepeatedly(Return(local_id)); |
215 items_[local_id] = result; | 215 items_[local_id] = result; |
216 | 216 |
217 return result; | 217 return result; |
218 } | 218 } |
219 | 219 |
220 content::DownloadItem* MockDownloadItemFactory::CreateActiveItem( | 220 content::DownloadItem* MockDownloadItemFactory::CreateActiveItem( |
221 DownloadItemImpl::Delegate* delegate, | 221 DownloadItemImpl::Delegate* delegate, |
222 const DownloadCreateInfo& info, | 222 const DownloadCreateInfo& info, |
223 DownloadRequestHandleInterface* request_handle, | 223 scoped_ptr<DownloadRequestHandleInterface> request_handle, |
224 bool is_otr, | 224 bool is_otr, |
225 const net::BoundNetLog& bound_net_log) { | 225 const net::BoundNetLog& bound_net_log) { |
226 int local_id = info.download_id.local(); | 226 int local_id = info.download_id.local(); |
227 DCHECK(items_.find(local_id) == items_.end()); | 227 DCHECK(items_.find(local_id) == items_.end()); |
228 | 228 |
229 content::MockDownloadItem* result = | 229 content::MockDownloadItem* result = |
230 new StrictMock<content::MockDownloadItem>; | 230 new StrictMock<content::MockDownloadItem>; |
231 EXPECT_CALL(*result, GetId()) | 231 EXPECT_CALL(*result, GetId()) |
232 .WillRepeatedly(Return(local_id)); | 232 .WillRepeatedly(Return(local_id)); |
233 items_[local_id] = result; | 233 items_[local_id] = result; |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 UpdateItemInPersistentStore(&item)); | 568 UpdateItemInPersistentStore(&item)); |
569 EXPECT_CALL(item, GetState()) | 569 EXPECT_CALL(item, GetState()) |
570 .WillRepeatedly(Return(DownloadItem::CANCELLED)); | 570 .WillRepeatedly(Return(DownloadItem::CANCELLED)); |
571 EXPECT_CALL(item, GetDbHandle()) | 571 EXPECT_CALL(item, GetDbHandle()) |
572 .WillRepeatedly(Return(db_handle)); | 572 .WillRepeatedly(Return(db_handle)); |
573 | 573 |
574 EXPECT_CALL(item, OffThreadCancel(&GetMockDownloadFileManager())); | 574 EXPECT_CALL(item, OffThreadCancel(&GetMockDownloadFileManager())); |
575 download_manager_->DownloadCancelled(&item); | 575 download_manager_->DownloadCancelled(&item); |
576 EXPECT_EQ(NULL, GetActiveDownloadItem(download_id)); | 576 EXPECT_EQ(NULL, GetActiveDownloadItem(download_id)); |
577 } | 577 } |
OLD | NEW |