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

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

Issue 10950015: Shift "commit point" for when a download will no longer accept cancels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync'd to LKGR. 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 | 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // should be considered complete. 200 // should be considered complete.
201 virtual void MarkAsComplete(); 201 virtual void MarkAsComplete();
202 202
203 // Interactions with persistence system -------------------------------------- 203 // Interactions with persistence system --------------------------------------
204 204
205 // TODO(benjhayden): Remove when DownloadHistory becomes an observer. 205 // TODO(benjhayden): Remove when DownloadHistory becomes an observer.
206 virtual void SetIsPersisted(); 206 virtual void SetIsPersisted();
207 virtual void SetDbHandle(int64 handle); 207 virtual void SetDbHandle(int64 handle);
208 208
209 private: 209 private:
210 // Fine grained states of a download.
211 enum DownloadInternalState {
212 // Unless otherwise specified, state transitions are linear forward
213 // in this list.
214
215 // Includes both before and after file name determination.
216 // TODO(rdsmith): Put in state variable for file name determination.
217 IN_PROGRESS_INTERNAL,
218
219 // Between commit point (dispatch of download file release) and
220 // completed. Embedder may be opening the file in this state.
221 COMPLETING_INTERNAL,
222
223 // After embedder has had a chance to auto-open. User may now open
224 // or auto-open based on extension.
225 COMPLETE_INTERNAL,
226
227 // User has cancelled the download.
228 // Only incoming transition IN_PROGRESS->
229 CANCELLED_INTERNAL,
230
231 // An error has interrupted the download.
232 // Only incoming transition IN_PROGRESS->
233 INTERRUPTED_INTERNAL,
234
235 MAX_DOWNLOAD_INTERNAL_STATE,
236 };
237
210 // Normal progression of a download ------------------------------------------ 238 // Normal progression of a download ------------------------------------------
211 239
212 // These are listed in approximately chronological order. There are also 240 // These are listed in approximately chronological order. There are also
213 // public methods involved in normal download progression; see 241 // public methods involved in normal download progression; see
214 // the implementation ordering in download_item_impl.cc. 242 // the implementation ordering in download_item_impl.cc.
215 243
216 // Construction common to all constructors. |active| should be true for new 244 // Construction common to all constructors. |active| should be true for new
217 // downloads and false for downloads from the history. 245 // downloads and false for downloads from the history.
218 // |download_type| indicates to the net log system what kind of download 246 // |download_type| indicates to the net log system what kind of download
219 // this is. 247 // this is.
(...skipping 22 matching lines...) Expand all
242 // GetTargetFilePath(). 270 // GetTargetFilePath().
243 bool NeedsRename() const; 271 bool NeedsRename() const;
244 272
245 // Internal helper for maintaining consistent received and total sizes, and 273 // Internal helper for maintaining consistent received and total sizes, and
246 // setting the final hash. 274 // setting the final hash.
247 // Should only be called from |OnAllDataSaved|. 275 // Should only be called from |OnAllDataSaved|.
248 void ProgressComplete(int64 bytes_so_far, 276 void ProgressComplete(int64 bytes_so_far,
249 const std::string& final_hash); 277 const std::string& final_hash);
250 278
251 // Call to transition state; all state transitions should go through this. 279 // Call to transition state; all state transitions should go through this.
252 void TransitionTo(DownloadState new_state); 280 void TransitionTo(DownloadInternalState new_state);
253 281
254 // Set the |danger_type_| and invoke obserers if necessary. 282 // Set the |danger_type_| and invoke obserers if necessary.
255 void SetDangerType(content::DownloadDangerType danger_type); 283 void SetDangerType(content::DownloadDangerType danger_type);
256 284
257 void SetFullPath(const FilePath& new_path); 285 void SetFullPath(const FilePath& new_path);
258 286
287 // Mapping between internal and external states.
288 static DownloadState InternalToExternalState(
289 DownloadInternalState internal_state);
290 static DownloadInternalState ExternalToInternalState(
291 DownloadState external_state);
292
293 // Debugging routines --------------------------------------------------------
294 static const char* DebugDownloadStateString(DownloadInternalState state);
295
259 // The handle to the request information. Used for operations outside the 296 // The handle to the request information. Used for operations outside the
260 // download system. 297 // download system.
261 scoped_ptr<DownloadRequestHandleInterface> request_handle_; 298 scoped_ptr<DownloadRequestHandleInterface> request_handle_;
262 299
263 // Download ID assigned by DownloadResourceHandler. 300 // Download ID assigned by DownloadResourceHandler.
264 content::DownloadId download_id_; 301 content::DownloadId download_id_;
265 302
266 // Display name for the download. If this is empty, then the display name is 303 // Display name for the download. If this is empty, then the display name is
267 // considered to be |target_path_.BaseName()|. 304 // considered to be |target_path_.BaseName()|.
268 FilePath display_name_; 305 FilePath display_name_;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 // Server's ETAG for the file. 383 // Server's ETAG for the file.
347 std::string etag_; 384 std::string etag_;
348 385
349 // Last reason. 386 // Last reason.
350 content::DownloadInterruptReason last_reason_; 387 content::DownloadInterruptReason last_reason_;
351 388
352 // Start time for recording statistics. 389 // Start time for recording statistics.
353 base::TimeTicks start_tick_; 390 base::TimeTicks start_tick_;
354 391
355 // The current state of this download. 392 // The current state of this download.
356 DownloadState state_; 393 DownloadInternalState state_;
357 394
358 // Current danger type for the download. 395 // Current danger type for the download.
359 content::DownloadDangerType danger_type_; 396 content::DownloadDangerType danger_type_;
360 397
361 // The views of this item in the download shelf and download contents. 398 // The views of this item in the download shelf and download contents.
362 ObserverList<Observer> observers_; 399 ObserverList<Observer> observers_;
363 400
364 // Time the download was started. 401 // Time the download was started.
365 base::Time start_time_; 402 base::Time start_time_;
366 403
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 450
414 // Net log to use for this download. 451 // Net log to use for this download.
415 const net::BoundNetLog bound_net_log_; 452 const net::BoundNetLog bound_net_log_;
416 453
417 base::WeakPtrFactory<DownloadItemImpl> weak_ptr_factory_; 454 base::WeakPtrFactory<DownloadItemImpl> weak_ptr_factory_;
418 455
419 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl); 456 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl);
420 }; 457 };
421 458
422 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ 459 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/download/download_file_manager_unittest.cc ('k') | content/browser/download/download_item_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698