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

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

Issue 10831302: Download resumption - Preliminary (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed content unit tests. Created 8 years, 2 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
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:
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_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ 17 #ifndef CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_
18 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ 18 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_
19 19
20 #include <map> 20 #include <map>
21 #include <string> 21 #include <string>
22 #include <vector> 22 #include <vector>
23 23
24 #include "base/file_path.h" 24 #include "base/file_path.h"
25 #include "base/string16.h" 25 #include "base/string16.h"
26 #include "base/supports_user_data.h" 26 #include "base/supports_user_data.h"
27 #include "content/public/browser/download_danger_type.h" 27 #include "content/public/browser/download_danger_type.h"
28 #include "content/public/browser/download_interrupt_reasons.h" 28 #include "content/public/browser/download_interrupt_reasons.h"
29 #include "content/public/common/page_transition_types.h" 29 #include "content/public/common/page_transition_types.h"
30 #include "net/base/net_log.h"
30 31
31 class FilePath; 32 class FilePath;
32 class GURL; 33 class GURL;
33 struct DownloadCreateInfo; 34 struct DownloadCreateInfo;
34 35
35 namespace base { 36 namespace base {
36 class Time; 37 class Time;
37 class TimeDelta; 38 class TimeDelta;
38 } 39 }
39 40
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 }; 83 };
83 84
84 // How the final target path should be used. 85 // How the final target path should be used.
85 enum TargetDisposition { 86 enum TargetDisposition {
86 TARGET_DISPOSITION_OVERWRITE, // Overwrite if the target already exists. 87 TARGET_DISPOSITION_OVERWRITE, // Overwrite if the target already exists.
87 TARGET_DISPOSITION_PROMPT // Prompt the user for the actual 88 TARGET_DISPOSITION_PROMPT // Prompt the user for the actual
88 // target. Implies 89 // target. Implies
89 // TARGET_DISPOSITION_OVERWRITE. 90 // TARGET_DISPOSITION_OVERWRITE.
90 }; 91 };
91 92
93 enum ResumeMode {
94 RESUME_MODE_INVALID = 0,
95 RESUME_MODE_IMMEDIATE_CONTINUE,
96 RESUME_MODE_IMMEDIATE_RESTART,
97 RESUME_MODE_USER_CONTINUE,
98 RESUME_MODE_USER_RESTART
99 };
Randy Smith (Not in Mondays) 2012/10/15 00:36:08 I'm uncomfortable about exposing this at the Downl
100
92 // A fake download table ID which represents a download that has started, 101 // A fake download table ID which represents a download that has started,
93 // but is not yet in the table. 102 // but is not yet in the table.
94 static const int kUninitializedHandle; 103 static const int kUninitializedHandle;
95 104
96 static const char kEmptyFileHash[]; 105 static const char kEmptyFileHash[];
97 106
98 // Interface that observers of a particular download must implement in order 107 // Interface that observers of a particular download must implement in order
99 // to receive updates to the download's status. 108 // to receive updates to the download's status.
100 class CONTENT_EXPORT Observer { 109 class CONTENT_EXPORT Observer {
101 public: 110 public:
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 166
158 virtual int32 GetId() const = 0; 167 virtual int32 GetId() const = 0;
159 virtual DownloadId GetGlobalId() const = 0; 168 virtual DownloadId GetGlobalId() const = 0;
160 virtual int64 GetDbHandle() const = 0; 169 virtual int64 GetDbHandle() const = 0;
161 virtual DownloadState GetState() const = 0; 170 virtual DownloadState GetState() const = 0;
162 171
163 // Only valid if |GetState() == DownloadItem::INTERRUPTED|. 172 // Only valid if |GetState() == DownloadItem::INTERRUPTED|.
164 virtual DownloadInterruptReason GetLastReason() const = 0; 173 virtual DownloadInterruptReason GetLastReason() const = 0;
165 174
166 virtual bool IsPaused() const = 0; 175 virtual bool IsPaused() const = 0;
176 virtual ResumeMode CanResumeInterrupted() const = 0;
167 virtual bool IsTemporary() const = 0; 177 virtual bool IsTemporary() const = 0;
168 virtual bool IsPersisted() const = 0; 178 virtual bool IsPersisted() const = 0;
169 179
170 // Convenience routines for accessing GetState() results conceptually ----- 180 // Convenience routines for accessing GetState() results conceptually -----
171 181
172 // Returns true if the download needs more data. 182 // Returns true if the download needs more data.
173 virtual bool IsPartialDownload() const = 0; 183 virtual bool IsPartialDownload() const = 0;
174 184
175 // Returns true if the download is still receiving data. 185 // Returns true if the download is still receiving data.
176 virtual bool IsInProgress() const = 0; 186 virtual bool IsInProgress() const = 0;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 virtual base::Time GetEndTime() const = 0; 288 virtual base::Time GetEndTime() const = 0;
279 289
280 // Open/Show State accessors ---------------------------------------------- 290 // Open/Show State accessors ----------------------------------------------
281 291
282 // Returns true if it is OK to open a folder which this file is inside. 292 // Returns true if it is OK to open a folder which this file is inside.
283 virtual bool CanShowInFolder() = 0; 293 virtual bool CanShowInFolder() = 0;
284 294
285 // Returns true if it is OK to open the download. 295 // Returns true if it is OK to open the download.
286 virtual bool CanOpenDownload() = 0; 296 virtual bool CanOpenDownload() = 0;
287 297
298 // Returns true if the download is paused or interrupted, and can be resumed.
299 virtual bool CanResumeDownload() const = 0;
300
288 // Tests if a file type should be opened automatically. 301 // Tests if a file type should be opened automatically.
289 virtual bool ShouldOpenFileBasedOnExtension() = 0; 302 virtual bool ShouldOpenFileBasedOnExtension() = 0;
290 303
291 // Returns true if the download will be auto-opened when complete. 304 // Returns true if the download will be auto-opened when complete.
292 virtual bool GetOpenWhenComplete() const = 0; 305 virtual bool GetOpenWhenComplete() const = 0;
293 306
294 // Returns true if the download has been auto-opened by the system. 307 // Returns true if the download has been auto-opened by the system.
295 virtual bool GetAutoOpened() = 0; 308 virtual bool GetAutoOpened() = 0;
296 309
297 // Returns true if the download has been opened. 310 // Returns true if the download has been opened.
(...skipping 27 matching lines...) Expand all
325 338
326 // Mark the download as having been opened (without actually opening it). 339 // Mark the download as having been opened (without actually opening it).
327 virtual void SetOpened(bool opened) = 0; 340 virtual void SetOpened(bool opened) = 0;
328 341
329 // Set a display name for the download that will be independent of the target 342 // Set a display name for the download that will be independent of the target
330 // filename. If |name| is not empty, then GetFileNameToReportUser() will 343 // filename. If |name| is not empty, then GetFileNameToReportUser() will
331 // return |name|. Has no effect on the final target filename. 344 // return |name|. Has no effect on the final target filename.
332 virtual void SetDisplayName(const FilePath& name) = 0; 345 virtual void SetDisplayName(const FilePath& name) = 0;
333 346
334 // Debug/testing ------------------------------------------------------------- 347 // Debug/testing -------------------------------------------------------------
348 // Gets the BoundNetLog associated with this download.
349 virtual const net::BoundNetLog& GetBoundNetLog() const = 0;
350
335 virtual std::string DebugString(bool verbose) const = 0; 351 virtual std::string DebugString(bool verbose) const = 0;
336 virtual void MockDownloadOpenForTesting() = 0; 352 virtual void MockDownloadOpenForTesting() = 0;
337 }; 353 };
338 354
339 } // namespace content 355 } // namespace content
340 356
341 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ 357 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698