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

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

Issue 8503018: Split DownloadItem into an ABC, an Impl, and a Mock. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: merge Created 9 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) 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/string16.h"
24 #include "base/file_path.h"
25 #include "base/memory/scoped_ptr.h"
26 #include "base/observer_list.h"
27 #include "base/time.h"
28 #include "content/browser/download/download_id.h"
29 #include "content/browser/download/download_request_handle.h"
30 #include "content/browser/download/download_state_info.h" 24 #include "content/browser/download/download_state_info.h"
31 #include "content/browser/download/interrupt_reasons.h" 25 #include "content/browser/download/interrupt_reasons.h"
32 #include "content/common/content_export.h"
33 #include "googleurl/src/gurl.h"
34 #include "net/base/net_errors.h"
35 26
36 class DownloadFileManager; 27 class DownloadFileManager;
37 class DownloadId; 28 class DownloadId;
38 class DownloadManager; 29 class DownloadManager;
30 class FilePath;
31 class GURL;
39 class TabContents; 32 class TabContents;
40
41 struct DownloadCreateInfo; 33 struct DownloadCreateInfo;
42 struct DownloadPersistentStoreInfo; 34 struct DownloadPersistentStoreInfo;
35 namespace base {
36 class Time;
37 class TimeDelta;
38 }
43 39
44 // One DownloadItem per download. This is the model class that stores all the 40 // One DownloadItem per download. This is the model class that stores all the
45 // state for a download. Multiple views, such as a tab's download shelf and the 41 // state for a download. Multiple views, such as a tab's download shelf and the
46 // Destination tab's download view, may refer to a given DownloadItem. 42 // Destination tab's download view, may refer to a given DownloadItem.
47 // 43 //
48 // This is intended to be used only on the UI thread. 44 // This is intended to be used only on the UI thread.
49 class CONTENT_EXPORT DownloadItem { 45 class CONTENT_EXPORT DownloadItem {
50 public: 46 public:
51 enum DownloadState { 47 enum DownloadState {
52 // Download is actively progressing. 48 // Download is actively progressing.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 public: 89 public:
94 virtual void OnDownloadUpdated(DownloadItem* download) = 0; 90 virtual void OnDownloadUpdated(DownloadItem* download) = 0;
95 91
96 // Called when a downloaded file has been opened. 92 // Called when a downloaded file has been opened.
97 virtual void OnDownloadOpened(DownloadItem* download) = 0; 93 virtual void OnDownloadOpened(DownloadItem* download) = 0;
98 94
99 protected: 95 protected:
100 virtual ~Observer() {} 96 virtual ~Observer() {}
101 }; 97 };
102 98
103 // Constructing from persistent store:
104 DownloadItem(DownloadManager* download_manager,
105 const DownloadPersistentStoreInfo& info);
106
107 // Constructing for a regular download.
108 // Takes ownership of the object pointed to by |request_handle|.
109 DownloadItem(DownloadManager* download_manager,
110 const DownloadCreateInfo& info,
111 DownloadRequestHandleInterface* request_handle,
112 bool is_otr);
113
114 // Constructing for the "Save Page As..." feature:
115 DownloadItem(DownloadManager* download_manager,
116 const FilePath& path,
117 const GURL& url,
118 bool is_otr,
119 DownloadId download_id);
120
121 virtual ~DownloadItem(); 99 virtual ~DownloadItem();
122 100
123 void AddObserver(Observer* observer); 101 virtual void AddObserver(DownloadItem::Observer* observer) = 0;
124 void RemoveObserver(Observer* observer); 102 virtual void RemoveObserver(DownloadItem::Observer* observer) = 0;
125 103
126 // Notifies our observers periodically. 104 // Notifies our observers periodically.
127 void UpdateObservers(); 105 virtual void UpdateObservers() = 0;
128 106
129 // Returns true if it is OK to open a folder which this file is inside. 107 // Returns true if it is OK to open a folder which this file is inside.
130 bool CanShowInFolder(); 108 virtual bool CanShowInFolder() = 0;
131 109
132 // Returns true if it is OK to register the type of this file so that 110 // Returns true if it is OK to register the type of this file so that
133 // it opens automatically. 111 // it opens automatically.
134 bool CanOpenDownload(); 112 virtual bool CanOpenDownload() = 0;
135 113
136 // Tests if a file type should be opened automatically. 114 // Tests if a file type should be opened automatically.
137 bool ShouldOpenFileBasedOnExtension(); 115 virtual bool ShouldOpenFileBasedOnExtension() = 0;
138 116
139 // Open the file associated with this download (wait for the download to 117 // Open the file associated with this download (wait for the download to
140 // complete if it is in progress). 118 // complete if it is in progress).
141 void OpenDownload(); 119 virtual void OpenDownload() = 0;
142 120
143 // Show the download via the OS shell. 121 // Show the download via the OS shell.
144 void ShowDownloadInShell(); 122 virtual void ShowDownloadInShell() = 0;
145 123
146 // Called when the user has validated the download of a dangerous file. 124 // Called when the user has validated the download of a dangerous file.
147 void DangerousDownloadValidated(); 125 virtual void DangerousDownloadValidated() = 0;
148 126
149 // Received a new chunk of data 127 // Received a new chunk of data
150 void Update(int64 bytes_so_far); 128 virtual void Update(int64 bytes_so_far) = 0;
151 129
152 // Cancel the download operation. We need to distinguish between cancels at 130 // Cancel the download operation. We need to distinguish between cancels at
153 // exit (DownloadManager destructor) from user interface initiated cancels 131 // exit (DownloadManager destructor) from user interface initiated cancels
154 // because at exit, the history system may not exist, and any updates to it 132 // because at exit, the history system may not exist, and any updates to it
155 // require AddRef'ing the DownloadManager in the destructor which results in 133 // require AddRef'ing the DownloadManager in the destructor which results in
156 // a DCHECK failure. Set |user_cancel| to false when canceling from at 134 // a DCHECK failure. Set |user_cancel| to false when canceling from at
157 // exit to prevent this crash. This may result in a difference between the 135 // exit to prevent this crash. This may result in a difference between the
158 // downloaded file's size on disk, and what the history system's last record 136 // downloaded file's size on disk, and what the history system's last record
159 // of it is. At worst, we'll end up re-downloading a small portion of the file 137 // of it is. At worst, we'll end up re-downloading a small portion of the file
160 // when resuming a download (assuming the server supports byte ranges). 138 // when resuming a download (assuming the server supports byte ranges).
161 void Cancel(bool user_cancel); 139 virtual void Cancel(bool user_cancel) = 0;
162 140
163 // Called by external code (SavePackage) using the DownloadItem interface 141 // Called by external code (SavePackage) using the DownloadItem interface
164 // to display progress when the DownloadItem should be considered complete. 142 // to display progress when the DownloadItem should be considered complete.
165 void MarkAsComplete(); 143 virtual void MarkAsComplete() = 0;
166 144
167 // Called by the delegate after it delayed opening the download in 145 // Called by the delegate after it delayed opening the download in
168 // DownloadManagerDelegate::ShouldOpenDownload. 146 // DownloadManagerDelegate::ShouldOpenDownload.
169 void DelayedDownloadOpened(); 147 virtual void DelayedDownloadOpened() = 0;
170 148
171 // Called when all data has been saved. 149 // Called when all data has been saved. Only has display effects.
172 void OnAllDataSaved(int64 size, const std::string& final_hash); 150 virtual void OnAllDataSaved(int64 size, const std::string& final_hash) = 0;
173 151
174 // Called when the downloaded file is removed. 152 // Called when the downloaded file is removed.
175 void OnDownloadedFileRemoved(); 153 virtual void OnDownloadedFileRemoved() = 0;
176 154
177 // Download operation had an error. 155 // Download operation had an error.
178 // |size| is the amount of data received at interruption. 156 // |size| is the amount of data received at interruption.
179 // |reason| is the download interrupt reason code that the operation received. 157 // |reason| is the download interrupt reason code that the operation received.
180 void Interrupted(int64 size, InterruptReason reason); 158 virtual void Interrupted(int64 size, InterruptReason reason) = 0;
181 159
182 // Deletes the file from disk and removes the download from the views and 160 // Deletes the file from disk and removes the download from the views and
183 // history. |user| should be true if this is the result of the user clicking 161 // history. |user| should be true if this is the result of the user clicking
184 // the discard button, and false if it is being deleted for other reasons like 162 // the discard button, and false if it is being deleted for other reasons like
185 // browser shutdown. 163 // browser shutdown.
186 void Delete(DeleteReason reason); 164 virtual void Delete(DeleteReason reason) = 0;
187 165
188 // Removes the download from the views and history. 166 // Removes the download from the views and history.
189 void Remove(); 167 virtual void Remove() = 0;
190 168
191 // Simple calculation of the amount of time remaining to completion. Fills 169 // Simple calculation of the amount of time remaining to completion. Fills
192 // |*remaining| with the amount of time remaining if successful. Fails and 170 // |*remaining| with the amount of time remaining if successful. Fails and
193 // returns false if we do not have the number of bytes or the speed so can 171 // returns false if we do not have the number of bytes or the speed so can
194 // not estimate. 172 // not estimate.
195 bool TimeRemaining(base::TimeDelta* remaining) const; 173 virtual bool TimeRemaining(base::TimeDelta* remaining) const = 0;
196 174
197 // Simple speed estimate in bytes/s 175 // Simple speed estimate in bytes/s
198 int64 CurrentSpeed() const; 176 virtual int64 CurrentSpeed() const = 0;
199 177
200 // Rough percent complete, -1 means we don't know (since we didn't receive a 178 // Rough percent complete, -1 means we don't know (since we didn't receive a
201 // total size). 179 // total size).
202 int PercentComplete() const; 180 virtual int PercentComplete() const = 0;
203 181
204 // Called when the final path has been determined. 182 // Called when the final path has been determined.
205 void OnPathDetermined(const FilePath& path); 183 virtual void OnPathDetermined(const FilePath& path) = 0;
206 184
207 // Returns true if this download has saved all of its data. 185 // Returns true if this download has saved all of its data.
208 bool all_data_saved() const { return all_data_saved_; } 186 virtual bool AllDataSaved() const = 0;
209 187
210 // Update the fields that may have changed in DownloadStateInfo as a 188 // Update the fields that may have changed in DownloadStateInfo as a
211 // result of analyzing the file and figuring out its type, location, etc. 189 // result of analyzing the file and figuring out its type, location, etc.
212 // May only be called once. 190 // May only be called once.
213 void SetFileCheckResults(const DownloadStateInfo& state); 191 virtual void SetFileCheckResults(const DownloadStateInfo& state) = 0;
214 192
215 // Update the download's path, the actual file is renamed on the download 193 // Update the download's path, the actual file is renamed on the download
216 // thread. 194 // thread.
217 void Rename(const FilePath& full_path); 195 virtual void Rename(const FilePath& full_path) = 0;
218 196
219 // Allow the user to temporarily pause a download or resume a paused download. 197 // Allow the user to temporarily pause a download or resume a paused download.
220 void TogglePause(); 198 virtual void TogglePause() = 0;
221 199
222 // Called when the download is ready to complete. 200 // Called when the download is ready to complete.
223 // This may perform final rename if necessary and will eventually call 201 // This may perform final rename if necessary and will eventually call
224 // DownloadItem::Completed(). 202 // DownloadItem::Completed().
225 void OnDownloadCompleting(DownloadFileManager* file_manager); 203 virtual void OnDownloadCompleting(DownloadFileManager* file_manager) = 0;
226 204
227 // Called when the file name for the download is renamed to its final name. 205 // Called when the file name for the download is renamed to its final name.
228 void OnDownloadRenamedToFinalName(const FilePath& full_path); 206 virtual void OnDownloadRenamedToFinalName(const FilePath& full_path) = 0;
229 207
230 // Returns true if this item matches |query|. |query| must be lower-cased. 208 // Returns true if this item matches |query|. |query| must be lower-cased.
231 bool MatchesQuery(const string16& query) const; 209 virtual bool MatchesQuery(const string16& query) const = 0;
232 210
233 // Returns true if the download needs more data. 211 // Returns true if the download needs more data.
234 bool IsPartialDownload() const; 212 virtual bool IsPartialDownload() const = 0;
235 213
236 // Returns true if the download is still receiving data. 214 // Returns true if the download is still receiving data.
237 bool IsInProgress() const; 215 virtual bool IsInProgress() const = 0;
238 216
239 // Returns true if the download has been cancelled or was interrupted. 217 // Returns true if the download has been cancelled or was interrupted.
240 bool IsCancelled() const; 218 virtual bool IsCancelled() const = 0;
241 219
242 // Returns true if the download was interrupted. 220 // Returns true if the download was interrupted.
243 bool IsInterrupted() const; 221 virtual bool IsInterrupted() const = 0;
244 222
245 // Returns true if we have all the data and know the final file name. 223 // Returns true if we have all the data and know the final file name.
246 bool IsComplete() const; 224 virtual bool IsComplete() const = 0;
247 225
248 // Accessors 226 // Accessors
249 DownloadState state() const { return state_; } 227 virtual const std::string& GetHash() const = 0;
250 const FilePath& full_path() const { return full_path_; } 228 virtual DownloadState GetState() const = 0;
251 void set_path_uniquifier(int uniquifier) { 229 virtual const FilePath& GetFullPath() const = 0;
252 state_info_.path_uniquifier = uniquifier; 230 virtual void SetPathUniquifier(int uniquifier) = 0;
253 } 231 virtual const GURL& GetURL() const = 0;
254 const GURL& GetURL() const; 232 virtual const std::vector<GURL>& GetUrlChain() const = 0;
233 virtual const GURL& GetOriginalUrl() const = 0;
234 virtual const GURL& GetReferrerUrl() const = 0;
235 virtual std::string GetSuggestedFilename() const = 0;
236 virtual std::string GetContentDisposition() const = 0;
237 virtual std::string GetMimeType() const = 0;
238 virtual std::string GetOriginalMimeType() const = 0;
239 virtual std::string GetReferrerCharset() const = 0;
240 virtual int64 GetTotalBytes() const = 0;
241 virtual void SetTotalBytes(int64 total_bytes) = 0;
242 virtual int64 GetReceivedBytes() const = 0;
243 virtual int32 GetId() const = 0;
244 virtual DownloadId GetGlobalId() const = 0;
245 virtual base::Time GetStartTime() const = 0;
246 virtual base::Time GetEndTime() const = 0;
247 virtual void SetDbHandle(int64 handle) = 0;
248 virtual int64 GetDbHandle() const = 0;
249 virtual DownloadManager* GetDownloadManager() = 0;
250 virtual bool IsPaused() const = 0;
251 virtual bool GetOpenWhenComplete() const = 0;
252 virtual void SetOpenWhenComplete(bool open) = 0;
253 virtual bool GetFileExternallyRemoved() const = 0;
254 virtual SafetyState GetSafetyState() const = 0;
255 // Why |safety_state_| is not SAFE.
256 virtual DownloadStateInfo::DangerType GetDangerType() const = 0;
257 virtual bool IsDangerous() const = 0;
258 virtual void MarkContentDangerous() = 0;
259 virtual void MarkFileDangerous() = 0;
260 virtual void MarkUrlDangerous() = 0;
255 261
256 const std::vector<GURL>& url_chain() const { return url_chain_; } 262 virtual bool GetAutoOpened() = 0;
257 const GURL& original_url() const { return url_chain_.front(); } 263 virtual const FilePath& GetTargetName() const = 0;
258 const GURL& referrer_url() const { return referrer_url_; } 264 virtual bool PromptUserForSaveLocation() const = 0;
259 std::string suggested_filename() const { return suggested_filename_; } 265 virtual bool IsOtr() const = 0;
260 std::string content_disposition() const { return content_disposition_; } 266 virtual const FilePath& GetSuggestedPath() const = 0;
261 std::string mime_type() const { return mime_type_; } 267 virtual bool IsTemporary() const = 0;
262 std::string original_mime_type() const { return original_mime_type_; } 268 virtual void SetOpened(bool opened) = 0;
263 std::string referrer_charset() const { return referrer_charset_; } 269 virtual bool GetOpened() const = 0;
264 int64 total_bytes() const { return total_bytes_; }
265 void set_total_bytes(int64 total_bytes) {
266 total_bytes_ = total_bytes;
267 }
268 int64 received_bytes() const { return received_bytes_; }
269 const std::string& hash() const { return hash_; }
270 int32 id() const { return download_id_.local(); }
271 DownloadId global_id() const { return download_id_; }
272 base::Time start_time() const { return start_time_; }
273 base::Time end_time() const { return end_time_; }
274 void set_db_handle(int64 handle) { db_handle_ = handle; }
275 int64 db_handle() const { return db_handle_; }
276 DownloadManager* download_manager() { return download_manager_; }
277 bool is_paused() const { return is_paused_; }
278 bool open_when_complete() const { return open_when_complete_; }
279 void set_open_when_complete(bool open) { open_when_complete_ = open; }
280 bool file_externally_removed() const { return file_externally_removed_; }
281 SafetyState safety_state() const { return safety_state_; }
282 // Why |safety_state_| is not SAFE.
283 DownloadStateInfo::DangerType GetDangerType() const;
284 bool IsDangerous() const;
285 void MarkFileDangerous();
286 void MarkUrlDangerous();
287 void MarkContentDangerous();
288 270
289 bool auto_opened() { return auto_opened_; } 271 virtual InterruptReason GetLastReason() const = 0;
290 const FilePath& target_name() const { return state_info_.target_name; } 272 virtual DownloadPersistentStoreInfo GetPersistentStoreInfo() const = 0;
291 bool prompt_user_for_save_location() const { 273 virtual DownloadStateInfo GetStateInfo() const = 0;
292 return state_info_.prompt_user_for_save_location; 274 virtual TabContents* GetTabContents() const = 0;
293 }
294 bool is_otr() const { return is_otr_; }
295 const FilePath& suggested_path() const { return state_info_.suggested_path; }
296 bool is_temporary() const { return is_temporary_; }
297 void set_opened(bool opened) { opened_ = opened; }
298 bool opened() const { return opened_; }
299
300 InterruptReason last_reason() const { return last_reason_; }
301
302 DownloadPersistentStoreInfo GetPersistentStoreInfo() const;
303 DownloadStateInfo state_info() const { return state_info_; }
304
305 TabContents* GetTabContents() const;
306 275
307 // Returns the final target file path for the download. 276 // Returns the final target file path for the download.
308 FilePath GetTargetFilePath() const; 277 virtual FilePath GetTargetFilePath() const = 0;
309 278
310 // Returns the file-name that should be reported to the user, which is 279 // Returns the file-name that should be reported to the user, which is
311 // target_name possibly with the uniquifier number. 280 // target_name possibly with the uniquifier number.
312 FilePath GetFileNameToReportUser() const; 281 virtual FilePath GetFileNameToReportUser() const = 0;
313 282
314 // Returns the user-verified target file path for the download. 283 // Returns the user-verified target file path for the download.
315 // This returns the same path as GetTargetFilePath() for safe downloads 284 // This returns the same path as GetTargetFilePath() for safe downloads
316 // but does not for dangerous downloads until the name is verified. 285 // but does not for dangerous downloads until the name is verified.
317 FilePath GetUserVerifiedFilePath() const; 286 virtual FilePath GetUserVerifiedFilePath() const = 0;
318 287
319 // Returns true if the current file name is not the final target name yet. 288 // Returns true if the current file name is not the final target name yet.
320 bool NeedsRename() const { 289 virtual bool NeedsRename() const = 0;
321 return state_info_.target_name != full_path_.BaseName();
322 }
323 290
324 // Cancels the off-thread aspects of the download. 291 // Cancels the off-thread aspects of the download.
325 // TODO(rdsmith): This should be private and only called from 292 // TODO(rdsmith): This should be private and only called from
326 // DownloadItem::Cancel/Interrupt; it isn't now because we can't 293 // DownloadItem::Cancel/Interrupt; it isn't now because we can't
327 // call those functions from 294 // call those functions from
328 // DownloadManager::FileSelectionCancelled() without doing some 295 // DownloadManager::FileSelectionCancelled() without doing some
329 // rewrites of the DownloadManager queues. 296 // rewrites of the DownloadManager queues.
330 void OffThreadCancel(DownloadFileManager* file_manager); 297 virtual void OffThreadCancel(DownloadFileManager* file_manager) = 0;
331 298
332 std::string DebugString(bool verbose) const; 299 virtual std::string DebugString(bool verbose) const = 0;
333 300
334 void MockDownloadOpenForTesting() { open_enabled_ = false; } 301 virtual void MockDownloadOpenForTesting() = 0;
335
336 private:
337 // Construction common to all constructors. |active| should be true for new
338 // downloads and false for downloads from the history.
339 void Init(bool active);
340
341 // Internal helper for maintaining consistent received and total sizes.
342 void UpdateSize(int64 size);
343
344 // Called when the entire download operation (including renaming etc)
345 // is completed.
346 void Completed();
347
348 // Call to transition state; all state transitions should go through this.
349 void TransitionTo(DownloadState new_state);
350
351 // Called when safety_state_ should be recomputed from the DangerType of the
352 // state info.
353 void UpdateSafetyState();
354
355 // Helper function to recompute |state_info_.target_name| when
356 // it may have changed. (If it's non-null it should be left alone,
357 // otherwise updated from |full_path_|.)
358 void UpdateTarget();
359
360 // State information used by the download manager.
361 DownloadStateInfo state_info_;
362
363 // The handle to the request information. Used for operations outside the
364 // download system. May be null if the download item isn't associated
365 // with a request (e.g. created from persistent store).
366 scoped_ptr<DownloadRequestHandleInterface> request_handle_;
367
368 // Download ID assigned by DownloadResourceHandler.
369 DownloadId download_id_;
370
371 // Full path to the downloaded or downloading file.
372 FilePath full_path_;
373
374 // A number that should be appended to the path to make it unique, or 0 if the
375 // path should be used as is.
376 int path_uniquifier_;
377
378 // The chain of redirects that leading up to and including the final URL.
379 std::vector<GURL> url_chain_;
380
381 // The URL of the page that initiated the download.
382 GURL referrer_url_;
383
384 // Suggested filename in 'download' attribute of an anchor. Details:
385 // http://www.whatwg.org/specs/web-apps/current-work/#downloading-hyperlinks
386 std::string suggested_filename_;
387
388 // Information from the request.
389 // Content-disposition field from the header.
390 std::string content_disposition_;
391
392 // Mime-type from the header. Subject to change.
393 std::string mime_type_;
394
395 // The value of the content type header sent with the downloaded item. It
396 // may be different from |mime_type_|, which may be set based on heuristics
397 // which may look at the file extension and first few bytes of the file.
398 std::string original_mime_type_;
399
400 // The charset of the referring page where the download request comes from.
401 // It's used to construct a suggested filename.
402 std::string referrer_charset_;
403
404 // Total bytes expected
405 int64 total_bytes_;
406
407 // Current received bytes
408 int64 received_bytes_;
409
410 // Sha256 hash of the content. This might be empty either because
411 // the download isn't done yet or because the hash isn't needed
412 // (ChromeDownloadManagerDelegate::GenerateFileHash() returned false).
413 std::string hash_;
414
415 // Last reason.
416 InterruptReason last_reason_;
417
418 // Start time for calculating remaining time
419 base::TimeTicks start_tick_;
420
421 // The current state of this download
422 DownloadState state_;
423
424 // The views of this item in the download shelf and download tab
425 ObserverList<Observer> observers_;
426
427 // Time the download was started
428 base::Time start_time_;
429
430 // Time the download completed
431 base::Time end_time_;
432
433 // Our persistent store handle
434 int64 db_handle_;
435
436 // Our owning object
437 DownloadManager* download_manager_;
438
439 // In progress downloads may be paused by the user, we note it here
440 bool is_paused_;
441
442 // A flag for indicating if the download should be opened at completion.
443 bool open_when_complete_;
444
445 // A flag for indicating if the downloaded file is externally removed.
446 bool file_externally_removed_;
447
448 // Indicates if the download is considered potentially safe or dangerous
449 // (executable files are typically considered dangerous).
450 SafetyState safety_state_;
451
452 // True if the download was auto-opened. We set this rather than using
453 // an observer as it's frequently possible for the download to be auto opened
454 // before the observer is added.
455 bool auto_opened_;
456
457 // True if the download was initiated in an incognito window.
458 bool is_otr_;
459
460 // True if the item was downloaded temporarily.
461 bool is_temporary_;
462
463 // True if we've saved all the data for the download.
464 bool all_data_saved_;
465
466 // Did the user open the item either directly or indirectly (such as by
467 // setting always open files of this type)? The shelf also sets this field
468 // when the user closes the shelf before the item has been opened but should
469 // be treated as though the user opened it.
470 bool opened_;
471
472 // Do we actual open downloads when requested? For testing purposes
473 // only.
474 bool open_enabled_;
475
476 // Did the delegate delay calling Complete on this download?
477 bool delegate_delayed_complete_;
478
479 DISALLOW_COPY_AND_ASSIGN(DownloadItem);
480 }; 302 };
481 303
482 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ 304 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_
OLDNEW
« no previous file with comments | « content/browser/download/download_id_unittest.cc ('k') | content/browser/download/download_item.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698