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 <iterator> | 7 #include <iterator> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "net/base/request_priority.h" | 44 #include "net/base/request_priority.h" |
45 #include "net/base/upload_bytes_element_reader.h" | 45 #include "net/base/upload_bytes_element_reader.h" |
46 #include "net/url_request/url_request_context.h" | 46 #include "net/url_request/url_request_context.h" |
47 #include "url/origin.h" | 47 #include "url/origin.h" |
48 | 48 |
49 namespace content { | 49 namespace content { |
50 namespace { | 50 namespace { |
51 | 51 |
52 scoped_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread> BeginDownload( | 52 scoped_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread> BeginDownload( |
53 scoped_ptr<DownloadUrlParameters> params, | 53 scoped_ptr<DownloadUrlParameters> params, |
54 uint32 download_id, | 54 uint32_t download_id, |
55 base::WeakPtr<DownloadManagerImpl> download_manager) { | 55 base::WeakPtr<DownloadManagerImpl> download_manager) { |
56 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 56 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
57 // ResourceDispatcherHost{Base} is-not-a URLRequest::Delegate, and | 57 // ResourceDispatcherHost{Base} is-not-a URLRequest::Delegate, and |
58 // DownloadUrlParameters can-not include resource_dispatcher_host_impl.h, so | 58 // DownloadUrlParameters can-not include resource_dispatcher_host_impl.h, so |
59 // we must down cast. RDHI is the only subclass of RDH as of 2012 May 4. | 59 // we must down cast. RDHI is the only subclass of RDH as of 2012 May 4. |
60 scoped_ptr<net::URLRequest> request( | 60 scoped_ptr<net::URLRequest> request( |
61 params->resource_context()->GetRequestContext()->CreateRequest( | 61 params->resource_context()->GetRequestContext()->CreateRequest( |
62 params->url(), net::DEFAULT_PRIORITY, NULL)); | 62 params->url(), net::DEFAULT_PRIORITY, NULL)); |
63 request->set_method(params->method()); | 63 request->set_method(params->method()); |
64 if (!params->post_body().empty()) { | 64 if (!params->post_body().empty()) { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 .release()); | 141 .release()); |
142 } | 142 } |
143 | 143 |
144 class DownloadItemFactoryImpl : public DownloadItemFactory { | 144 class DownloadItemFactoryImpl : public DownloadItemFactory { |
145 public: | 145 public: |
146 DownloadItemFactoryImpl() {} | 146 DownloadItemFactoryImpl() {} |
147 ~DownloadItemFactoryImpl() override {} | 147 ~DownloadItemFactoryImpl() override {} |
148 | 148 |
149 DownloadItemImpl* CreatePersistedItem( | 149 DownloadItemImpl* CreatePersistedItem( |
150 DownloadItemImplDelegate* delegate, | 150 DownloadItemImplDelegate* delegate, |
151 uint32 download_id, | 151 uint32_t download_id, |
152 const base::FilePath& current_path, | 152 const base::FilePath& current_path, |
153 const base::FilePath& target_path, | 153 const base::FilePath& target_path, |
154 const std::vector<GURL>& url_chain, | 154 const std::vector<GURL>& url_chain, |
155 const GURL& referrer_url, | 155 const GURL& referrer_url, |
156 const std::string& mime_type, | 156 const std::string& mime_type, |
157 const std::string& original_mime_type, | 157 const std::string& original_mime_type, |
158 const base::Time& start_time, | 158 const base::Time& start_time, |
159 const base::Time& end_time, | 159 const base::Time& end_time, |
160 const std::string& etag, | 160 const std::string& etag, |
161 const std::string& last_modified, | 161 const std::string& last_modified, |
162 int64 received_bytes, | 162 int64_t received_bytes, |
163 int64 total_bytes, | 163 int64_t total_bytes, |
164 DownloadItem::DownloadState state, | 164 DownloadItem::DownloadState state, |
165 DownloadDangerType danger_type, | 165 DownloadDangerType danger_type, |
166 DownloadInterruptReason interrupt_reason, | 166 DownloadInterruptReason interrupt_reason, |
167 bool opened, | 167 bool opened, |
168 const net::BoundNetLog& bound_net_log) override { | 168 const net::BoundNetLog& bound_net_log) override { |
169 return new DownloadItemImpl( | 169 return new DownloadItemImpl( |
170 delegate, | 170 delegate, |
171 download_id, | 171 download_id, |
172 current_path, | 172 current_path, |
173 target_path, | 173 target_path, |
174 url_chain, | 174 url_chain, |
175 referrer_url, | 175 referrer_url, |
176 mime_type, | 176 mime_type, |
177 original_mime_type, | 177 original_mime_type, |
178 start_time, | 178 start_time, |
179 end_time, | 179 end_time, |
180 etag, | 180 etag, |
181 last_modified, | 181 last_modified, |
182 received_bytes, | 182 received_bytes, |
183 total_bytes, | 183 total_bytes, |
184 state, | 184 state, |
185 danger_type, | 185 danger_type, |
186 interrupt_reason, | 186 interrupt_reason, |
187 opened, | 187 opened, |
188 bound_net_log); | 188 bound_net_log); |
189 } | 189 } |
190 | 190 |
191 DownloadItemImpl* CreateActiveItem( | 191 DownloadItemImpl* CreateActiveItem( |
192 DownloadItemImplDelegate* delegate, | 192 DownloadItemImplDelegate* delegate, |
193 uint32 download_id, | 193 uint32_t download_id, |
194 const DownloadCreateInfo& info, | 194 const DownloadCreateInfo& info, |
195 const net::BoundNetLog& bound_net_log) override { | 195 const net::BoundNetLog& bound_net_log) override { |
196 return new DownloadItemImpl(delegate, download_id, info, bound_net_log); | 196 return new DownloadItemImpl(delegate, download_id, info, bound_net_log); |
197 } | 197 } |
198 | 198 |
199 DownloadItemImpl* CreateSavePageItem( | 199 DownloadItemImpl* CreateSavePageItem( |
200 DownloadItemImplDelegate* delegate, | 200 DownloadItemImplDelegate* delegate, |
201 uint32 download_id, | 201 uint32_t download_id, |
202 const base::FilePath& path, | 202 const base::FilePath& path, |
203 const GURL& url, | 203 const GURL& url, |
204 const std::string& mime_type, | 204 const std::string& mime_type, |
205 scoped_ptr<DownloadRequestHandleInterface> request_handle, | 205 scoped_ptr<DownloadRequestHandleInterface> request_handle, |
206 const net::BoundNetLog& bound_net_log) override { | 206 const net::BoundNetLog& bound_net_log) override { |
207 return new DownloadItemImpl(delegate, download_id, path, url, | 207 return new DownloadItemImpl(delegate, download_id, path, url, |
208 mime_type, request_handle.Pass(), | 208 mime_type, request_handle.Pass(), |
209 bound_net_log); | 209 bound_net_log); |
210 } | 210 } |
211 }; | 211 }; |
(...skipping 12 matching lines...) Expand all Loading... |
224 net_log_(net_log), | 224 net_log_(net_log), |
225 weak_factory_(this) { | 225 weak_factory_(this) { |
226 DCHECK(browser_context); | 226 DCHECK(browser_context); |
227 } | 227 } |
228 | 228 |
229 DownloadManagerImpl::~DownloadManagerImpl() { | 229 DownloadManagerImpl::~DownloadManagerImpl() { |
230 DCHECK(!shutdown_needed_); | 230 DCHECK(!shutdown_needed_); |
231 } | 231 } |
232 | 232 |
233 DownloadItemImpl* DownloadManagerImpl::CreateActiveItem( | 233 DownloadItemImpl* DownloadManagerImpl::CreateActiveItem( |
234 uint32 id, const DownloadCreateInfo& info) { | 234 uint32_t id, |
| 235 const DownloadCreateInfo& info) { |
235 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 236 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
236 DCHECK(!ContainsKey(downloads_, id)); | 237 DCHECK(!ContainsKey(downloads_, id)); |
237 net::BoundNetLog bound_net_log = | 238 net::BoundNetLog bound_net_log = |
238 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD); | 239 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD); |
239 DownloadItemImpl* download = | 240 DownloadItemImpl* download = |
240 item_factory_->CreateActiveItem(this, id, info, bound_net_log); | 241 item_factory_->CreateActiveItem(this, id, info, bound_net_log); |
241 downloads_[id] = download; | 242 downloads_[id] = download; |
242 return download; | 243 return download; |
243 } | 244 } |
244 | 245 |
245 void DownloadManagerImpl::GetNextId(const DownloadIdCallback& callback) { | 246 void DownloadManagerImpl::GetNextId(const DownloadIdCallback& callback) { |
246 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 247 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
247 if (delegate_) { | 248 if (delegate_) { |
248 delegate_->GetNextId(callback); | 249 delegate_->GetNextId(callback); |
249 return; | 250 return; |
250 } | 251 } |
251 static uint32 next_id = content::DownloadItem::kInvalidId + 1; | 252 static uint32_t next_id = content::DownloadItem::kInvalidId + 1; |
252 callback.Run(next_id++); | 253 callback.Run(next_id++); |
253 } | 254 } |
254 | 255 |
255 void DownloadManagerImpl::DetermineDownloadTarget( | 256 void DownloadManagerImpl::DetermineDownloadTarget( |
256 DownloadItemImpl* item, const DownloadTargetCallback& callback) { | 257 DownloadItemImpl* item, const DownloadTargetCallback& callback) { |
257 // Note that this next call relies on | 258 // Note that this next call relies on |
258 // DownloadItemImplDelegate::DownloadTargetCallback and | 259 // DownloadItemImplDelegate::DownloadTargetCallback and |
259 // DownloadManagerDelegate::DownloadTargetCallback having the same | 260 // DownloadManagerDelegate::DownloadTargetCallback having the same |
260 // type. If the types ever diverge, gasket code will need to | 261 // type. If the types ever diverge, gasket code will need to |
261 // be written here. | 262 // be written here. |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 delegate_->Shutdown(); | 337 delegate_->Shutdown(); |
337 delegate_ = NULL; | 338 delegate_ = NULL; |
338 } | 339 } |
339 | 340 |
340 void DownloadManagerImpl::StartDownload( | 341 void DownloadManagerImpl::StartDownload( |
341 scoped_ptr<DownloadCreateInfo> info, | 342 scoped_ptr<DownloadCreateInfo> info, |
342 scoped_ptr<ByteStreamReader> stream, | 343 scoped_ptr<ByteStreamReader> stream, |
343 const DownloadUrlParameters::OnStartedCallback& on_started) { | 344 const DownloadUrlParameters::OnStartedCallback& on_started) { |
344 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 345 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
345 DCHECK(info); | 346 DCHECK(info); |
346 uint32 download_id = info->download_id; | 347 uint32_t download_id = info->download_id; |
347 const bool new_download = (download_id == content::DownloadItem::kInvalidId); | 348 const bool new_download = (download_id == content::DownloadItem::kInvalidId); |
348 base::Callback<void(uint32)> got_id(base::Bind( | 349 base::Callback<void(uint32_t)> got_id(base::Bind( |
349 &DownloadManagerImpl::StartDownloadWithId, | 350 &DownloadManagerImpl::StartDownloadWithId, weak_factory_.GetWeakPtr(), |
350 weak_factory_.GetWeakPtr(), | 351 base::Passed(&info), base::Passed(&stream), on_started, new_download)); |
351 base::Passed(&info), | |
352 base::Passed(&stream), | |
353 on_started, | |
354 new_download)); | |
355 if (new_download) { | 352 if (new_download) { |
356 GetNextId(got_id); | 353 GetNextId(got_id); |
357 } else { | 354 } else { |
358 got_id.Run(download_id); | 355 got_id.Run(download_id); |
359 } | 356 } |
360 } | 357 } |
361 | 358 |
362 void DownloadManagerImpl::StartDownloadWithId( | 359 void DownloadManagerImpl::StartDownloadWithId( |
363 scoped_ptr<DownloadCreateInfo> info, | 360 scoped_ptr<DownloadCreateInfo> info, |
364 scoped_ptr<ByteStreamReader> stream, | 361 scoped_ptr<ByteStreamReader> stream, |
365 const DownloadUrlParameters::OnStartedCallback& on_started, | 362 const DownloadUrlParameters::OnStartedCallback& on_started, |
366 bool new_download, | 363 bool new_download, |
367 uint32 id) { | 364 uint32_t id) { |
368 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 365 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
369 DCHECK_NE(content::DownloadItem::kInvalidId, id); | 366 DCHECK_NE(content::DownloadItem::kInvalidId, id); |
370 DownloadItemImpl* download = NULL; | 367 DownloadItemImpl* download = NULL; |
371 if (new_download) { | 368 if (new_download) { |
372 download = CreateActiveItem(id, *info); | 369 download = CreateActiveItem(id, *info); |
373 } else { | 370 } else { |
374 DownloadMap::iterator item_iterator = downloads_.find(id); | 371 DownloadMap::iterator item_iterator = downloads_.find(id); |
375 // Trying to resume an interrupted download. | 372 // Trying to resume an interrupted download. |
376 if (item_iterator == downloads_.end() || | 373 if (item_iterator == downloads_.end() || |
377 (item_iterator->second->GetState() == DownloadItem::CANCELLED)) { | 374 (item_iterator->second->GetState() == DownloadItem::CANCELLED)) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 if ((download_item->GetState() == DownloadItem::COMPLETE) && | 434 if ((download_item->GetState() == DownloadItem::COMPLETE) && |
438 !download_item->GetFileExternallyRemoved() && | 435 !download_item->GetFileExternallyRemoved() && |
439 delegate_) { | 436 delegate_) { |
440 delegate_->CheckForFileExistence( | 437 delegate_->CheckForFileExistence( |
441 download_item, | 438 download_item, |
442 base::Bind(&DownloadManagerImpl::OnFileExistenceChecked, | 439 base::Bind(&DownloadManagerImpl::OnFileExistenceChecked, |
443 weak_factory_.GetWeakPtr(), download_item->GetId())); | 440 weak_factory_.GetWeakPtr(), download_item->GetId())); |
444 } | 441 } |
445 } | 442 } |
446 | 443 |
447 void DownloadManagerImpl::OnFileExistenceChecked(uint32 download_id, | 444 void DownloadManagerImpl::OnFileExistenceChecked(uint32_t download_id, |
448 bool result) { | 445 bool result) { |
449 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 446 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
450 if (!result) { // File does not exist. | 447 if (!result) { // File does not exist. |
451 if (ContainsKey(downloads_, download_id)) | 448 if (ContainsKey(downloads_, download_id)) |
452 downloads_[download_id]->OnDownloadedFileRemoved(); | 449 downloads_[download_id]->OnDownloadedFileRemoved(); |
453 } | 450 } |
454 } | 451 } |
455 | 452 |
456 BrowserContext* DownloadManagerImpl::GetBrowserContext() const { | 453 BrowserContext* DownloadManagerImpl::GetBrowserContext() const { |
457 return browser_context_; | 454 return browser_context_; |
(...skipping 15 matching lines...) Expand all Loading... |
473 base::Passed(request_handle.Pass()), | 470 base::Passed(request_handle.Pass()), |
474 item_created)); | 471 item_created)); |
475 } | 472 } |
476 | 473 |
477 void DownloadManagerImpl::CreateSavePackageDownloadItemWithId( | 474 void DownloadManagerImpl::CreateSavePackageDownloadItemWithId( |
478 const base::FilePath& main_file_path, | 475 const base::FilePath& main_file_path, |
479 const GURL& page_url, | 476 const GURL& page_url, |
480 const std::string& mime_type, | 477 const std::string& mime_type, |
481 scoped_ptr<DownloadRequestHandleInterface> request_handle, | 478 scoped_ptr<DownloadRequestHandleInterface> request_handle, |
482 const DownloadItemImplCreated& item_created, | 479 const DownloadItemImplCreated& item_created, |
483 uint32 id) { | 480 uint32_t id) { |
484 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 481 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
485 DCHECK_NE(content::DownloadItem::kInvalidId, id); | 482 DCHECK_NE(content::DownloadItem::kInvalidId, id); |
486 DCHECK(!ContainsKey(downloads_, id)); | 483 DCHECK(!ContainsKey(downloads_, id)); |
487 net::BoundNetLog bound_net_log = | 484 net::BoundNetLog bound_net_log = |
488 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD); | 485 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD); |
489 DownloadItemImpl* download_item = item_factory_->CreateSavePageItem( | 486 DownloadItemImpl* download_item = item_factory_->CreateSavePageItem( |
490 this, | 487 this, |
491 id, | 488 id, |
492 main_file_path, | 489 main_file_path, |
493 page_url, | 490 page_url, |
(...skipping 11 matching lines...) Expand all Loading... |
505 DownloadItem* download_item) { | 502 DownloadItem* download_item) { |
506 FOR_EACH_OBSERVER(Observer, observers_, | 503 FOR_EACH_OBSERVER(Observer, observers_, |
507 OnSavePackageSuccessfullyFinished(this, download_item)); | 504 OnSavePackageSuccessfullyFinished(this, download_item)); |
508 } | 505 } |
509 | 506 |
510 // Resume a download of a specific URL. We send the request to the | 507 // Resume a download of a specific URL. We send the request to the |
511 // ResourceDispatcherHost, and let it send us responses like a regular | 508 // ResourceDispatcherHost, and let it send us responses like a regular |
512 // download. | 509 // download. |
513 void DownloadManagerImpl::ResumeInterruptedDownload( | 510 void DownloadManagerImpl::ResumeInterruptedDownload( |
514 scoped_ptr<content::DownloadUrlParameters> params, | 511 scoped_ptr<content::DownloadUrlParameters> params, |
515 uint32 id) { | 512 uint32_t id) { |
516 RecordDownloadSource(INITIATED_BY_RESUMPTION); | 513 RecordDownloadSource(INITIATED_BY_RESUMPTION); |
517 BrowserThread::PostTaskAndReplyWithResult( | 514 BrowserThread::PostTaskAndReplyWithResult( |
518 BrowserThread::IO, FROM_HERE, | 515 BrowserThread::IO, FROM_HERE, |
519 base::Bind(&BeginDownload, base::Passed(¶ms), id, | 516 base::Bind(&BeginDownload, base::Passed(¶ms), id, |
520 weak_factory_.GetWeakPtr()), | 517 weak_factory_.GetWeakPtr()), |
521 base::Bind(&DownloadManagerImpl::AddUrlDownloader, | 518 base::Bind(&DownloadManagerImpl::AddUrlDownloader, |
522 weak_factory_.GetWeakPtr())); | 519 weak_factory_.GetWeakPtr())); |
523 } | 520 } |
524 | 521 |
525 void DownloadManagerImpl::SetDownloadItemFactoryForTesting( | 522 void DownloadManagerImpl::SetDownloadItemFactoryForTesting( |
526 scoped_ptr<DownloadItemFactory> item_factory) { | 523 scoped_ptr<DownloadItemFactory> item_factory) { |
527 item_factory_ = item_factory.Pass(); | 524 item_factory_ = item_factory.Pass(); |
528 } | 525 } |
529 | 526 |
530 void DownloadManagerImpl::SetDownloadFileFactoryForTesting( | 527 void DownloadManagerImpl::SetDownloadFileFactoryForTesting( |
531 scoped_ptr<DownloadFileFactory> file_factory) { | 528 scoped_ptr<DownloadFileFactory> file_factory) { |
532 file_factory_ = file_factory.Pass(); | 529 file_factory_ = file_factory.Pass(); |
533 } | 530 } |
534 | 531 |
535 DownloadFileFactory* DownloadManagerImpl::GetDownloadFileFactoryForTesting() { | 532 DownloadFileFactory* DownloadManagerImpl::GetDownloadFileFactoryForTesting() { |
536 return file_factory_.get(); | 533 return file_factory_.get(); |
537 } | 534 } |
538 | 535 |
539 void DownloadManagerImpl::DownloadRemoved(DownloadItemImpl* download) { | 536 void DownloadManagerImpl::DownloadRemoved(DownloadItemImpl* download) { |
540 if (!download) | 537 if (!download) |
541 return; | 538 return; |
542 | 539 |
543 uint32 download_id = download->GetId(); | 540 uint32_t download_id = download->GetId(); |
544 if (downloads_.erase(download_id) == 0) | 541 if (downloads_.erase(download_id) == 0) |
545 return; | 542 return; |
546 delete download; | 543 delete download; |
547 } | 544 } |
548 | 545 |
549 void DownloadManagerImpl::AddUrlDownloader( | 546 void DownloadManagerImpl::AddUrlDownloader( |
550 scoped_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread> downloader) { | 547 scoped_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread> downloader) { |
551 if (downloader) | 548 if (downloader) |
552 url_downloaders_.push_back(downloader.Pass()); | 549 url_downloaders_.push_back(downloader.Pass()); |
553 } | 550 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 | 639 |
643 void DownloadManagerImpl::AddObserver(Observer* observer) { | 640 void DownloadManagerImpl::AddObserver(Observer* observer) { |
644 observers_.AddObserver(observer); | 641 observers_.AddObserver(observer); |
645 } | 642 } |
646 | 643 |
647 void DownloadManagerImpl::RemoveObserver(Observer* observer) { | 644 void DownloadManagerImpl::RemoveObserver(Observer* observer) { |
648 observers_.RemoveObserver(observer); | 645 observers_.RemoveObserver(observer); |
649 } | 646 } |
650 | 647 |
651 DownloadItem* DownloadManagerImpl::CreateDownloadItem( | 648 DownloadItem* DownloadManagerImpl::CreateDownloadItem( |
652 uint32 id, | 649 uint32_t id, |
653 const base::FilePath& current_path, | 650 const base::FilePath& current_path, |
654 const base::FilePath& target_path, | 651 const base::FilePath& target_path, |
655 const std::vector<GURL>& url_chain, | 652 const std::vector<GURL>& url_chain, |
656 const GURL& referrer_url, | 653 const GURL& referrer_url, |
657 const std::string& mime_type, | 654 const std::string& mime_type, |
658 const std::string& original_mime_type, | 655 const std::string& original_mime_type, |
659 const base::Time& start_time, | 656 const base::Time& start_time, |
660 const base::Time& end_time, | 657 const base::Time& end_time, |
661 const std::string& etag, | 658 const std::string& etag, |
662 const std::string& last_modified, | 659 const std::string& last_modified, |
663 int64 received_bytes, | 660 int64_t received_bytes, |
664 int64 total_bytes, | 661 int64_t total_bytes, |
665 DownloadItem::DownloadState state, | 662 DownloadItem::DownloadState state, |
666 DownloadDangerType danger_type, | 663 DownloadDangerType danger_type, |
667 DownloadInterruptReason interrupt_reason, | 664 DownloadInterruptReason interrupt_reason, |
668 bool opened) { | 665 bool opened) { |
669 if (ContainsKey(downloads_, id)) { | 666 if (ContainsKey(downloads_, id)) { |
670 NOTREACHED(); | 667 NOTREACHED(); |
671 return NULL; | 668 return NULL; |
672 } | 669 } |
673 DownloadItemImpl* item = item_factory_->CreatePersistedItem( | 670 DownloadItemImpl* item = item_factory_->CreatePersistedItem( |
674 this, | 671 this, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 it->second->GetDangerType() != DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT && | 712 it->second->GetDangerType() != DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT && |
716 it->second->GetDangerType() != DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST && | 713 it->second->GetDangerType() != DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST && |
717 it->second->GetDangerType() != | 714 it->second->GetDangerType() != |
718 DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED) { | 715 DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED) { |
719 ++count; | 716 ++count; |
720 } | 717 } |
721 } | 718 } |
722 return count; | 719 return count; |
723 } | 720 } |
724 | 721 |
725 DownloadItem* DownloadManagerImpl::GetDownload(uint32 download_id) { | 722 DownloadItem* DownloadManagerImpl::GetDownload(uint32_t download_id) { |
726 return ContainsKey(downloads_, download_id) ? downloads_[download_id] : NULL; | 723 return ContainsKey(downloads_, download_id) ? downloads_[download_id] : NULL; |
727 } | 724 } |
728 | 725 |
729 void DownloadManagerImpl::GetAllDownloads(DownloadVector* downloads) { | 726 void DownloadManagerImpl::GetAllDownloads(DownloadVector* downloads) { |
730 for (DownloadMap::iterator it = downloads_.begin(); | 727 for (DownloadMap::iterator it = downloads_.begin(); |
731 it != downloads_.end(); ++it) { | 728 it != downloads_.end(); ++it) { |
732 downloads->push_back(it->second); | 729 downloads->push_back(it->second); |
733 } | 730 } |
734 } | 731 } |
735 | 732 |
(...skipping 11 matching lines...) Expand all Loading... |
747 if (delegate_) | 744 if (delegate_) |
748 delegate_->OpenDownload(download); | 745 delegate_->OpenDownload(download); |
749 } | 746 } |
750 | 747 |
751 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { | 748 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { |
752 if (delegate_) | 749 if (delegate_) |
753 delegate_->ShowDownloadInShell(download); | 750 delegate_->ShowDownloadInShell(download); |
754 } | 751 } |
755 | 752 |
756 } // namespace content | 753 } // namespace content |
OLD | NEW |