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

Side by Side Diff: content/public/test/download_test_observer.cc

Issue 11068027: OnDownloadStarted takes DownloadItem* instead of DownloadId (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: @r160830 Created 8 years, 2 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/public/test/download_test_observer.h" 5 #include "content/public/test/download_test_observer.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 BrowserThread::PostTask( 382 BrowserThread::PostTask(
383 BrowserThread::UI, FROM_HERE, 383 BrowserThread::UI, FROM_HERE,
384 base::Bind(&DownloadTestFlushObserver::PingFileThread, this, cycle)); 384 base::Bind(&DownloadTestFlushObserver::PingFileThread, this, cycle));
385 } else { 385 } else {
386 BrowserThread::PostTask( 386 BrowserThread::PostTask(
387 BrowserThread::UI, FROM_HERE, MessageLoop::QuitClosure()); 387 BrowserThread::UI, FROM_HERE, MessageLoop::QuitClosure());
388 } 388 }
389 } 389 }
390 390
391 DownloadTestItemCreationObserver::DownloadTestItemCreationObserver() 391 DownloadTestItemCreationObserver::DownloadTestItemCreationObserver()
392 : download_id_(DownloadId::Invalid()), 392 : download_id_(DownloadId::Invalid().local()),
393 error_(net::OK), 393 error_(net::OK),
394 called_back_count_(0), 394 called_back_count_(0),
395 waiting_(false) { 395 waiting_(false) {
396 } 396 }
397 397
398 DownloadTestItemCreationObserver::~DownloadTestItemCreationObserver() { 398 DownloadTestItemCreationObserver::~DownloadTestItemCreationObserver() {
399 } 399 }
400 400
401 void DownloadTestItemCreationObserver::WaitForDownloadItemCreation() { 401 void DownloadTestItemCreationObserver::WaitForDownloadItemCreation() {
402 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 402 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
403 403
404 if (called_back_count_ == 0) { 404 if (called_back_count_ == 0) {
405 waiting_ = true; 405 waiting_ = true;
406 RunMessageLoop(); 406 RunMessageLoop();
407 waiting_ = false; 407 waiting_ = false;
408 } 408 }
409 } 409 }
410 410
411 void DownloadTestItemCreationObserver::DownloadItemCreationCallback( 411 void DownloadTestItemCreationObserver::DownloadItemCreationCallback(
412 DownloadId download_id, net::Error error) { 412 DownloadItem* item,
413 net::Error error) {
413 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 414 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
414 415
415 download_id_ = download_id; 416 if (item)
417 download_id_ = item->GetId();
416 error_ = error; 418 error_ = error;
417 ++called_back_count_; 419 ++called_back_count_;
418 DCHECK_EQ(1u, called_back_count_); 420 DCHECK_EQ(1u, called_back_count_);
419 421
420 if (waiting_) 422 if (waiting_)
421 MessageLoopForUI::current()->Quit(); 423 MessageLoopForUI::current()->Quit();
422 } 424 }
423 425
424 const DownloadUrlParameters::OnStartedCallback 426 const DownloadUrlParameters::OnStartedCallback
425 DownloadTestItemCreationObserver::callback() { 427 DownloadTestItemCreationObserver::callback() {
426 return base::Bind( 428 return base::Bind(
427 &DownloadTestItemCreationObserver::DownloadItemCreationCallback, this); 429 &DownloadTestItemCreationObserver::DownloadItemCreationCallback, this);
428 } 430 }
429 431
430 } // namespace content 432 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/download_test_observer.h ('k') | content/public/test/mock_download_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698