OLD | NEW |
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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 if (waiting_ && IsFinished()) | 214 if (waiting_ && IsFinished()) |
215 base::MessageLoopForUI::current()->Quit(); | 215 base::MessageLoopForUI::current()->Quit(); |
216 } | 216 } |
217 | 217 |
218 void DownloadTestObserver::AcceptDangerousDownload(int32 download_id) { | 218 void DownloadTestObserver::AcceptDangerousDownload(int32 download_id) { |
219 // Download manager was shutdown before the UI thread could accept the | 219 // Download manager was shutdown before the UI thread could accept the |
220 // download. | 220 // download. |
221 if (!download_manager_) | 221 if (!download_manager_) |
222 return; | 222 return; |
223 DownloadItem* download = download_manager_->GetDownload(download_id); | 223 DownloadItem* download = download_manager_->GetDownload(download_id); |
224 if (download && (download->GetState() == DownloadItem::IN_PROGRESS)) | 224 if (download && !download->IsDone()) |
225 download->ValidateDangerousDownload(); | 225 download->ValidateDangerousDownload(); |
226 } | 226 } |
227 | 227 |
228 void DownloadTestObserver::DenyDangerousDownload(int32 download_id) { | 228 void DownloadTestObserver::DenyDangerousDownload(int32 download_id) { |
229 // Download manager was shutdown before the UI thread could deny the | 229 // Download manager was shutdown before the UI thread could deny the |
230 // download. | 230 // download. |
231 if (!download_manager_) | 231 if (!download_manager_) |
232 return; | 232 return; |
233 DownloadItem* download = download_manager_->GetDownload(download_id); | 233 DownloadItem* download = download_manager_->GetDownload(download_id); |
234 if (download && (download->GetState() == DownloadItem::IN_PROGRESS)) { | 234 if (download && !download->IsDone()) |
235 download->Remove(); | 235 download->Remove(); |
236 } | |
237 } | 236 } |
238 | 237 |
239 DownloadTestObserverTerminal::DownloadTestObserverTerminal( | 238 DownloadTestObserverTerminal::DownloadTestObserverTerminal( |
240 DownloadManager* download_manager, | 239 DownloadManager* download_manager, |
241 size_t wait_count, | 240 size_t wait_count, |
242 DangerousDownloadAction dangerous_download_action) | 241 DangerousDownloadAction dangerous_download_action) |
243 : DownloadTestObserver(download_manager, | 242 : DownloadTestObserver(download_manager, |
244 wait_count, | 243 wait_count, |
245 dangerous_download_action) { | 244 dangerous_download_action) { |
246 // You can't rely on overriden virtual functions in a base class constructor; | 245 // You can't rely on overriden virtual functions in a base class constructor; |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 base::MessageLoopForUI::current()->Quit(); | 419 base::MessageLoopForUI::current()->Quit(); |
421 } | 420 } |
422 | 421 |
423 const DownloadUrlParameters::OnStartedCallback | 422 const DownloadUrlParameters::OnStartedCallback |
424 DownloadTestItemCreationObserver::callback() { | 423 DownloadTestItemCreationObserver::callback() { |
425 return base::Bind( | 424 return base::Bind( |
426 &DownloadTestItemCreationObserver::DownloadItemCreationCallback, this); | 425 &DownloadTestItemCreationObserver::DownloadItemCreationCallback, this); |
427 } | 426 } |
428 | 427 |
429 } // namespace content | 428 } // namespace content |
OLD | NEW |