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

Side by Side Diff: content/browser/download/download_item_impl.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 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_
6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 18 matching lines...) Expand all
29 class CONTENT_EXPORT DownloadItemImpl : public content::DownloadItem { 29 class CONTENT_EXPORT DownloadItemImpl : public content::DownloadItem {
30 public: 30 public:
31 // Note that it is the responsibility of the caller to ensure that a 31 // Note that it is the responsibility of the caller to ensure that a
32 // DownloadItemImplDelegate passed to a DownloadItemImpl constructor 32 // DownloadItemImplDelegate passed to a DownloadItemImpl constructor
33 // outlives the DownloadItemImpl. 33 // outlives the DownloadItemImpl.
34 34
35 // Constructing from persistent store: 35 // Constructing from persistent store:
36 // |bound_net_log| is constructed externally for our use. 36 // |bound_net_log| is constructed externally for our use.
37 DownloadItemImpl(DownloadItemImplDelegate* delegate, 37 DownloadItemImpl(DownloadItemImplDelegate* delegate,
38 content::DownloadId download_id, 38 content::DownloadId download_id,
39 const content::DownloadPersistentStoreInfo& info, 39 const FilePath& path,
40 const GURL& url,
41 const GURL& referrer_url,
42 const base::Time& start_time,
43 const base::Time& end_time,
44 int64 received_bytes,
45 int64 total_bytes,
46 DownloadItem::DownloadState state,
47 bool opened,
40 const net::BoundNetLog& bound_net_log); 48 const net::BoundNetLog& bound_net_log);
41 49
42 // Constructing for a regular download. 50 // Constructing for a regular download.
43 // |bound_net_log| is constructed externally for our use. 51 // |bound_net_log| is constructed externally for our use.
44 DownloadItemImpl(DownloadItemImplDelegate* delegate, 52 DownloadItemImpl(DownloadItemImplDelegate* delegate,
45 const DownloadCreateInfo& info, 53 const DownloadCreateInfo& info,
46 scoped_ptr<DownloadRequestHandleInterface> request_handle, 54 scoped_ptr<DownloadRequestHandleInterface> request_handle,
47 const net::BoundNetLog& bound_net_log); 55 const net::BoundNetLog& bound_net_log);
48 56
49 // Constructing for the "Save Page As..." feature: 57 // Constructing for the "Save Page As..." feature:
(...skipping 16 matching lines...) Expand all
66 // to use to store the download until OnDownloadCompleting() is called. 74 // to use to store the download until OnDownloadCompleting() is called.
67 virtual void OnDownloadTargetDetermined( 75 virtual void OnDownloadTargetDetermined(
68 const FilePath& target_path, 76 const FilePath& target_path,
69 TargetDisposition disposition, 77 TargetDisposition disposition,
70 content::DownloadDangerType danger_type, 78 content::DownloadDangerType danger_type,
71 const FilePath& intermediate_path); 79 const FilePath& intermediate_path);
72 80
73 // Indicate that an error has occurred on the download. 81 // Indicate that an error has occurred on the download.
74 virtual void Interrupt(content::DownloadInterruptReason reason); 82 virtual void Interrupt(content::DownloadInterruptReason reason);
75 83
76 // Mark the item as having been persisted.
77 virtual void SetIsPersisted();
78
79 // Set the item's DB handle.
80 virtual void SetDbHandle(int64 handle);
81
82 // Cancels the off-thread aspects of the download. 84 // Cancels the off-thread aspects of the download.
83 // TODO(rdsmith): This should be private and only called from 85 // TODO(rdsmith): This should be private and only called from
84 // DownloadItem::Cancel/Interrupt; it isn't now because we can't 86 // DownloadItem::Cancel/Interrupt; it isn't now because we can't
85 // call those functions from 87 // call those functions from
86 // DownloadManager::FileSelectionCancelled() without doing some 88 // DownloadManager::FileSelectionCancelled() without doing some
87 // rewrites of the DownloadManager queues. 89 // rewrites of the DownloadManager queues.
88 virtual void OffThreadCancel(); 90 virtual void OffThreadCancel();
89 91
90 // Called when the downloaded file is removed. 92 // Called when the downloaded file is removed.
91 virtual void OnDownloadedFileRemoved(); 93 virtual void OnDownloadedFileRemoved();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 virtual std::string GetReferrerCharset() const OVERRIDE; 160 virtual std::string GetReferrerCharset() const OVERRIDE;
159 virtual std::string GetRemoteAddress() const OVERRIDE; 161 virtual std::string GetRemoteAddress() const OVERRIDE;
160 virtual int64 GetTotalBytes() const OVERRIDE; 162 virtual int64 GetTotalBytes() const OVERRIDE;
161 virtual const std::string& GetHash() const OVERRIDE; 163 virtual const std::string& GetHash() const OVERRIDE;
162 virtual int64 GetReceivedBytes() const OVERRIDE; 164 virtual int64 GetReceivedBytes() const OVERRIDE;
163 virtual const std::string& GetHashState() const OVERRIDE; 165 virtual const std::string& GetHashState() const OVERRIDE;
164 virtual int32 GetId() const OVERRIDE; 166 virtual int32 GetId() const OVERRIDE;
165 virtual content::DownloadId GetGlobalId() const OVERRIDE; 167 virtual content::DownloadId GetGlobalId() const OVERRIDE;
166 virtual base::Time GetStartTime() const OVERRIDE; 168 virtual base::Time GetStartTime() const OVERRIDE;
167 virtual base::Time GetEndTime() const OVERRIDE; 169 virtual base::Time GetEndTime() const OVERRIDE;
168 virtual bool IsPersisted() const OVERRIDE;
169 virtual int64 GetDbHandle() const OVERRIDE;
170 virtual bool IsPaused() const OVERRIDE; 170 virtual bool IsPaused() const OVERRIDE;
171 virtual bool GetOpenWhenComplete() const OVERRIDE; 171 virtual bool GetOpenWhenComplete() const OVERRIDE;
172 virtual void SetOpenWhenComplete(bool open) OVERRIDE; 172 virtual void SetOpenWhenComplete(bool open) OVERRIDE;
173 virtual bool GetFileExternallyRemoved() const OVERRIDE; 173 virtual bool GetFileExternallyRemoved() const OVERRIDE;
174 virtual SafetyState GetSafetyState() const OVERRIDE; 174 virtual SafetyState GetSafetyState() const OVERRIDE;
175 virtual content::DownloadDangerType GetDangerType() const OVERRIDE; 175 virtual content::DownloadDangerType GetDangerType() const OVERRIDE;
176 virtual bool IsDangerous() const OVERRIDE; 176 virtual bool IsDangerous() const OVERRIDE;
177 virtual bool GetAutoOpened() OVERRIDE; 177 virtual bool GetAutoOpened() OVERRIDE;
178 virtual FilePath GetTargetName() const OVERRIDE; 178 virtual FilePath GetTargetName() const OVERRIDE;
179 virtual const FilePath& GetForcedFilePath() const OVERRIDE; 179 virtual const FilePath& GetForcedFilePath() const OVERRIDE;
180 virtual bool HasUserGesture() const OVERRIDE; 180 virtual bool HasUserGesture() const OVERRIDE;
181 virtual content::PageTransition GetTransitionType() const OVERRIDE; 181 virtual content::PageTransition GetTransitionType() const OVERRIDE;
182 virtual bool IsTemporary() const OVERRIDE; 182 virtual bool IsTemporary() const OVERRIDE;
183 virtual void SetIsTemporary(bool temporary) OVERRIDE; 183 virtual void SetIsTemporary(bool temporary) OVERRIDE;
184 virtual void SetOpened(bool opened) OVERRIDE; 184 virtual void SetOpened(bool opened) OVERRIDE;
185 virtual bool GetOpened() const OVERRIDE; 185 virtual bool GetOpened() const OVERRIDE;
186 virtual const std::string& GetLastModifiedTime() const OVERRIDE; 186 virtual const std::string& GetLastModifiedTime() const OVERRIDE;
187 virtual const std::string& GetETag() const OVERRIDE; 187 virtual const std::string& GetETag() const OVERRIDE;
188 virtual content::DownloadInterruptReason GetLastReason() const OVERRIDE; 188 virtual content::DownloadInterruptReason GetLastReason() const OVERRIDE;
189 virtual content::DownloadPersistentStoreInfo
190 GetPersistentStoreInfo() const OVERRIDE;
191 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE; 189 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE;
192 virtual content::WebContents* GetWebContents() const OVERRIDE; 190 virtual content::WebContents* GetWebContents() const OVERRIDE;
193 virtual FilePath GetFileNameToReportUser() const OVERRIDE; 191 virtual FilePath GetFileNameToReportUser() const OVERRIDE;
194 virtual void SetDisplayName(const FilePath& name) OVERRIDE; 192 virtual void SetDisplayName(const FilePath& name) OVERRIDE;
195 virtual FilePath GetUserVerifiedFilePath() const OVERRIDE; 193 virtual FilePath GetUserVerifiedFilePath() const OVERRIDE;
196 virtual std::string DebugString(bool verbose) const OVERRIDE; 194 virtual std::string DebugString(bool verbose) const OVERRIDE;
197 virtual void MockDownloadOpenForTesting() OVERRIDE; 195 virtual void MockDownloadOpenForTesting() OVERRIDE;
198 196
199 private: 197 private:
200 // Construction common to all constructors. |active| should be true for new 198 // Construction common to all constructors. |active| should be true for new
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 345
348 // The views of this item in the download shelf and download contents. 346 // The views of this item in the download shelf and download contents.
349 ObserverList<Observer> observers_; 347 ObserverList<Observer> observers_;
350 348
351 // Time the download was started. 349 // Time the download was started.
352 base::Time start_time_; 350 base::Time start_time_;
353 351
354 // Time the download completed. 352 // Time the download completed.
355 base::Time end_time_; 353 base::Time end_time_;
356 354
357 // Our persistent store handle.
358 int64 db_handle_;
359
360 // Our delegate. 355 // Our delegate.
361 DownloadItemImplDelegate* delegate_; 356 DownloadItemImplDelegate* delegate_;
362 357
363 // In progress downloads may be paused by the user, we note it here. 358 // In progress downloads may be paused by the user, we note it here.
364 bool is_paused_; 359 bool is_paused_;
365 360
366 // A flag for indicating if the download should be opened at completion. 361 // A flag for indicating if the download should be opened at completion.
367 bool open_when_complete_; 362 bool open_when_complete_;
368 363
369 // A flag for indicating if the downloaded file is externally removed. 364 // A flag for indicating if the downloaded file is externally removed.
370 bool file_externally_removed_; 365 bool file_externally_removed_;
371 366
372 // Indicates if the download is considered potentially safe or dangerous 367 // Indicates if the download is considered potentially safe or dangerous
373 // (executable files are typically considered dangerous). 368 // (executable files are typically considered dangerous).
374 SafetyState safety_state_; 369 SafetyState safety_state_;
375 370
376 // True if the download was auto-opened. We set this rather than using 371 // True if the download was auto-opened. We set this rather than using
377 // an observer as it's frequently possible for the download to be auto opened 372 // an observer as it's frequently possible for the download to be auto opened
378 // before the observer is added. 373 // before the observer is added.
379 bool auto_opened_; 374 bool auto_opened_;
380 375
381 bool is_persisted_;
382
383 // True if the item was downloaded temporarily. 376 // True if the item was downloaded temporarily.
384 bool is_temporary_; 377 bool is_temporary_;
385 378
386 // True if we've saved all the data for the download. 379 // True if we've saved all the data for the download.
387 bool all_data_saved_; 380 bool all_data_saved_;
388 381
389 // Did the user open the item either directly or indirectly (such as by 382 // Did the user open the item either directly or indirectly (such as by
390 // setting always open files of this type)? The shelf also sets this field 383 // setting always open files of this type)? The shelf also sets this field
391 // when the user closes the shelf before the item has been opened but should 384 // when the user closes the shelf before the item has been opened but should
392 // be treated as though the user opened it. 385 // be treated as though the user opened it.
393 bool opened_; 386 bool opened_;
394 387
395 // Do we actually open downloads when requested? For testing purposes only. 388 // Do we actually open downloads when requested? For testing purposes only.
396 bool open_enabled_; 389 bool open_enabled_;
397 390
398 // Did the delegate delay calling Complete on this download? 391 // Did the delegate delay calling Complete on this download?
399 bool delegate_delayed_complete_; 392 bool delegate_delayed_complete_;
400 393
401 // Net log to use for this download. 394 // Net log to use for this download.
402 const net::BoundNetLog bound_net_log_; 395 const net::BoundNetLog bound_net_log_;
403 396
404 base::WeakPtrFactory<DownloadItemImpl> weak_ptr_factory_; 397 base::WeakPtrFactory<DownloadItemImpl> weak_ptr_factory_;
405 398
406 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl); 399 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl);
407 }; 400 };
408 401
409 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ 402 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698