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

Unified Diff: content/browser/download/download_file_impl.h

Issue 319603003: [Downloads] Retry renames after transient failures. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/download/download_file_impl.h
diff --git a/content/browser/download/download_file_impl.h b/content/browser/download/download_file_impl.h
index 2ba3d8d058e27211d3eaefc32c9e177f511e67d1..a483d7ab9f45255855d673783cee01cab9fa18e4 100644
--- a/content/browser/download/download_file_impl.h
+++ b/content/browser/download/download_file_impl.h
@@ -68,7 +68,37 @@ class CONTENT_EXPORT DownloadFileImpl : virtual public DownloadFile {
virtual DownloadInterruptReason AppendDataToFile(
const char* data, size_t data_len);
+ virtual base::TimeDelta GetRetryDelayForFailedRename(int attempt_number);
+
+ virtual bool ShouldRetryFailedRename(DownloadInterruptReason reason);
+
private:
+ friend class DownloadFileTest;
+
+ // Options for RenameWithRetryInternal.
+ enum RenameOption {
+ UNIQUIFY = 1 << 0, // If there's already a file on disk that conflicts with
+ // |new_path|, try to create a unique file by appending
+ // a uniquifier.
+ ANNOTATE_WITH_SOURCE_INFORMATION = 1 << 1
+ };
+
+ // Rename file_ to |new_path|.
+ // |option| specifies additional operations to be performed during the rename.
+ // See RenameOption above.
+ // |retries_left| indicates how many times to retry the operation if the
+ // rename fails with a transient error.
+ // |time_of_first_failure| Set
+ // to an empty base::TimeTicks during the first call. Once the first
+ // failure is seen, subsequent calls of RenameWithRetryInternal will have
+ // a non-empty value keeping track of the time of first observed failure.
+ // Used for UMA.
+ void RenameWithRetryInternal(const base::FilePath& new_path,
+ RenameOption option,
+ int retries_left,
+ base::TimeTicks time_of_first_failure,
+ const RenameCompletionCallback& callback);
+
// Send an update on our progress.
void SendUpdate();

Powered by Google App Engine
This is Rietveld 408576698