Chromium Code Reviews| 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 | 22 |
| 23 #include "base/basictypes.h" | 23 #include "base/basictypes.h" |
| 24 #include "base/file_path.h" | 24 #include "base/file_path.h" |
| 25 #include "base/observer_list.h" | 25 #include "base/observer_list.h" |
| 26 #include "base/time.h" | 26 #include "base/time.h" |
| 27 #include "base/timer.h" | 27 #include "base/timer.h" |
| 28 #include "content/common/content_export.h" | |
|
darin (slow to review)
2011/09/04 15:41:04
nit: "browser" before "common"
Dirk Pranke
2011/09/07 01:46:07
Done. Apparently I can't alphabetize reliably.
| |
| 28 #include "content/browser/download/download_request_handle.h" | 29 #include "content/browser/download/download_request_handle.h" |
| 29 #include "content/browser/download/download_state_info.h" | 30 #include "content/browser/download/download_state_info.h" |
| 30 #include "googleurl/src/gurl.h" | 31 #include "googleurl/src/gurl.h" |
| 31 | 32 |
| 32 class DownloadFileManager; | 33 class DownloadFileManager; |
| 33 class DownloadManager; | 34 class DownloadManager; |
| 34 struct DownloadCreateInfo; | 35 struct DownloadCreateInfo; |
| 35 struct DownloadPersistentStoreInfo; | 36 struct DownloadPersistentStoreInfo; |
| 36 | 37 |
| 37 // One DownloadItem per download. This is the model class that stores all the | 38 // One DownloadItem per download. This is the model class that stores all the |
| 38 // state for a download. Multiple views, such as a tab's download shelf and the | 39 // state for a download. Multiple views, such as a tab's download shelf and the |
| 39 // Destination tab's download view, may refer to a given DownloadItem. | 40 // Destination tab's download view, may refer to a given DownloadItem. |
| 40 // | 41 // |
| 41 // This is intended to be used only on the UI thread. | 42 // This is intended to be used only on the UI thread. |
| 42 class DownloadItem { | 43 class CONTENT_EXPORT DownloadItem { |
| 43 public: | 44 public: |
| 44 enum DownloadState { | 45 enum DownloadState { |
| 45 // Download is actively progressing. | 46 // Download is actively progressing. |
| 46 IN_PROGRESS = 0, | 47 IN_PROGRESS = 0, |
| 47 | 48 |
| 48 // Download is completely finished. | 49 // Download is completely finished. |
| 49 COMPLETE, | 50 COMPLETE, |
| 50 | 51 |
| 51 // Download has been cancelled. | 52 // Download has been cancelled. |
| 52 CANCELLED, | 53 CANCELLED, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 DELETE_DUE_TO_BROWSER_SHUTDOWN = 0, | 91 DELETE_DUE_TO_BROWSER_SHUTDOWN = 0, |
| 91 DELETE_DUE_TO_USER_DISCARD | 92 DELETE_DUE_TO_USER_DISCARD |
| 92 }; | 93 }; |
| 93 | 94 |
| 94 // A fake download table ID which represents a download that has started, | 95 // A fake download table ID which represents a download that has started, |
| 95 // but is not yet in the table. | 96 // but is not yet in the table. |
| 96 static const int kUninitializedHandle; | 97 static const int kUninitializedHandle; |
| 97 | 98 |
| 98 // Interface that observers of a particular download must implement in order | 99 // Interface that observers of a particular download must implement in order |
| 99 // to receive updates to the download's status. | 100 // to receive updates to the download's status. |
| 100 class Observer { | 101 class CONTENT_EXPORT Observer { |
| 101 public: | 102 public: |
| 102 virtual void OnDownloadUpdated(DownloadItem* download) = 0; | 103 virtual void OnDownloadUpdated(DownloadItem* download) = 0; |
| 103 | 104 |
| 104 // Called when a downloaded file has been opened. | 105 // Called when a downloaded file has been opened. |
| 105 virtual void OnDownloadOpened(DownloadItem* download) = 0; | 106 virtual void OnDownloadOpened(DownloadItem* download) = 0; |
| 106 | 107 |
| 107 protected: | 108 protected: |
| 108 virtual ~Observer() {} | 109 virtual ~Observer() {} |
| 109 }; | 110 }; |
| 110 | 111 |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 475 // only. | 476 // only. |
| 476 bool open_enabled_; | 477 bool open_enabled_; |
| 477 | 478 |
| 478 // Did the delegate delay calling Complete on this download? | 479 // Did the delegate delay calling Complete on this download? |
| 479 bool delegate_delayed_complete_; | 480 bool delegate_delayed_complete_; |
| 480 | 481 |
| 481 DISALLOW_COPY_AND_ASSIGN(DownloadItem); | 482 DISALLOW_COPY_AND_ASSIGN(DownloadItem); |
| 482 }; | 483 }; |
| 483 | 484 |
| 484 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ | 485 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ |
| OLD | NEW |