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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 } | 81 } |
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(FROM_HERE, | 91 update_timer_.Start(base::TimeDelta::FromMilliseconds(kUpdatePeriodMs), |
92 base::TimeDelta::FromMilliseconds(kUpdatePeriodMs), | |
93 this, &DownloadFileManager::UpdateInProgressDownloads); | 92 this, &DownloadFileManager::UpdateInProgressDownloads); |
94 } | 93 } |
95 } | 94 } |
96 | 95 |
97 void DownloadFileManager::StopUpdateTimer() { | 96 void DownloadFileManager::StopUpdateTimer() { |
98 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
99 update_timer_.Stop(); | 98 update_timer_.Stop(); |
100 } | 99 } |
101 | 100 |
102 void DownloadFileManager::UpdateInProgressDownloads() { | 101 void DownloadFileManager::UpdateInProgressDownloads() { |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 << " id = " << id | 430 << " id = " << id |
432 << " download_file = " << download_file->DebugString(); | 431 << " download_file = " << download_file->DebugString(); |
433 | 432 |
434 downloads_.erase(id); | 433 downloads_.erase(id); |
435 | 434 |
436 delete download_file; | 435 delete download_file; |
437 | 436 |
438 if (downloads_.empty()) | 437 if (downloads_.empty()) |
439 StopUpdateTimer(); | 438 StopUpdateTimer(); |
440 } | 439 } |
OLD | NEW |