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

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

Issue 18284005: Make ByteStream independent from DownloadInterruptReason (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rdsmith's comments Created 7 years, 4 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 | Annotate | Revision Log
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 <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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 // We'll have nothing more to report to the observers after this point. 347 // We'll have nothing more to report to the observers after this point.
348 observers_.Clear(); 348 observers_.Clear();
349 349
350 if (delegate_) 350 if (delegate_)
351 delegate_->Shutdown(); 351 delegate_->Shutdown();
352 delegate_ = NULL; 352 delegate_ = NULL;
353 } 353 }
354 354
355 void DownloadManagerImpl::StartDownload( 355 void DownloadManagerImpl::StartDownload(
356 scoped_ptr<DownloadCreateInfo> info, 356 scoped_ptr<DownloadCreateInfo> info,
357 scoped_ptr<ByteStreamReader> stream, 357 scoped_ptr<ByteStreamReader<DownloadInterruptReason> > stream,
358 const DownloadUrlParameters::OnStartedCallback& on_started) { 358 const DownloadUrlParameters::OnStartedCallback& on_started) {
359 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 359 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
360 DCHECK(info); 360 DCHECK(info);
361 uint32 download_id = info->download_id; 361 uint32 download_id = info->download_id;
362 const bool new_download = (download_id == content::DownloadItem::kInvalidId); 362 const bool new_download = (download_id == content::DownloadItem::kInvalidId);
363 base::Callback<void(uint32)> got_id(base::Bind( 363 base::Callback<void(uint32)> got_id(base::Bind(
364 &DownloadManagerImpl::StartDownloadWithId, 364 &DownloadManagerImpl::StartDownloadWithId,
365 weak_factory_.GetWeakPtr(), 365 weak_factory_.GetWeakPtr(),
366 base::Passed(info.Pass()), 366 base::Passed(info.Pass()),
367 base::Passed(stream.Pass()), 367 base::Passed(stream.Pass()),
368 on_started, 368 on_started,
369 new_download)); 369 new_download));
370 if (new_download) { 370 if (new_download) {
371 GetNextId(got_id); 371 GetNextId(got_id);
372 } else { 372 } else {
373 got_id.Run(download_id); 373 got_id.Run(download_id);
374 } 374 }
375 } 375 }
376 376
377 void DownloadManagerImpl::StartDownloadWithId( 377 void DownloadManagerImpl::StartDownloadWithId(
378 scoped_ptr<DownloadCreateInfo> info, 378 scoped_ptr<DownloadCreateInfo> info,
379 scoped_ptr<ByteStreamReader> stream, 379 scoped_ptr<ByteStreamReader<DownloadInterruptReason> > stream,
380 const DownloadUrlParameters::OnStartedCallback& on_started, 380 const DownloadUrlParameters::OnStartedCallback& on_started,
381 bool new_download, 381 bool new_download,
382 uint32 id) { 382 uint32 id) {
383 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 383 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
384 DCHECK_NE(content::DownloadItem::kInvalidId, id); 384 DCHECK_NE(content::DownloadItem::kInvalidId, id);
385 DownloadItemImpl* download = NULL; 385 DownloadItemImpl* download = NULL;
386 if (new_download) { 386 if (new_download) {
387 download = CreateActiveItem(id, *info); 387 download = CreateActiveItem(id, *info);
388 } else { 388 } else {
389 DownloadMap::iterator item_iterator = downloads_.find(id); 389 DownloadMap::iterator item_iterator = downloads_.find(id);
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 if (delegate_) 682 if (delegate_)
683 delegate_->OpenDownload(download); 683 delegate_->OpenDownload(download);
684 } 684 }
685 685
686 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { 686 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) {
687 if (delegate_) 687 if (delegate_)
688 delegate_->ShowDownloadInShell(download); 688 delegate_->ShowDownloadInShell(download);
689 } 689 }
690 690
691 } // namespace content 691 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/download_manager_impl.h ('k') | content/browser/download/download_manager_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698