| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 NET_URL_REQUEST_URL_FETCHER_RESPONSE_WRITER_H_ | 5 #ifndef NET_URL_REQUEST_URL_FETCHER_RESPONSE_WRITER_H_ |
| 6 #define NET_URL_REQUEST_URL_FETCHER_RESPONSE_WRITER_H_ | 6 #define NET_URL_REQUEST_URL_FETCHER_RESPONSE_WRITER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 private: | 105 private: |
| 106 // Callback which gets the result of a temporary file creation. | 106 // Callback which gets the result of a temporary file creation. |
| 107 void DidCreateTempFile(const CompletionCallback& callback, | 107 void DidCreateTempFile(const CompletionCallback& callback, |
| 108 base::FilePath* temp_file_path, | 108 base::FilePath* temp_file_path, |
| 109 bool success); | 109 bool success); |
| 110 | 110 |
| 111 // Callback which gets the result of FileStream::Open. | 111 // Callback which gets the result of FileStream::Open. |
| 112 void DidOpenFile(const CompletionCallback& callback, | 112 void DidOpenFile(const CompletionCallback& callback, |
| 113 int result); | 113 int result); |
| 114 | 114 |
| 115 // Callback which gets the result of closing a file. |
| 116 void CloseComplete(const CompletionCallback& callback, int result); |
| 117 |
| 115 // The last error encountered on a file operation. OK if no error occurred. | 118 // The last error encountered on a file operation. OK if no error occurred. |
| 116 int error_code_; | 119 int error_code_; |
| 117 | 120 |
| 118 // Callbacks are created for use with base::FileUtilProxy. | 121 // Callbacks are created for use with base::FileUtilProxy. |
| 119 base::WeakPtrFactory<URLFetcherFileWriter> weak_factory_; | 122 base::WeakPtrFactory<URLFetcherFileWriter> weak_factory_; |
| 120 | 123 |
| 121 // Task runner on which file operations should happen. | 124 // Task runner on which file operations should happen. |
| 122 scoped_refptr<base::TaskRunner> file_task_runner_; | 125 scoped_refptr<base::TaskRunner> file_task_runner_; |
| 123 | 126 |
| 124 // Destination file path. | 127 // Destination file path. |
| 125 // Initialize() creates a temporary file if this variable is empty. | 128 // Initialize() creates a temporary file if this variable is empty. |
| 126 base::FilePath file_path_; | 129 base::FilePath file_path_; |
| 127 | 130 |
| 128 // True when this instance is responsible to delete the file at |file_path_|. | 131 // True when this instance is responsible to delete the file at |file_path_|. |
| 129 bool owns_file_; | 132 bool owns_file_; |
| 130 | 133 |
| 131 scoped_ptr<FileStream> file_stream_; | 134 scoped_ptr<FileStream> file_stream_; |
| 132 | 135 |
| 133 // We always append to the file. Track the total number of bytes | 136 // We always append to the file. Track the total number of bytes |
| 134 // written, so that writes know the offset to give. | 137 // written, so that writes know the offset to give. |
| 135 int64 total_bytes_written_; | 138 int64 total_bytes_written_; |
| 136 | 139 |
| 137 DISALLOW_COPY_AND_ASSIGN(URLFetcherFileWriter); | 140 DISALLOW_COPY_AND_ASSIGN(URLFetcherFileWriter); |
| 138 }; | 141 }; |
| 139 | 142 |
| 140 } // namespace net | 143 } // namespace net |
| 141 | 144 |
| 142 #endif // NET_URL_REQUEST_URL_FETCHER_RESPONSE_WRITER_H_ | 145 #endif // NET_URL_REQUEST_URL_FETCHER_RESPONSE_WRITER_H_ |
| OLD | NEW |