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

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

Issue 10704052: Download filename determination refactor (3/3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with r148594 to and resolve conflicts with r148576 Created 8 years, 4 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 const GURL& url, 54 const GURL& url,
55 bool is_otr, 55 bool is_otr,
56 content::DownloadId download_id, 56 content::DownloadId download_id,
57 const std::string& mime_type, 57 const std::string& mime_type,
58 const net::BoundNetLog& bound_net_log); 58 const net::BoundNetLog& bound_net_log);
59 59
60 virtual ~DownloadItemImpl(); 60 virtual ~DownloadItemImpl();
61 61
62 // Implementation functions (not part of the DownloadItem interface). 62 // Implementation functions (not part of the DownloadItem interface).
63 63
64 // Called when the target path has been determined. |target_path| is the
65 // suggested target path. |disposition| indicates how the target path should
66 // be used (see TargetDisposition). |danger_type| is the danger level of
67 // |target_path| as determined by the caller. |intermediate_path| is the path
68 // to use to store the download until OnDownloadCompleting() is called.
69 virtual void OnDownloadTargetDetermined(
70 const FilePath& target_path,
71 TargetDisposition disposition,
72 content::DownloadDangerType danger_type,
73 const FilePath& intermediate_path);
74
64 // Indicate that an error has occurred on the download. 75 // Indicate that an error has occurred on the download.
65 virtual void Interrupt(content::DownloadInterruptReason reason); 76 virtual void Interrupt(content::DownloadInterruptReason reason);
66 77
67 // Mark the item as having been persisted. 78 // Mark the item as having been persisted.
68 virtual void SetIsPersisted(); 79 virtual void SetIsPersisted();
69 80
70 // Set the item's DB handle. 81 // Set the item's DB handle.
71 virtual void SetDbHandle(int64 handle); 82 virtual void SetDbHandle(int64 handle);
72 83
73 // Cancels the off-thread aspects of the download. 84 // Cancels the off-thread aspects of the download.
74 // TODO(rdsmith): This should be private and only called from 85 // TODO(rdsmith): This should be private and only called from
75 // DownloadItem::Cancel/Interrupt; it isn't now because we can't 86 // DownloadItem::Cancel/Interrupt; it isn't now because we can't
76 // call those functions from 87 // call those functions from
77 // DownloadManager::FileSelectionCancelled() without doing some 88 // DownloadManager::FileSelectionCancelled() without doing some
78 // rewrites of the DownloadManager queues. 89 // rewrites of the DownloadManager queues.
79 virtual void OffThreadCancel(DownloadFileManager* file_manager); 90 virtual void OffThreadCancel();
80 91
81 // Called when the downloaded file is removed. 92 // Called when the downloaded file is removed.
82 virtual void OnDownloadedFileRemoved(); 93 virtual void OnDownloadedFileRemoved();
83 94
84 // Called when the download is ready to complete. 95 // Called when the download is ready to complete.
85 // This may perform final rename if necessary and will eventually call 96 // This may perform final rename if necessary and will eventually call
86 // DownloadItem::Completed(). 97 // DownloadItem::Completed().
87 virtual void OnDownloadCompleting(DownloadFileManager* file_manager); 98 virtual void OnDownloadCompleting();
88 99
89 // Called periodically from the download thread, or from the UI thread 100 // Called periodically from the download thread, or from the UI thread
90 // for saving packages. 101 // for saving packages.
91 // |bytes_so_far| is the number of bytes received so far. 102 // |bytes_so_far| is the number of bytes received so far.
92 // |hash_state| is the current hash state. 103 // |hash_state| is the current hash state.
93 virtual void UpdateProgress(int64 bytes_so_far, 104 virtual void UpdateProgress(int64 bytes_so_far,
94 int64 bytes_per_sec, 105 int64 bytes_per_sec,
95 const std::string& hash_state); 106 const std::string& hash_state);
96 107
97 // Called by SavePackage to display progress when the DownloadItem 108 // Called by SavePackage to display progress when the DownloadItem
(...skipping 28 matching lines...) Expand all
126 virtual bool MatchesQuery(const string16& query) const OVERRIDE; 137 virtual bool MatchesQuery(const string16& query) const OVERRIDE;
127 virtual bool IsPartialDownload() const OVERRIDE; 138 virtual bool IsPartialDownload() const OVERRIDE;
128 virtual bool IsInProgress() const OVERRIDE; 139 virtual bool IsInProgress() const OVERRIDE;
129 virtual bool IsCancelled() const OVERRIDE; 140 virtual bool IsCancelled() const OVERRIDE;
130 virtual bool IsInterrupted() const OVERRIDE; 141 virtual bool IsInterrupted() const OVERRIDE;
131 virtual bool IsComplete() const OVERRIDE; 142 virtual bool IsComplete() const OVERRIDE;
132 virtual DownloadState GetState() const OVERRIDE; 143 virtual DownloadState GetState() const OVERRIDE;
133 virtual const FilePath& GetFullPath() const OVERRIDE; 144 virtual const FilePath& GetFullPath() const OVERRIDE;
134 virtual const FilePath& GetTargetFilePath() const OVERRIDE; 145 virtual const FilePath& GetTargetFilePath() const OVERRIDE;
135 virtual TargetDisposition GetTargetDisposition() const OVERRIDE; 146 virtual TargetDisposition GetTargetDisposition() const OVERRIDE;
136 virtual void OnTargetPathDetermined(
137 const FilePath& target_path,
138 TargetDisposition disposition,
139 content::DownloadDangerType danger_type) OVERRIDE;
140 virtual void OnTargetPathSelected(const FilePath& target_path) OVERRIDE;
141 virtual void OnContentCheckCompleted( 147 virtual void OnContentCheckCompleted(
142 content::DownloadDangerType danger_type) OVERRIDE; 148 content::DownloadDangerType danger_type) OVERRIDE;
143 virtual void OnIntermediatePathDetermined(DownloadFileManager* file_manager,
144 const FilePath& path) OVERRIDE;
145 virtual const GURL& GetURL() const OVERRIDE; 149 virtual const GURL& GetURL() const OVERRIDE;
146 virtual const std::vector<GURL>& GetUrlChain() const OVERRIDE; 150 virtual const std::vector<GURL>& GetUrlChain() const OVERRIDE;
147 virtual const GURL& GetOriginalUrl() const OVERRIDE; 151 virtual const GURL& GetOriginalUrl() const OVERRIDE;
148 virtual const GURL& GetReferrerUrl() const OVERRIDE; 152 virtual const GURL& GetReferrerUrl() const OVERRIDE;
149 virtual std::string GetSuggestedFilename() const OVERRIDE; 153 virtual std::string GetSuggestedFilename() const OVERRIDE;
150 virtual std::string GetContentDisposition() const OVERRIDE; 154 virtual std::string GetContentDisposition() const OVERRIDE;
151 virtual std::string GetMimeType() const OVERRIDE; 155 virtual std::string GetMimeType() const OVERRIDE;
152 virtual std::string GetOriginalMimeType() const OVERRIDE; 156 virtual std::string GetOriginalMimeType() const OVERRIDE;
153 virtual std::string GetReferrerCharset() const OVERRIDE; 157 virtual std::string GetReferrerCharset() const OVERRIDE;
154 virtual std::string GetRemoteAddress() const OVERRIDE; 158 virtual std::string GetRemoteAddress() const OVERRIDE;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 // Call to transition state; all state transitions should go through this. 228 // Call to transition state; all state transitions should go through this.
225 void TransitionTo(DownloadState new_state); 229 void TransitionTo(DownloadState new_state);
226 230
227 // Set the |danger_type_| and invoke obserers if necessary. 231 // Set the |danger_type_| and invoke obserers if necessary.
228 void SetDangerType(content::DownloadDangerType danger_type); 232 void SetDangerType(content::DownloadDangerType danger_type);
229 233
230 // Set the |current_path_| to |new_path|. 234 // Set the |current_path_| to |new_path|.
231 void SetFullPath(const FilePath& new_path); 235 void SetFullPath(const FilePath& new_path);
232 236
233 // Callback invoked when the download has been renamed to its final name. 237 // Callback invoked when the download has been renamed to its final name.
234 void OnDownloadRenamedToFinalName(DownloadFileManager* file_manager, 238 void OnDownloadRenamedToFinalName(content::DownloadInterruptReason reason,
235 content::DownloadInterruptReason reason,
236 const FilePath& full_path); 239 const FilePath& full_path);
237 240
238 // Callback invoked when the download has been renamed to its intermediate 241 // Callback invoked when the download has been renamed to its intermediate
239 // name. 242 // name.
240 void OnDownloadRenamedToIntermediateName( 243 void OnDownloadRenamedToIntermediateName(
241 content::DownloadInterruptReason reason, const FilePath& full_path); 244 content::DownloadInterruptReason reason, const FilePath& full_path);
242 245
243 // Callback from file thread when we release the DownloadFile. 246 // Callback from file thread when we release the DownloadFile.
244 void OnDownloadFileReleased(); 247 void OnDownloadFileReleased();
245 248
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 410
408 // Net log to use for this download. 411 // Net log to use for this download.
409 const net::BoundNetLog bound_net_log_; 412 const net::BoundNetLog bound_net_log_;
410 413
411 base::WeakPtrFactory<DownloadItemImpl> weak_ptr_factory_; 414 base::WeakPtrFactory<DownloadItemImpl> weak_ptr_factory_;
412 415
413 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl); 416 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl);
414 }; 417 };
415 418
416 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ 419 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_close_browsertest.cc ('k') | content/browser/download/download_item_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698