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

Side by Side Diff: chrome/browser/download/download_test_observer.cc

Issue 9570005: Added callback to DownloadUrl() so we can find download failures. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added thread checks. Created 8 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 | 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 <vector> 5 #include <vector>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 void DownloadTestFlushObserver::PingIOThread(int cycle) { 339 void DownloadTestFlushObserver::PingIOThread(int cycle) {
340 if (--cycle) { 340 if (--cycle) {
341 BrowserThread::PostTask( 341 BrowserThread::PostTask(
342 BrowserThread::UI, FROM_HERE, 342 BrowserThread::UI, FROM_HERE,
343 base::Bind(&DownloadTestFlushObserver::PingFileThread, this, cycle)); 343 base::Bind(&DownloadTestFlushObserver::PingFileThread, this, cycle));
344 } else { 344 } else {
345 BrowserThread::PostTask( 345 BrowserThread::PostTask(
346 BrowserThread::UI, FROM_HERE, MessageLoop::QuitClosure()); 346 BrowserThread::UI, FROM_HERE, MessageLoop::QuitClosure());
347 } 347 }
348 } 348 }
349
350 DownloadTestItemCreationObserver::~DownloadTestItemCreationObserver() {
351 }
352
353 DownloadTestItemCreationObserver::DownloadTestItemCreationObserver()
354 : called_back_count_(0),
355 waiting_(false) {
356 }
357
358 void DownloadTestItemCreationObserver::WaitForDownloadItemCreation() {
359 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
360
361 if (called_back_count_ == 0) {
362 waiting_ = true;
363 ui_test_utils::RunMessageLoop();
364 waiting_ = false;
365 }
366 }
367
368 void DownloadTestItemCreationObserver::DownloadItemCreationCallback(
369 content::DownloadId download_id, net::Error error) {
370 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
371
372 creation_info_.download_id = download_id;
373 creation_info_.error = error;
374 ++called_back_count_;
375
376 if (waiting_ && (called_back_count_ > 0))
377 MessageLoopForUI::current()->Quit();
378 }
379
380 const content::DownloadManager::OnStartedCallback
381 DownloadTestItemCreationObserver::callback() {
382 return base::Bind(
383 &DownloadTestItemCreationObserver::DownloadItemCreationCallback, this);
384 }
385
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698