Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: content/public/browser/download_item.h

Issue 10915180: Make DownloadHistory observe manager, items (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: @r168573 Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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:
(...skipping 24 matching lines...) Expand all
35 class Time; 35 class Time;
36 class TimeDelta; 36 class TimeDelta;
37 } 37 }
38 38
39 namespace content { 39 namespace content {
40 40
41 class BrowserContext; 41 class BrowserContext;
42 class DownloadId; 42 class DownloadId;
43 class DownloadManager; 43 class DownloadManager;
44 class WebContents; 44 class WebContents;
45 struct DownloadCreateInfo;
46 struct DownloadPersistentStoreInfo;
47 45
48 // One DownloadItem per download. This is the model class that stores all the 46 // One DownloadItem per download. This is the model class that stores all the
49 // state for a download. Multiple views, such as a tab's download shelf and the 47 // state for a download. Multiple views, such as a tab's download shelf and the
50 // Destination tab's download view, may refer to a given DownloadItem. 48 // Destination tab's download view, may refer to a given DownloadItem.
51 // 49 //
52 // This is intended to be used only on the UI thread. 50 // This is intended to be used only on the UI thread.
53 class CONTENT_EXPORT DownloadItem : public base::SupportsUserData { 51 class CONTENT_EXPORT DownloadItem : public base::SupportsUserData {
54 public: 52 public:
55 enum DownloadState { 53 enum DownloadState {
56 // Download is actively progressing. 54 // Download is actively progressing.
(...skipping 25 matching lines...) Expand all
82 }; 80 };
83 81
84 // How the final target path should be used. 82 // How the final target path should be used.
85 enum TargetDisposition { 83 enum TargetDisposition {
86 TARGET_DISPOSITION_OVERWRITE, // Overwrite if the target already exists. 84 TARGET_DISPOSITION_OVERWRITE, // Overwrite if the target already exists.
87 TARGET_DISPOSITION_PROMPT // Prompt the user for the actual 85 TARGET_DISPOSITION_PROMPT // Prompt the user for the actual
88 // target. Implies 86 // target. Implies
89 // TARGET_DISPOSITION_OVERWRITE. 87 // TARGET_DISPOSITION_OVERWRITE.
90 }; 88 };
91 89
92 // A fake download table ID which represents a download that has started,
93 // but is not yet in the table.
94 static const int kUninitializedHandle;
95
96 static const char kEmptyFileHash[]; 90 static const char kEmptyFileHash[];
97 91
98 // Interface that observers of a particular download must implement in order 92 // Interface that observers of a particular download must implement in order
99 // to receive updates to the download's status. 93 // to receive updates to the download's status.
100 class CONTENT_EXPORT Observer { 94 class CONTENT_EXPORT Observer {
101 public: 95 public:
102 virtual void OnDownloadUpdated(DownloadItem* download) {} 96 virtual void OnDownloadUpdated(DownloadItem* download) {}
103 virtual void OnDownloadOpened(DownloadItem* download) {} 97 virtual void OnDownloadOpened(DownloadItem* download) {}
104 virtual void OnDownloadRemoved(DownloadItem* download) {} 98 virtual void OnDownloadRemoved(DownloadItem* download) {}
105 99
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // still in progress, marks the download to be opened when it is complete. 144 // still in progress, marks the download to be opened when it is complete.
151 virtual void OpenDownload() = 0; 145 virtual void OpenDownload() = 0;
152 146
153 // Show the download via the OS shell. 147 // Show the download via the OS shell.
154 virtual void ShowDownloadInShell() = 0; 148 virtual void ShowDownloadInShell() = 0;
155 149
156 // State accessors ----------------------------------------------------------- 150 // State accessors -----------------------------------------------------------
157 151
158 virtual int32 GetId() const = 0; 152 virtual int32 GetId() const = 0;
159 virtual DownloadId GetGlobalId() const = 0; 153 virtual DownloadId GetGlobalId() const = 0;
160 virtual int64 GetDbHandle() const = 0;
161 virtual DownloadState GetState() const = 0; 154 virtual DownloadState GetState() const = 0;
162 155
163 // Only valid if |GetState() == DownloadItem::INTERRUPTED|. 156 // Only valid if |GetState() == DownloadItem::INTERRUPTED|.
164 virtual DownloadInterruptReason GetLastReason() const = 0; 157 virtual DownloadInterruptReason GetLastReason() const = 0;
165 158
166 virtual bool IsPaused() const = 0; 159 virtual bool IsPaused() const = 0;
167 virtual bool IsTemporary() const = 0; 160 virtual bool IsTemporary() const = 0;
168 virtual bool IsPersisted() const = 0;
169 161
170 // Convenience routines for accessing GetState() results conceptually ----- 162 // Convenience routines for accessing GetState() results conceptually -----
171 163
172 // Returns true if the download needs more data. 164 // Returns true if the download needs more data.
173 virtual bool IsPartialDownload() const = 0; 165 virtual bool IsPartialDownload() const = 0;
174 166
175 // Returns true if the download is still receiving data. 167 // Returns true if the download is still receiving data.
176 virtual bool IsInProgress() const = 0; 168 virtual bool IsInProgress() const = 0;
177 169
178 // Returns true if the download has been cancelled or was interrupted. 170 // Returns true if the download has been cancelled or was interrupted.
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 virtual bool GetOpenWhenComplete() const = 0; 284 virtual bool GetOpenWhenComplete() const = 0;
293 285
294 // Returns true if the download has been auto-opened by the system. 286 // Returns true if the download has been auto-opened by the system.
295 virtual bool GetAutoOpened() = 0; 287 virtual bool GetAutoOpened() = 0;
296 288
297 // Returns true if the download has been opened. 289 // Returns true if the download has been opened.
298 virtual bool GetOpened() const = 0; 290 virtual bool GetOpened() const = 0;
299 291
300 // Misc State accessors --------------------------------------------------- 292 // Misc State accessors ---------------------------------------------------
301 293
302 virtual DownloadPersistentStoreInfo GetPersistentStoreInfo() const = 0;
303 virtual BrowserContext* GetBrowserContext() const = 0; 294 virtual BrowserContext* GetBrowserContext() const = 0;
304 virtual WebContents* GetWebContents() const = 0; 295 virtual WebContents* GetWebContents() const = 0;
305 296
306 // External state transitions/setters ---------------------------------------- 297 // External state transitions/setters ----------------------------------------
307 // TODO(rdsmith): These should all be removed; the download item should 298 // TODO(rdsmith): These should all be removed; the download item should
308 // control its own state transitions. 299 // control its own state transitions.
309 300
310 // Called if a check of the download contents was performed and the results of 301 // Called if a check of the download contents was performed and the results of
311 // the test are available. This should only be called after AllDataSaved() is 302 // the test are available. This should only be called after AllDataSaved() is
312 // true. 303 // true.
(...skipping 15 matching lines...) Expand all
328 virtual void SetDisplayName(const FilePath& name) = 0; 319 virtual void SetDisplayName(const FilePath& name) = 0;
329 320
330 // Debug/testing ------------------------------------------------------------- 321 // Debug/testing -------------------------------------------------------------
331 virtual std::string DebugString(bool verbose) const = 0; 322 virtual std::string DebugString(bool verbose) const = 0;
332 virtual void MockDownloadOpenForTesting() = 0; 323 virtual void MockDownloadOpenForTesting() = 0;
333 }; 324 };
334 325
335 } // namespace content 326 } // namespace content
336 327
337 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ 328 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698