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

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

Issue 10665049: Make DownloadHistory observe manager, items (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 3 months 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 25 matching lines...) Expand all
36 class Time; 36 class Time;
37 class TimeDelta; 37 class TimeDelta;
38 } 38 }
39 39
40 namespace content { 40 namespace content {
41 41
42 class BrowserContext; 42 class BrowserContext;
43 class DownloadId; 43 class DownloadId;
44 class DownloadManager; 44 class DownloadManager;
45 class WebContents; 45 class WebContents;
46 struct DownloadPersistentStoreInfo;
47 46
48 // One DownloadItem per download. This is the model class that stores all the 47 // 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 48 // 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. 49 // Destination tab's download view, may refer to a given DownloadItem.
51 // 50 //
52 // This is intended to be used only on the UI thread. 51 // This is intended to be used only on the UI thread.
53 class CONTENT_EXPORT DownloadItem : public base::SupportsUserData { 52 class CONTENT_EXPORT DownloadItem : public base::SupportsUserData {
54 public: 53 public:
55 enum DownloadState { 54 enum DownloadState {
56 // Download is actively progressing. 55 // Download is actively progressing.
(...skipping 25 matching lines...) Expand all
82 }; 81 };
83 82
84 // How the final target path should be used. 83 // How the final target path should be used.
85 enum TargetDisposition { 84 enum TargetDisposition {
86 TARGET_DISPOSITION_OVERWRITE, // Overwrite if the target already exists. 85 TARGET_DISPOSITION_OVERWRITE, // Overwrite if the target already exists.
87 TARGET_DISPOSITION_PROMPT // Prompt the user for the actual 86 TARGET_DISPOSITION_PROMPT // Prompt the user for the actual
88 // target. Implies 87 // target. Implies
89 // TARGET_DISPOSITION_OVERWRITE. 88 // TARGET_DISPOSITION_OVERWRITE.
90 }; 89 };
91 90
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[]; 91 static const char kEmptyFileHash[];
97 92
98 // Interface that observers of a particular download must implement in order 93 // Interface that observers of a particular download must implement in order
99 // to receive updates to the download's status. 94 // to receive updates to the download's status.
100 class CONTENT_EXPORT Observer { 95 class CONTENT_EXPORT Observer {
101 public: 96 public:
102 virtual void OnDownloadUpdated(DownloadItem* download) {} 97 virtual void OnDownloadUpdated(DownloadItem* download) {}
103 98
104 // Called when a downloaded file has been opened. 99 // Called when a downloaded file has been opened.
105 virtual void OnDownloadOpened(DownloadItem* download) {} 100 virtual void OnDownloadOpened(DownloadItem* download) {}
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 virtual const FilePath& GetTargetFilePath() const = 0; 211 virtual const FilePath& GetTargetFilePath() const = 0;
217 212
218 // Get the target disposition. 213 // Get the target disposition.
219 virtual TargetDisposition GetTargetDisposition() const = 0; 214 virtual TargetDisposition GetTargetDisposition() const = 0;
220 215
221 // Called if a check of the download contents was performed and the results of 216 // Called if a check of the download contents was performed and the results of
222 // the test are available. This should only be called after AllDataSaved() is 217 // the test are available. This should only be called after AllDataSaved() is
223 // true. 218 // true.
224 virtual void OnContentCheckCompleted(DownloadDangerType danger_type) = 0; 219 virtual void OnContentCheckCompleted(DownloadDangerType danger_type) = 0;
225 220
226 virtual bool IsPersisted() const = 0;
227
228 // Accessors 221 // Accessors
229 virtual const std::string& GetHash() const = 0; 222 virtual const std::string& GetHash() const = 0;
230 virtual DownloadState GetState() const = 0; 223 virtual DownloadState GetState() const = 0;
231 virtual const GURL& GetURL() const = 0; 224 virtual const GURL& GetURL() const = 0;
232 virtual const std::vector<GURL>& GetUrlChain() const = 0; 225 virtual const std::vector<GURL>& GetUrlChain() const = 0;
233 virtual const GURL& GetOriginalUrl() const = 0; 226 virtual const GURL& GetOriginalUrl() const = 0;
234 virtual const GURL& GetReferrerUrl() const = 0; 227 virtual const GURL& GetReferrerUrl() const = 0;
235 virtual std::string GetSuggestedFilename() const = 0; 228 virtual std::string GetSuggestedFilename() const = 0;
236 virtual std::string GetContentDisposition() const = 0; 229 virtual std::string GetContentDisposition() const = 0;
237 virtual std::string GetMimeType() const = 0; 230 virtual std::string GetMimeType() const = 0;
238 virtual std::string GetOriginalMimeType() const = 0; 231 virtual std::string GetOriginalMimeType() const = 0;
239 virtual std::string GetReferrerCharset() const = 0; 232 virtual std::string GetReferrerCharset() const = 0;
240 virtual std::string GetRemoteAddress() const = 0; 233 virtual std::string GetRemoteAddress() const = 0;
241 virtual int64 GetTotalBytes() const = 0; 234 virtual int64 GetTotalBytes() const = 0;
242 virtual int64 GetReceivedBytes() const = 0; 235 virtual int64 GetReceivedBytes() const = 0;
243 virtual const std::string& GetHashState() const = 0; 236 virtual const std::string& GetHashState() const = 0;
244 virtual int32 GetId() const = 0; 237 virtual int32 GetId() const = 0;
245 virtual DownloadId GetGlobalId() const = 0; 238 virtual DownloadId GetGlobalId() const = 0;
246 virtual base::Time GetStartTime() const = 0; 239 virtual base::Time GetStartTime() const = 0;
247 virtual base::Time GetEndTime() const = 0; 240 virtual base::Time GetEndTime() const = 0;
248 virtual int64 GetDbHandle() const = 0;
249 virtual bool IsPaused() const = 0; 241 virtual bool IsPaused() const = 0;
250 virtual bool GetOpenWhenComplete() const = 0; 242 virtual bool GetOpenWhenComplete() const = 0;
251 virtual void SetOpenWhenComplete(bool open) = 0; 243 virtual void SetOpenWhenComplete(bool open) = 0;
252 virtual bool GetFileExternallyRemoved() const = 0; 244 virtual bool GetFileExternallyRemoved() const = 0;
253 virtual SafetyState GetSafetyState() const = 0; 245 virtual SafetyState GetSafetyState() const = 0;
254 // Why |safety_state_| is not SAFE. 246 // Why |safety_state_| is not SAFE.
255 virtual DownloadDangerType GetDangerType() const = 0; 247 virtual DownloadDangerType GetDangerType() const = 0;
256 virtual bool IsDangerous() const = 0; 248 virtual bool IsDangerous() const = 0;
257 249
258 virtual bool GetAutoOpened() = 0; 250 virtual bool GetAutoOpened() = 0;
259 virtual FilePath GetTargetName() const = 0; 251 virtual FilePath GetTargetName() const = 0;
260 virtual const FilePath& GetForcedFilePath() const = 0; 252 virtual const FilePath& GetForcedFilePath() const = 0;
261 virtual bool HasUserGesture() const = 0; 253 virtual bool HasUserGesture() const = 0;
262 virtual PageTransition GetTransitionType() const = 0; 254 virtual PageTransition GetTransitionType() const = 0;
263 virtual bool IsTemporary() const = 0; 255 virtual bool IsTemporary() const = 0;
264 virtual void SetIsTemporary(bool temporary) = 0; 256 virtual void SetIsTemporary(bool temporary) = 0;
265 virtual void SetOpened(bool opened) = 0; 257 virtual void SetOpened(bool opened) = 0;
266 virtual bool GetOpened() const = 0; 258 virtual bool GetOpened() const = 0;
267 259
268 virtual const std::string& GetLastModifiedTime() const = 0; 260 virtual const std::string& GetLastModifiedTime() const = 0;
269 virtual const std::string& GetETag() const = 0; 261 virtual const std::string& GetETag() const = 0;
270 262
271 virtual DownloadInterruptReason GetLastReason() const = 0; 263 virtual DownloadInterruptReason GetLastReason() const = 0;
272 virtual DownloadPersistentStoreInfo GetPersistentStoreInfo() const = 0;
273 virtual BrowserContext* GetBrowserContext() const = 0; 264 virtual BrowserContext* GetBrowserContext() const = 0;
274 virtual WebContents* GetWebContents() const = 0; 265 virtual WebContents* GetWebContents() const = 0;
275 266
276 // Returns the file-name that should be reported to the user. If a display 267 // Returns the file-name that should be reported to the user. If a display
277 // name has been explicitly set using SetDisplayName(), this function returns 268 // name has been explicitly set using SetDisplayName(), this function returns
278 // that display name. Otherwise returns the final target filename. 269 // that display name. Otherwise returns the final target filename.
279 virtual FilePath GetFileNameToReportUser() const = 0; 270 virtual FilePath GetFileNameToReportUser() const = 0;
280 271
281 // Set a display name for the download that will be independent of the target 272 // Set a display name for the download that will be independent of the target
282 // filename. If |name| is not empty, then GetFileNameToReportUser() will 273 // filename. If |name| is not empty, then GetFileNameToReportUser() will
283 // return |name|. Has no effect on the final target filename. 274 // return |name|. Has no effect on the final target filename.
284 virtual void SetDisplayName(const FilePath& name) = 0; 275 virtual void SetDisplayName(const FilePath& name) = 0;
285 276
286 // Returns the user-verified target file path for the download. 277 // Returns the user-verified target file path for the download.
287 // This returns the same path as GetTargetFilePath() for safe downloads 278 // This returns the same path as GetTargetFilePath() for safe downloads
288 // but does not for dangerous downloads until the name is verified. 279 // but does not for dangerous downloads until the name is verified.
289 virtual FilePath GetUserVerifiedFilePath() const = 0; 280 virtual FilePath GetUserVerifiedFilePath() const = 0;
290 281
291 virtual std::string DebugString(bool verbose) const = 0; 282 virtual std::string DebugString(bool verbose) const = 0;
292 283
293 virtual void MockDownloadOpenForTesting() = 0; 284 virtual void MockDownloadOpenForTesting() = 0;
294 }; 285 };
295 286
296 } // namespace content 287 } // namespace content
297 288
298 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ 289 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698