| 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 // The DownloadManager object manages the process of downloading, including | 5 // The DownloadManager object manages the process of downloading, including |
| 6 // updates to the history system and providing the information for displaying | 6 // updates to the history system and providing the information for displaying |
| 7 // the downloads view in the Destinations tab. There is one DownloadManager per | 7 // the downloads view in the Destinations tab. There is one DownloadManager per |
| 8 // active profile in Chrome. | 8 // active profile in Chrome. |
| 9 // | 9 // |
| 10 // Each download is represented by a DownloadItem, and all DownloadItems | 10 // Each download is represented by a DownloadItem, and all DownloadItems |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 // Constructing from persistent store: | 107 // Constructing from persistent store: |
| 108 explicit DownloadItem(const DownloadCreateInfo& info); | 108 explicit DownloadItem(const DownloadCreateInfo& info); |
| 109 | 109 |
| 110 // Constructing from user action: | 110 // Constructing from user action: |
| 111 DownloadItem(int32 download_id, | 111 DownloadItem(int32 download_id, |
| 112 const FilePath& path, | 112 const FilePath& path, |
| 113 int path_uniquifier, | 113 int path_uniquifier, |
| 114 const GURL& url, | 114 const GURL& url, |
| 115 const GURL& referrer_url, | 115 const GURL& referrer_url, |
| 116 const std::string& mime_type, | 116 const std::string& mime_type, |
| 117 const std::string& original_mime_type, |
| 117 const FilePath& original_name, | 118 const FilePath& original_name, |
| 118 const base::Time start_time, | 119 const base::Time start_time, |
| 119 int64 download_size, | 120 int64 download_size, |
| 120 int render_process_id, | 121 int render_process_id, |
| 121 int request_id, | 122 int request_id, |
| 122 bool is_dangerous, | 123 bool is_dangerous, |
| 123 bool save_as, | 124 bool save_as, |
| 124 bool is_otr, | 125 bool is_otr, |
| 125 bool is_extension_install, | 126 bool is_extension_install, |
| 126 bool is_temporary); | 127 bool is_temporary); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 DownloadState state() const { return state_; } | 193 DownloadState state() const { return state_; } |
| 193 FilePath file_name() const { return file_name_; } | 194 FilePath file_name() const { return file_name_; } |
| 194 void set_file_name(const FilePath& name) { file_name_ = name; } | 195 void set_file_name(const FilePath& name) { file_name_ = name; } |
| 195 FilePath full_path() const { return full_path_; } | 196 FilePath full_path() const { return full_path_; } |
| 196 void set_full_path(const FilePath& path) { full_path_ = path; } | 197 void set_full_path(const FilePath& path) { full_path_ = path; } |
| 197 int path_uniquifier() const { return path_uniquifier_; } | 198 int path_uniquifier() const { return path_uniquifier_; } |
| 198 void set_path_uniquifier(int uniquifier) { path_uniquifier_ = uniquifier; } | 199 void set_path_uniquifier(int uniquifier) { path_uniquifier_ = uniquifier; } |
| 199 GURL url() const { return url_; } | 200 GURL url() const { return url_; } |
| 200 GURL referrer_url() const { return referrer_url_; } | 201 GURL referrer_url() const { return referrer_url_; } |
| 201 std::string mime_type() const { return mime_type_; } | 202 std::string mime_type() const { return mime_type_; } |
| 203 std::string original_mime_type() const { return original_mime_type_; } |
| 202 int64 total_bytes() const { return total_bytes_; } | 204 int64 total_bytes() const { return total_bytes_; } |
| 203 void set_total_bytes(int64 total_bytes) { total_bytes_ = total_bytes; } | 205 void set_total_bytes(int64 total_bytes) { total_bytes_ = total_bytes; } |
| 204 int64 received_bytes() const { return received_bytes_; } | 206 int64 received_bytes() const { return received_bytes_; } |
| 205 int32 id() const { return id_; } | 207 int32 id() const { return id_; } |
| 206 base::Time start_time() const { return start_time_; } | 208 base::Time start_time() const { return start_time_; } |
| 207 void set_db_handle(int64 handle) { db_handle_ = handle; } | 209 void set_db_handle(int64 handle) { db_handle_ = handle; } |
| 208 int64 db_handle() const { return db_handle_; } | 210 int64 db_handle() const { return db_handle_; } |
| 209 DownloadManager* manager() const { return manager_; } | 211 DownloadManager* manager() const { return manager_; } |
| 210 void set_manager(DownloadManager* manager) { manager_ = manager; } | 212 void set_manager(DownloadManager* manager) { manager_ = manager; } |
| 211 bool is_paused() const { return is_paused_; } | 213 bool is_paused() const { return is_paused_; } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 | 258 |
| 257 // The URL from whence we came. | 259 // The URL from whence we came. |
| 258 GURL url_; | 260 GURL url_; |
| 259 | 261 |
| 260 // The URL of the page that initiated the download. | 262 // The URL of the page that initiated the download. |
| 261 GURL referrer_url_; | 263 GURL referrer_url_; |
| 262 | 264 |
| 263 // The mimetype of the download | 265 // The mimetype of the download |
| 264 std::string mime_type_; | 266 std::string mime_type_; |
| 265 | 267 |
| 268 // The value of the content type header received when downloading |
| 269 // this item. |mime_type_| may be different because of type sniffing. |
| 270 std::string original_mime_type_; |
| 271 |
| 266 // Total bytes expected | 272 // Total bytes expected |
| 267 int64 total_bytes_; | 273 int64 total_bytes_; |
| 268 | 274 |
| 269 // Current received bytes | 275 // Current received bytes |
| 270 int64 received_bytes_; | 276 int64 received_bytes_; |
| 271 | 277 |
| 272 // Start time for calculating remaining time | 278 // Start time for calculating remaining time |
| 273 base::TimeTicks start_tick_; | 279 base::TimeTicks start_tick_; |
| 274 | 280 |
| 275 // The current state of this download | 281 // The current state of this download |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 friend class base::RefCountedThreadSafe<DownloadManager>; | 576 friend class base::RefCountedThreadSafe<DownloadManager>; |
| 571 friend class OtherDownloadManagerObserver; | 577 friend class OtherDownloadManagerObserver; |
| 572 | 578 |
| 573 ~DownloadManager(); | 579 ~DownloadManager(); |
| 574 | 580 |
| 575 // Opens a download via the Windows shell. | 581 // Opens a download via the Windows shell. |
| 576 void OpenDownloadInShell(const DownloadItem* download, | 582 void OpenDownloadInShell(const DownloadItem* download, |
| 577 gfx::NativeView parent_window); | 583 gfx::NativeView parent_window); |
| 578 | 584 |
| 579 // Opens downloaded Chrome extension file (*.crx). | 585 // Opens downloaded Chrome extension file (*.crx). |
| 580 void OpenChromeExtension(const FilePath& full_path, const GURL& download_url, | 586 void OpenChromeExtension(const FilePath& full_path, |
| 581 const GURL& referrer_url); | 587 const GURL& download_url, |
| 588 const GURL& referrer_url, |
| 589 const std::string& original_mime_type); |
| 582 | 590 |
| 583 // Shutdown the download manager. This call is needed only after Init. | 591 // Shutdown the download manager. This call is needed only after Init. |
| 584 void Shutdown(); | 592 void Shutdown(); |
| 585 | 593 |
| 586 // Called on the download thread to check whether the suggested file path | 594 // Called on the download thread to check whether the suggested file path |
| 587 // exists. We don't check if the file exists on the UI thread to avoid UI | 595 // exists. We don't check if the file exists on the UI thread to avoid UI |
| 588 // stalls from interacting with the file system. | 596 // stalls from interacting with the file system. |
| 589 void CheckIfSuggestedPathExists(DownloadCreateInfo* info); | 597 void CheckIfSuggestedPathExists(DownloadCreateInfo* info); |
| 590 | 598 |
| 591 // Called on the UI thread once the DownloadManager has determined whether the | 599 // Called on the UI thread once the DownloadManager has determined whether the |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 // Downloads are expected to have unique handles, so FakeDbHandleGenerator | 748 // Downloads are expected to have unique handles, so FakeDbHandleGenerator |
| 741 // automatically decrement the handle value on every use. | 749 // automatically decrement the handle value on every use. |
| 742 FakeDbHandleGenerator fake_db_handle_; | 750 FakeDbHandleGenerator fake_db_handle_; |
| 743 | 751 |
| 744 scoped_ptr<OtherDownloadManagerObserver> other_download_manager_observer_; | 752 scoped_ptr<OtherDownloadManagerObserver> other_download_manager_observer_; |
| 745 | 753 |
| 746 DISALLOW_COPY_AND_ASSIGN(DownloadManager); | 754 DISALLOW_COPY_AND_ASSIGN(DownloadManager); |
| 747 }; | 755 }; |
| 748 | 756 |
| 749 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_ | 757 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_ |
| OLD | NEW |