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

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: Merged with parent 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 ALLOW_THIS_IN_INITIALIZER_LIST(callback_(base::Bind(
357 &DownloadTestItemCreationObserver::DownloadItemCreationCallback,
358 this))) {
359 }
360
361 void DownloadTestItemCreationObserver::WaitForDownloadItemCreation() {
362 if (called_back_count_ == 0) {
363 waiting_ = true;
364 ui_test_utils::RunMessageLoop();
365 waiting_ = false;
366 }
367 }
368
369 void DownloadTestItemCreationObserver::DownloadItemCreationCallback(
370 content::DownloadId download_id, net::Error error) {
371 creation_info_.download_id = download_id;
cbentzel 2012/03/02 21:00:18 Can you add a DCHECK that this is called on the UI
ahendrickson 2012/03/02 21:51:41 Done.
372 creation_info_.error = error;
373 ++called_back_count_;
374
375 if (waiting_ && (called_back_count_ > 0))
376 MessageLoopForUI::current()->Quit();
377 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698