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

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: Fixed CLANG issue. 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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 void DownloadTestFlushObserver::PingIOThread(int cycle) { 311 void DownloadTestFlushObserver::PingIOThread(int cycle) {
312 if (--cycle) { 312 if (--cycle) {
313 BrowserThread::PostTask( 313 BrowserThread::PostTask(
314 BrowserThread::UI, FROM_HERE, 314 BrowserThread::UI, FROM_HERE,
315 base::Bind(&DownloadTestFlushObserver::PingFileThread, this, cycle)); 315 base::Bind(&DownloadTestFlushObserver::PingFileThread, this, cycle));
316 } else { 316 } else {
317 BrowserThread::PostTask( 317 BrowserThread::PostTask(
318 BrowserThread::UI, FROM_HERE, MessageLoop::QuitClosure()); 318 BrowserThread::UI, FROM_HERE, MessageLoop::QuitClosure());
319 } 319 }
320 } 320 }
321
322 DownloadTestItemCreationObserver::~DownloadTestItemCreationObserver() {
cbentzel 2012/03/08 17:58:48 Nit: comes after the constructor.
ahendrickson 2012/03/08 21:33:07 Done.
323 }
324
325 DownloadTestItemCreationObserver::DownloadTestItemCreationObserver()
326 : download_id_(content::DownloadId::Invalid()),
327 error_(net::OK),
328 called_back_count_(0),
329 waiting_(false) {
330 }
331
332 void DownloadTestItemCreationObserver::WaitForDownloadItemCreation() {
333 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
334
335 if (called_back_count_ == 0) {
336 waiting_ = true;
337 ui_test_utils::RunMessageLoop();
338 waiting_ = false;
339 }
340 }
341
342 void DownloadTestItemCreationObserver::DownloadItemCreationCallback(
343 content::DownloadId download_id, net::Error error) {
344 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
345
346 download_id_ = download_id;
347 error_ = error;
348 ++called_back_count_;
349
350 if (waiting_ && (called_back_count_ > 0))
cbentzel 2012/03/08 17:58:48 called_back_count_ will always be > 0. Do you need
ahendrickson 2012/03/08 21:33:07 Ah, this is kind of left over from when I was wait
351 MessageLoopForUI::current()->Quit();
352 }
353
354 const content::DownloadManager::OnStartedCallback
355 DownloadTestItemCreationObserver::callback() {
356 return base::Bind(
357 &DownloadTestItemCreationObserver::DownloadItemCreationCallback, this);
358 }
359
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698