| 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 // Each download is represented by a DownloadItem, and all DownloadItems | 5 // Each download is represented by a DownloadItem, and all DownloadItems |
| 6 // are owned by the DownloadManager which maintains a global list of all | 6 // are owned by the DownloadManager which maintains a global list of all |
| 7 // downloads. DownloadItems are created when a user initiates a download, | 7 // downloads. DownloadItems are created when a user initiates a download, |
| 8 // and exist for the duration of the browser life time. | 8 // and exist for the duration of the browser life time. |
| 9 // | 9 // |
| 10 // Download observers: | 10 // Download observers: |
| 11 // DownloadItem::Observer: | 11 // DownloadItem::Observer: |
| 12 // - allows observers to receive notifications about one download from start | 12 // - allows observers to receive notifications about one download from start |
| 13 // to completion | 13 // to completion |
| 14 // Use AddObserver() / RemoveObserver() on the appropriate download object to | 14 // Use AddObserver() / RemoveObserver() on the appropriate download object to |
| 15 // receive state updates. | 15 // receive state updates. |
| 16 | 16 |
| 17 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ | 17 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ |
| 18 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ | 18 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ |
| 19 #pragma once | 19 #pragma once |
| 20 | 20 |
| 21 #include <string> | 21 #include <string> |
| 22 #include <iostream> | |
| 23 | 22 |
| 24 #include "base/basictypes.h" | 23 #include "base/basictypes.h" |
| 25 #include "base/file_path.h" | 24 #include "base/file_path.h" |
| 26 #include "base/observer_list.h" | 25 #include "base/observer_list.h" |
| 27 #include "base/time.h" | 26 #include "base/time.h" |
| 28 #include "base/timer.h" | 27 #include "base/timer.h" |
| 29 #include "content/browser/download/download_request_handle.h" | 28 #include "content/browser/download/download_request_handle.h" |
| 30 #include "content/browser/download/download_state_info.h" | 29 #include "content/browser/download/download_state_info.h" |
| 31 #include "googleurl/src/gurl.h" | 30 #include "googleurl/src/gurl.h" |
| 32 | 31 |
| 33 class DownloadFileManager; | 32 class DownloadFileManager; |
| 34 class DownloadId; | |
| 35 class DownloadManager; | 33 class DownloadManager; |
| 36 struct DownloadCreateInfo; | 34 struct DownloadCreateInfo; |
| 37 struct DownloadPersistentStoreInfo; | 35 struct DownloadPersistentStoreInfo; |
| 38 | 36 |
| 39 // One DownloadItem per download. This is the model class that stores all the | 37 // One DownloadItem per download. This is the model class that stores all the |
| 40 // state for a download. Multiple views, such as a tab's download shelf and the | 38 // state for a download. Multiple views, such as a tab's download shelf and the |
| 41 // Destination tab's download view, may refer to a given DownloadItem. | 39 // Destination tab's download view, may refer to a given DownloadItem. |
| 42 // | 40 // |
| 43 // This is intended to be used only on the UI thread. | 41 // This is intended to be used only on the UI thread. |
| 44 class DownloadItem { | 42 class DownloadItem { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // Constructing for a regular download: | 115 // Constructing for a regular download: |
| 118 DownloadItem(DownloadManager* download_manager, | 116 DownloadItem(DownloadManager* download_manager, |
| 119 const DownloadCreateInfo& info, | 117 const DownloadCreateInfo& info, |
| 120 bool is_otr); | 118 bool is_otr); |
| 121 | 119 |
| 122 // Constructing for the "Save Page As..." feature: | 120 // Constructing for the "Save Page As..." feature: |
| 123 DownloadItem(DownloadManager* download_manager, | 121 DownloadItem(DownloadManager* download_manager, |
| 124 const FilePath& path, | 122 const FilePath& path, |
| 125 const GURL& url, | 123 const GURL& url, |
| 126 bool is_otr, | 124 bool is_otr, |
| 127 DownloadId download_id); | 125 int download_id); |
| 128 | 126 |
| 129 virtual ~DownloadItem(); | 127 virtual ~DownloadItem(); |
| 130 | 128 |
| 131 void AddObserver(Observer* observer); | 129 void AddObserver(Observer* observer); |
| 132 void RemoveObserver(Observer* observer); | 130 void RemoveObserver(Observer* observer); |
| 133 | 131 |
| 134 // Notifies our observers periodically. | 132 // Notifies our observers periodically. |
| 135 void UpdateObservers(); | 133 void UpdateObservers(); |
| 136 | 134 |
| 137 // Returns true if it is OK to open a folder which this file is inside. | 135 // Returns true if it is OK to open a folder which this file is inside. |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 std::string content_disposition() const { return content_disposition_; } | 266 std::string content_disposition() const { return content_disposition_; } |
| 269 std::string mime_type() const { return mime_type_; } | 267 std::string mime_type() const { return mime_type_; } |
| 270 std::string original_mime_type() const { return original_mime_type_; } | 268 std::string original_mime_type() const { return original_mime_type_; } |
| 271 std::string referrer_charset() const { return referrer_charset_; } | 269 std::string referrer_charset() const { return referrer_charset_; } |
| 272 int64 total_bytes() const { return total_bytes_; } | 270 int64 total_bytes() const { return total_bytes_; } |
| 273 void set_total_bytes(int64 total_bytes) { | 271 void set_total_bytes(int64 total_bytes) { |
| 274 total_bytes_ = total_bytes; | 272 total_bytes_ = total_bytes; |
| 275 } | 273 } |
| 276 int64 received_bytes() const { return received_bytes_; } | 274 int64 received_bytes() const { return received_bytes_; } |
| 277 int32 id() const { return download_id_; } | 275 int32 id() const { return download_id_; } |
| 278 DownloadId global_id() const; | |
| 279 base::Time start_time() const { return start_time_; } | 276 base::Time start_time() const { return start_time_; } |
| 280 void set_db_handle(int64 handle) { db_handle_ = handle; } | 277 void set_db_handle(int64 handle) { db_handle_ = handle; } |
| 281 int64 db_handle() const { return db_handle_; } | 278 int64 db_handle() const { return db_handle_; } |
| 282 DownloadManager* download_manager() { return download_manager_; } | 279 DownloadManager* download_manager() { return download_manager_; } |
| 283 bool is_paused() const { return is_paused_; } | 280 bool is_paused() const { return is_paused_; } |
| 284 bool open_when_complete() const { return open_when_complete_; } | 281 bool open_when_complete() const { return open_when_complete_; } |
| 285 void set_open_when_complete(bool open) { open_when_complete_ = open; } | 282 void set_open_when_complete(bool open) { open_when_complete_ = open; } |
| 286 bool file_externally_removed() const { return file_externally_removed_; } | 283 bool file_externally_removed() const { return file_externally_removed_; } |
| 287 SafetyState safety_state() const { return safety_state_; } | 284 SafetyState safety_state() const { return safety_state_; } |
| 288 // Why |safety_state_| is not SAFE. | 285 // Why |safety_state_| is not SAFE. |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 // only. | 475 // only. |
| 479 bool open_enabled_; | 476 bool open_enabled_; |
| 480 | 477 |
| 481 // Did the delegate delay calling Complete on this download? | 478 // Did the delegate delay calling Complete on this download? |
| 482 bool delegate_delayed_complete_; | 479 bool delegate_delayed_complete_; |
| 483 | 480 |
| 484 DISALLOW_COPY_AND_ASSIGN(DownloadItem); | 481 DISALLOW_COPY_AND_ASSIGN(DownloadItem); |
| 485 }; | 482 }; |
| 486 | 483 |
| 487 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ | 484 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ |
| OLD | NEW |