| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/download/download_file_manager.h" | 5 #include "content/browser/download/download_file_manager.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/task.h" | 10 #include "base/task.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 | 82 |
| 83 DownloadFile* DownloadFileManager::GetDownloadFile(int id) { | 83 DownloadFile* DownloadFileManager::GetDownloadFile(int id) { |
| 84 DownloadFileMap::iterator it = downloads_.find(id); | 84 DownloadFileMap::iterator it = downloads_.find(id); |
| 85 return it == downloads_.end() ? NULL : it->second; | 85 return it == downloads_.end() ? NULL : it->second; |
| 86 } | 86 } |
| 87 | 87 |
| 88 void DownloadFileManager::StartUpdateTimer() { | 88 void DownloadFileManager::StartUpdateTimer() { |
| 89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 90 if (!update_timer_.IsRunning()) { | 90 if (!update_timer_.IsRunning()) { |
| 91 update_timer_.Start(base::TimeDelta::FromMilliseconds(kUpdatePeriodMs), | 91 update_timer_.Start(base::TimeDelta::FromMilliseconds(kUpdatePeriodMs), |
| 92 this, &DownloadFileManager::UpdateInProgressDownloads); | 92 this, &DownloadFileManager::UpdateInProgressDownloads, |
| 93 FROM_HERE); |
| 93 } | 94 } |
| 94 } | 95 } |
| 95 | 96 |
| 96 void DownloadFileManager::StopUpdateTimer() { | 97 void DownloadFileManager::StopUpdateTimer() { |
| 97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 98 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 98 update_timer_.Stop(); | 99 update_timer_.Stop(); |
| 99 } | 100 } |
| 100 | 101 |
| 101 void DownloadFileManager::UpdateInProgressDownloads() { | 102 void DownloadFileManager::UpdateInProgressDownloads() { |
| 102 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 103 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 << " id = " << id | 431 << " id = " << id |
| 431 << " download_file = " << download_file->DebugString(); | 432 << " download_file = " << download_file->DebugString(); |
| 432 | 433 |
| 433 downloads_.erase(id); | 434 downloads_.erase(id); |
| 434 | 435 |
| 435 delete download_file; | 436 delete download_file; |
| 436 | 437 |
| 437 if (downloads_.empty()) | 438 if (downloads_.empty()) |
| 438 StopUpdateTimer(); | 439 StopUpdateTimer(); |
| 439 } | 440 } |
| OLD | NEW |