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

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

Issue 10912183: Remove DownloadManager::GetDownloadItem in favor of GetDownload() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 3 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 "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"
(...skipping 11 matching lines...) Expand all
22 // These functions take scoped_refptr's to DownloadManager because they 22 // These functions take scoped_refptr's to DownloadManager because they
23 // are posted to message queues, and hence may execute arbitrarily after 23 // are posted to message queues, and hence may execute arbitrarily after
24 // their actual posting. Once posted, there is no connection between 24 // their actual posting. Once posted, there is no connection between
25 // these routines and the DownloadTestObserver class from which 25 // these routines and the DownloadTestObserver class from which
26 // they came, so the DownloadTestObserver's reference to the 26 // they came, so the DownloadTestObserver's reference to the
27 // DownloadManager cannot be counted on to keep the DownloadManager around. 27 // DownloadManager cannot be counted on to keep the DownloadManager around.
28 28
29 // Fake user click on "Accept". 29 // Fake user click on "Accept".
30 void AcceptDangerousDownload(scoped_refptr<DownloadManager> download_manager, 30 void AcceptDangerousDownload(scoped_refptr<DownloadManager> download_manager,
31 int32 download_id) { 31 int32 download_id) {
32 DownloadItem* download = download_manager->GetDownloadItem(download_id); 32 DownloadItem* download = download_manager->GetDownload(download_id);
33 download->DangerousDownloadValidated(); 33 if (download && (download->GetState() == DownloadItem::IN_PROGRESS))
34 download->DangerousDownloadValidated();
34 } 35 }
35 36
36 // Fake user click on "Deny". 37 // Fake user click on "Deny".
37 void DenyDangerousDownload(scoped_refptr<DownloadManager> download_manager, 38 void DenyDangerousDownload(scoped_refptr<DownloadManager> download_manager,
38 int32 download_id) { 39 int32 download_id) {
39 DownloadItem* download = download_manager->GetDownloadItem(download_id); 40 DownloadItem* download = download_manager->GetDownload(download_id);
40 ASSERT_TRUE(download->IsPartialDownload()); 41 ASSERT_TRUE(download->IsPartialDownload());
Randy Smith (Not in Mondays) 2012/09/13 18:52:44 (Feel free to ignore; not a natural part of this C
benjhayden 2012/09/13 20:19:36 Done.
41 download->Cancel(true); 42 download->Cancel(true);
42 download->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD); 43 download->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD);
43 } 44 }
44 45
45 } // namespace 46 } // namespace
46 47
47 DownloadTestObserver::DownloadTestObserver( 48 DownloadTestObserver::DownloadTestObserver(
48 DownloadManager* download_manager, 49 DownloadManager* download_manager,
49 size_t wait_count, 50 size_t wait_count,
50 DangerousDownloadAction dangerous_download_action) 51 DangerousDownloadAction dangerous_download_action)
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 MessageLoopForUI::current()->Quit(); 377 MessageLoopForUI::current()->Quit();
377 } 378 }
378 379
379 const DownloadUrlParameters::OnStartedCallback 380 const DownloadUrlParameters::OnStartedCallback
380 DownloadTestItemCreationObserver::callback() { 381 DownloadTestItemCreationObserver::callback() {
381 return base::Bind( 382 return base::Bind(
382 &DownloadTestItemCreationObserver::DownloadItemCreationCallback, this); 383 &DownloadTestItemCreationObserver::DownloadItemCreationCallback, this);
383 } 384 }
384 385
385 } // namespace content 386 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698