OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/download/download_item.h" | 5 #include "chrome/browser/download/download_item.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
13 #include "base/timer.h" | 13 #include "base/timer.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "net/base/net_util.h" | 15 #include "net/base/net_util.h" |
16 #include "chrome/browser/browser_thread.h" | 16 #include "chrome/browser/browser_thread.h" |
17 #include "chrome/browser/download/download_extensions.h" | 17 #include "chrome/browser/download/download_extensions.h" |
18 #include "chrome/browser/download/download_file_manager.h" | 18 #include "chrome/browser/download/download_file_manager.h" |
19 #include "chrome/browser/download/download_history.h" | 19 #include "chrome/browser/download/download_history.h" |
20 #include "chrome/browser/download/download_manager.h" | 20 #include "chrome/browser/download/download_manager.h" |
21 #include "chrome/browser/download/download_prefs.h" | 21 #include "chrome/browser/download/download_prefs.h" |
22 #include "chrome/browser/download/download_util.h" | 22 #include "chrome/browser/download/download_util.h" |
23 #include "chrome/browser/history/download_create_info.h" | 23 #include "chrome/browser/history/download_create_info.h" |
24 #include "chrome/browser/platform_util.h" | 24 #include "chrome/browser/platform_util.h" |
25 #include "chrome/browser/prefs/pref_service.h" | 25 #include "chrome/browser/prefs/pref_service.h" |
26 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
27 #include "chrome/common/extensions/extension.h" | 27 #include "chrome/common/extensions/extension.h" |
28 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
29 | 29 |
| 30 // A DownloadItem normally goes through the following states: |
| 31 // * Created (when download starts) |
| 32 // * Made visible to consumers (e.g. Javascript) after the |
| 33 // destination file has been determined. |
| 34 // * Entered into the history database. |
| 35 // * Made visible in the download shelf. |
| 36 // * All data is received. Note that the actual data download occurs |
| 37 // in parallel with the above steps, but until those steps are |
| 38 // complete, completion of the data download will be ignored. |
| 39 // * Download file is renamed to its final name, and possibly |
| 40 // auto-opened. |
| 41 // TODO(rdsmith): This progress should be reflected in |
| 42 // DownloadItem::DownloadState and a state transition table/state diagram. |
| 43 // |
| 44 // TODO(rdsmith): This description should be updated to reflect the cancel |
| 45 // pathways. |
| 46 |
30 namespace { | 47 namespace { |
31 | 48 |
32 // Update frequency (milliseconds). | 49 // Update frequency (milliseconds). |
33 const int kUpdateTimeMs = 1000; | 50 const int kUpdateTimeMs = 1000; |
34 | 51 |
35 void DeleteDownloadedFile(const FilePath& path) { | 52 void DeleteDownloadedFile(const FilePath& path) { |
36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
37 | 54 |
38 // Make sure we only delete files. | 55 // Make sure we only delete files. |
39 if (!file_util::DirectoryExists(path)) | 56 if (!file_util::DirectoryExists(path)) |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 target_name_.value().c_str(), | 561 target_name_.value().c_str(), |
545 full_path().value().c_str()); | 562 full_path().value().c_str()); |
546 } else { | 563 } else { |
547 description += base::StringPrintf(" url = \"%s\"", url().spec().c_str()); | 564 description += base::StringPrintf(" url = \"%s\"", url().spec().c_str()); |
548 } | 565 } |
549 | 566 |
550 description += " }"; | 567 description += " }"; |
551 | 568 |
552 return description; | 569 return description; |
553 } | 570 } |
OLD | NEW |