Chromium Code Reviews| 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/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 Loading... | |
| 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, net::Error error) { |
|
sky
2012/10/09 16:16:11
nit: when you wrap, each param on its own line.
benjhayden
2012/10/09 20:57:18
Done.
| |
| 413 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 413 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 414 | 414 |
| 415 download_id_ = download_id; | 415 if (item) |
| 416 download_id_ = item->GetId(); | |
| 416 error_ = error; | 417 error_ = error; |
| 417 ++called_back_count_; | 418 ++called_back_count_; |
| 418 DCHECK_EQ(1u, called_back_count_); | 419 DCHECK_EQ(1u, called_back_count_); |
| 419 | 420 |
| 420 if (waiting_) | 421 if (waiting_) |
| 421 MessageLoopForUI::current()->Quit(); | 422 MessageLoopForUI::current()->Quit(); |
| 422 } | 423 } |
| 423 | 424 |
| 424 const DownloadUrlParameters::OnStartedCallback | 425 const DownloadUrlParameters::OnStartedCallback |
| 425 DownloadTestItemCreationObserver::callback() { | 426 DownloadTestItemCreationObserver::callback() { |
| 426 return base::Bind( | 427 return base::Bind( |
| 427 &DownloadTestItemCreationObserver::DownloadItemCreationCallback, this); | 428 &DownloadTestItemCreationObserver::DownloadItemCreationCallback, this); |
| 428 } | 429 } |
| 429 | 430 |
| 430 } // namespace content | 431 } // namespace content |
| OLD | NEW |