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

Side by Side 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: Prepare to reland after XP test fix. Created 6 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_FILE_IMPL_H_ 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_
6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_
7 7
8 #include "content/browser/download/download_file.h" 8 #include "content/browser/download/download_file.h"
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 virtual int64 CurrentSpeed() const OVERRIDE; 61 virtual int64 CurrentSpeed() const OVERRIDE;
62 virtual bool GetHash(std::string* hash) OVERRIDE; 62 virtual bool GetHash(std::string* hash) OVERRIDE;
63 virtual std::string GetHashState() OVERRIDE; 63 virtual std::string GetHashState() OVERRIDE;
64 virtual void SetClientGuid(const std::string& guid) OVERRIDE; 64 virtual void SetClientGuid(const std::string& guid) OVERRIDE;
65 65
66 protected: 66 protected:
67 // For test class overrides. 67 // For test class overrides.
68 virtual DownloadInterruptReason AppendDataToFile( 68 virtual DownloadInterruptReason AppendDataToFile(
69 const char* data, size_t data_len); 69 const char* data, size_t data_len);
70 70
71 virtual base::TimeDelta GetRetryDelayForFailedRename(int attempt_number);
72
73 virtual bool ShouldRetryFailedRename(DownloadInterruptReason reason);
74
71 private: 75 private:
76 friend class DownloadFileTest;
77
78 // Options for RenameWithRetryInternal.
79 enum RenameOption {
80 UNIQUIFY = 1 << 0, // If there's already a file on disk that conflicts with
81 // |new_path|, try to create a unique file by appending
82 // a uniquifier.
83 ANNOTATE_WITH_SOURCE_INFORMATION = 1 << 1
84 };
85
86 // Rename file_ to |new_path|.
87 // |option| specifies additional operations to be performed during the rename.
88 // See RenameOption above.
89 // |retries_left| indicates how many times to retry the operation if the
90 // rename fails with a transient error.
91 // |time_of_first_failure| Set to an empty base::TimeTicks during the first
92 // call. Once the first failure is seen, subsequent calls of
93 // RenameWithRetryInternal will have a non-empty value keeping track of
94 // the time of first observed failure. Used for UMA.
95 void RenameWithRetryInternal(const base::FilePath& new_path,
96 RenameOption option,
97 int retries_left,
98 base::TimeTicks time_of_first_failure,
99 const RenameCompletionCallback& callback);
100
72 // Send an update on our progress. 101 // Send an update on our progress.
73 void SendUpdate(); 102 void SendUpdate();
74 103
75 // Called when there's some activity on stream_reader_ that needs to be 104 // Called when there's some activity on stream_reader_ that needs to be
76 // handled. 105 // handled.
77 void StreamActive(); 106 void StreamActive();
78 107
79 // The base file instance. 108 // The base file instance.
80 BaseFile file_; 109 BaseFile file_;
81 110
(...skipping 20 matching lines...) Expand all
102 base::WeakPtr<DownloadDestinationObserver> observer_; 131 base::WeakPtr<DownloadDestinationObserver> observer_;
103 132
104 base::WeakPtrFactory<DownloadFileImpl> weak_factory_; 133 base::WeakPtrFactory<DownloadFileImpl> weak_factory_;
105 134
106 DISALLOW_COPY_AND_ASSIGN(DownloadFileImpl); 135 DISALLOW_COPY_AND_ASSIGN(DownloadFileImpl);
107 }; 136 };
108 137
109 } // namespace content 138 } // namespace content
110 139
111 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ 140 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/download/base_file_win.cc ('k') | content/browser/download/download_file_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698