OLD | NEW |
---|---|
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 Loading... | |
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 RenameOptions above. | |
Randy Smith (Not in Mondays)
2014/06/11 18:07:29
nit: No 's' (IMO).
asanka
2014/06/12 20:02:37
Done.
| |
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| should be empty when this method is called for the | |
92 // first time. | |
Randy Smith (Not in Mondays)
2014/06/11 18:07:29
If you just read the comment, you're left with the
asanka
2014/06/12 20:02:37
Reworded.
| |
93 void RenameWithRetryInternal(const base::FilePath& new_path, | |
94 RenameOption option, | |
95 int retries_left, | |
96 base::TimeTicks time_of_first_failure, | |
97 const RenameCompletionCallback& callback); | |
98 | |
72 // Send an update on our progress. | 99 // Send an update on our progress. |
73 void SendUpdate(); | 100 void SendUpdate(); |
74 | 101 |
75 // Called when there's some activity on stream_reader_ that needs to be | 102 // Called when there's some activity on stream_reader_ that needs to be |
76 // handled. | 103 // handled. |
77 void StreamActive(); | 104 void StreamActive(); |
78 | 105 |
79 // The base file instance. | 106 // The base file instance. |
80 BaseFile file_; | 107 BaseFile file_; |
81 | 108 |
(...skipping 20 matching lines...) Expand all Loading... | |
102 base::WeakPtr<DownloadDestinationObserver> observer_; | 129 base::WeakPtr<DownloadDestinationObserver> observer_; |
103 | 130 |
104 base::WeakPtrFactory<DownloadFileImpl> weak_factory_; | 131 base::WeakPtrFactory<DownloadFileImpl> weak_factory_; |
105 | 132 |
106 DISALLOW_COPY_AND_ASSIGN(DownloadFileImpl); | 133 DISALLOW_COPY_AND_ASSIGN(DownloadFileImpl); |
107 }; | 134 }; |
108 | 135 |
109 } // namespace content | 136 } // namespace content |
110 | 137 |
111 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ | 138 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ |
OLD | NEW |