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

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 trunk 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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 void DownloadTestFlushObserver::PingIOThread(int cycle) { 334 void DownloadTestFlushObserver::PingIOThread(int cycle) {
335 if (--cycle) { 335 if (--cycle) {
336 BrowserThread::PostTask( 336 BrowserThread::PostTask(
337 BrowserThread::UI, FROM_HERE, 337 BrowserThread::UI, FROM_HERE,
338 base::Bind(&DownloadTestFlushObserver::PingFileThread, this, cycle)); 338 base::Bind(&DownloadTestFlushObserver::PingFileThread, this, cycle));
339 } else { 339 } else {
340 BrowserThread::PostTask( 340 BrowserThread::PostTask(
341 BrowserThread::UI, FROM_HERE, MessageLoop::QuitClosure()); 341 BrowserThread::UI, FROM_HERE, MessageLoop::QuitClosure());
342 } 342 }
343 } 343 }
344
345 DownloadTestItemCreationObserver::DownloadTestItemCreationObserver(size_t count)
346 : expected_count_(count),
347 called_back_count_(0),
348 waiting_(false),
349 ALLOW_THIS_IN_INITIALIZER_LIST(callback_(base::Bind(
350 &DownloadTestItemCreationObserver::DownloadItemCreationCallback,
351 this))) {
352 creation_info_.resize(count);
353 }
354
355 void DownloadTestItemCreationObserver::WaitForDownloadItemCreation() {
356 if (called_back_count_ < expected_count_) {
357 waiting_ = true;
358 ui_test_utils::RunMessageLoop();
359 waiting_ = false;
360 }
361 }
362
363 void DownloadTestItemCreationObserver::DownloadItemCreationCallback(
364 content::DownloadId download_id, net::Error error) {
365 if (called_back_count_ >= creation_info_.size())
366 creation_info_.resize(creation_info_.size() + 1);
367 creation_info_[called_back_count_].download_id = download_id;
368 creation_info_[called_back_count_].error = error;
369 ++called_back_count_;
370
371 if (waiting_ && (called_back_count_ >= expected_count_))
372 MessageLoopForUI::current()->Quit();
373 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698