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

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

Issue 1010963002: favor DCHECK_CURRENTLY_ON for better logs in content/{public,shell,test}/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 5 years, 9 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
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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 DownloadItem* download) { 307 DownloadItem* download) {
308 return download->GetState() == DownloadItem::INTERRUPTED; 308 return download->GetState() == DownloadItem::INTERRUPTED;
309 } 309 }
310 310
311 DownloadTestFlushObserver::DownloadTestFlushObserver( 311 DownloadTestFlushObserver::DownloadTestFlushObserver(
312 DownloadManager* download_manager) 312 DownloadManager* download_manager)
313 : download_manager_(download_manager), 313 : download_manager_(download_manager),
314 waiting_for_zero_inprogress_(true) {} 314 waiting_for_zero_inprogress_(true) {}
315 315
316 void DownloadTestFlushObserver::WaitForFlush() { 316 void DownloadTestFlushObserver::WaitForFlush() {
317 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 317 DCHECK_CURRENTLY_ON(BrowserThread::UI);
318 download_manager_->AddObserver(this); 318 download_manager_->AddObserver(this);
319 // The wait condition may have been met before WaitForFlush() was called. 319 // The wait condition may have been met before WaitForFlush() was called.
320 CheckDownloadsInProgress(true); 320 CheckDownloadsInProgress(true);
321 BrowserThread::GetBlockingPool()->FlushForTesting(); 321 BrowserThread::GetBlockingPool()->FlushForTesting();
322 RunMessageLoop(); 322 RunMessageLoop();
323 } 323 }
324 324
325 void DownloadTestFlushObserver::OnDownloadCreated( 325 void DownloadTestFlushObserver::OnDownloadCreated(
326 DownloadManager* manager, 326 DownloadManager* manager,
327 DownloadItem* item) { 327 DownloadItem* item) {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 : download_id_(DownloadItem::kInvalidId), 415 : download_id_(DownloadItem::kInvalidId),
416 interrupt_reason_(DOWNLOAD_INTERRUPT_REASON_NONE), 416 interrupt_reason_(DOWNLOAD_INTERRUPT_REASON_NONE),
417 called_back_count_(0), 417 called_back_count_(0),
418 waiting_(false) { 418 waiting_(false) {
419 } 419 }
420 420
421 DownloadTestItemCreationObserver::~DownloadTestItemCreationObserver() { 421 DownloadTestItemCreationObserver::~DownloadTestItemCreationObserver() {
422 } 422 }
423 423
424 void DownloadTestItemCreationObserver::WaitForDownloadItemCreation() { 424 void DownloadTestItemCreationObserver::WaitForDownloadItemCreation() {
425 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 425 DCHECK_CURRENTLY_ON(BrowserThread::UI);
426 426
427 if (called_back_count_ == 0) { 427 if (called_back_count_ == 0) {
428 waiting_ = true; 428 waiting_ = true;
429 RunMessageLoop(); 429 RunMessageLoop();
430 waiting_ = false; 430 waiting_ = false;
431 } 431 }
432 } 432 }
433 433
434 void DownloadTestItemCreationObserver::DownloadItemCreationCallback( 434 void DownloadTestItemCreationObserver::DownloadItemCreationCallback(
435 DownloadItem* item, 435 DownloadItem* item,
436 DownloadInterruptReason interrupt_reason) { 436 DownloadInterruptReason interrupt_reason) {
437 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 437 DCHECK_CURRENTLY_ON(BrowserThread::UI);
438 438
439 if (item) 439 if (item)
440 download_id_ = item->GetId(); 440 download_id_ = item->GetId();
441 interrupt_reason_ = interrupt_reason; 441 interrupt_reason_ = interrupt_reason;
442 ++called_back_count_; 442 ++called_back_count_;
443 DCHECK_EQ(1u, called_back_count_); 443 DCHECK_EQ(1u, called_back_count_);
444 444
445 if (waiting_) 445 if (waiting_)
446 base::MessageLoopForUI::current()->Quit(); 446 base::MessageLoopForUI::current()->Quit();
447 } 447 }
448 448
449 const DownloadUrlParameters::OnStartedCallback 449 const DownloadUrlParameters::OnStartedCallback
450 DownloadTestItemCreationObserver::callback() { 450 DownloadTestItemCreationObserver::callback() {
451 return base::Bind( 451 return base::Bind(
452 &DownloadTestItemCreationObserver::DownloadItemCreationCallback, this); 452 &DownloadTestItemCreationObserver::DownloadItemCreationCallback, this);
453 } 453 }
454 454
455 } // namespace content 455 } // namespace content
OLDNEW
« no previous file with comments | « content/public/browser/push_messaging_service.cc ('k') | content/public/test/fake_speech_recognition_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698