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

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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 void DownloadTestFlushObserver::PingIOThread(int cycle) { 342 void DownloadTestFlushObserver::PingIOThread(int cycle) {
343 if (--cycle) { 343 if (--cycle) {
344 BrowserThread::PostTask( 344 BrowserThread::PostTask(
345 BrowserThread::UI, FROM_HERE, 345 BrowserThread::UI, FROM_HERE,
346 base::Bind(&DownloadTestFlushObserver::PingFileThread, this, cycle)); 346 base::Bind(&DownloadTestFlushObserver::PingFileThread, this, cycle));
347 } else { 347 } else {
348 BrowserThread::PostTask( 348 BrowserThread::PostTask(
349 BrowserThread::UI, FROM_HERE, MessageLoop::QuitClosure()); 349 BrowserThread::UI, FROM_HERE, MessageLoop::QuitClosure());
350 } 350 }
351 } 351 }
352
353 DownloadTestItemCreationObserver::DownloadTestItemCreationObserver()
354 : download_id_(content::DownloadId::Invalid()),
355 error_(net::OK),
356 called_back_count_(0),
357 waiting_(false) {
358 }
359
360 DownloadTestItemCreationObserver::~DownloadTestItemCreationObserver() {
361 }
362
363 void DownloadTestItemCreationObserver::WaitForDownloadItemCreation() {
364 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
365
366 if (called_back_count_ == 0) {
367 waiting_ = true;
368 ui_test_utils::RunMessageLoop();
369 waiting_ = false;
370 }
371 }
372
373 void DownloadTestItemCreationObserver::DownloadItemCreationCallback(
374 content::DownloadId download_id, net::Error error) {
375 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
376
377 download_id_ = download_id;
378 error_ = error;
379 ++called_back_count_;
380 DCHECK_EQ(1u, called_back_count_);
381
382 if (waiting_)
383 MessageLoopForUI::current()->Quit();
384 }
385
386 const content::DownloadManager::OnStartedCallback
387 DownloadTestItemCreationObserver::callback() {
388 return base::Bind(
389 &DownloadTestItemCreationObserver::DownloadItemCreationCallback, this);
390 }
391
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698