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

Side by Side Diff: content/public/test/download_test_observer.cc

Issue 2890853002: Downloads: replace BrowserThread::FILE with task scheduler. (Closed)
Patch Set: Add scoped COM initialization to quench a couple of assertion failures. Created 3 years, 5 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
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 "content/public/test/download_test_observer.h" 5 #include "content/public/test/download_test_observer.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "base/threading/sequenced_worker_pool.h" 13 #include "base/threading/sequenced_worker_pool.h"
14 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/download_manager.h"
15 #include "content/public/browser/download_url_parameters.h" 16 #include "content/public/browser/download_url_parameters.h"
16 #include "content/public/test/test_utils.h" 17 #include "content/public/test/test_utils.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 19
19 namespace content { 20 namespace content {
20 21
21 DownloadUpdatedObserver::DownloadUpdatedObserver( 22 DownloadUpdatedObserver::DownloadUpdatedObserver(
22 DownloadItem* item, DownloadUpdatedObserver::EventFilter filter) 23 DownloadItem* item, DownloadUpdatedObserver::EventFilter filter)
23 : item_(item), 24 : item_(item),
24 filter_(filter), 25 filter_(filter),
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 // of DownloadManager so that we don't have to independently track 380 // of DownloadManager so that we don't have to independently track
380 // whether we are observing it for conditional destruction. 381 // whether we are observing it for conditional destruction.
381 for (DownloadSet::iterator it = downloads_observed_.begin(); 382 for (DownloadSet::iterator it = downloads_observed_.begin();
382 it != downloads_observed_.end(); ++it) { 383 it != downloads_observed_.end(); ++it) {
383 (*it)->RemoveObserver(this); 384 (*it)->RemoveObserver(this);
384 } 385 }
385 downloads_observed_.clear(); 386 downloads_observed_.clear();
386 387
387 // Trigger next step. We need to go past the IO thread twice, as 388 // Trigger next step. We need to go past the IO thread twice, as
388 // there's a self-task posting in the IO thread cancel path. 389 // there's a self-task posting in the IO thread cancel path.
389 BrowserThread::PostTask( 390 DownloadManager::GetTaskRunner()->PostTask(
390 BrowserThread::FILE, FROM_HERE, 391 FROM_HERE,
391 base::Bind(&DownloadTestFlushObserver::PingFileThread, this, 2)); 392 base::Bind(&DownloadTestFlushObserver::PingFileThread, this, 2));
392 } 393 }
393 } 394 }
394 } 395 }
395 396
396 void DownloadTestFlushObserver::PingFileThread(int cycle) { 397 void DownloadTestFlushObserver::PingFileThread(int cycle) {
397 BrowserThread::PostTask( 398 BrowserThread::PostTask(
398 BrowserThread::IO, FROM_HERE, 399 BrowserThread::IO, FROM_HERE,
399 base::Bind(&DownloadTestFlushObserver::PingIOThread, this, cycle)); 400 base::Bind(&DownloadTestFlushObserver::PingIOThread, this, cycle));
400 } 401 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 } 486 }
486 487
487 void SavePackageFinishedObserver::ManagerGoingDown(DownloadManager* manager) { 488 void SavePackageFinishedObserver::ManagerGoingDown(DownloadManager* manager) {
488 download_->RemoveObserver(this); 489 download_->RemoveObserver(this);
489 download_ = NULL; 490 download_ = NULL;
490 download_manager_->RemoveObserver(this); 491 download_manager_->RemoveObserver(this);
491 download_manager_ = NULL; 492 download_manager_ = NULL;
492 } 493 }
493 494
494 } // namespace content 495 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698