OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome/browser/renderer_host/redirect_to_file_resource_handler.h" | 5 #include "chrome/browser/renderer_host/redirect_to_file_resource_handler.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/file_util_proxy.h" | 8 #include "base/file_util_proxy.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 } | 156 } |
157 | 157 |
158 void RedirectToFileResourceHandler::DidCreateTemporaryFile( | 158 void RedirectToFileResourceHandler::DidCreateTemporaryFile( |
159 base::PlatformFileError /*error_code*/, | 159 base::PlatformFileError /*error_code*/, |
160 base::PassPlatformFile file_handle, | 160 base::PassPlatformFile file_handle, |
161 FilePath file_path) { | 161 FilePath file_path) { |
162 file_path_ = file_path; | 162 file_path_ = file_path; |
163 file_stream_.reset(new net::FileStream(file_handle.ReleaseValue(), | 163 file_stream_.reset(new net::FileStream(file_handle.ReleaseValue(), |
164 base::PLATFORM_FILE_WRITE | | 164 base::PLATFORM_FILE_WRITE | |
165 base::PLATFORM_FILE_ASYNC)); | 165 base::PLATFORM_FILE_ASYNC)); |
166 ChildProcessSecurityPolicy::GetInstance()->GrantUploadFile( | 166 ChildProcessSecurityPolicy::GetInstance()->GrantReadFile( |
167 process_id_, file_path); | 167 process_id_, file_path); |
168 host_->StartDeferredRequest(process_id_, request_id_); | 168 host_->StartDeferredRequest(process_id_, request_id_); |
169 } | 169 } |
170 | 170 |
171 void RedirectToFileResourceHandler::DidWriteToFile(int result) { | 171 void RedirectToFileResourceHandler::DidWriteToFile(int result) { |
172 write_callback_pending_ = false; | 172 write_callback_pending_ = false; |
173 | 173 |
174 bool failed = false; | 174 bool failed = false; |
175 if (result > 0) { | 175 if (result > 0) { |
176 write_cursor_ += result; | 176 write_cursor_ += result; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 } | 213 } |
214 } | 214 } |
215 | 215 |
216 bool RedirectToFileResourceHandler::BufIsFull() const { | 216 bool RedirectToFileResourceHandler::BufIsFull() const { |
217 // This is a hack to workaround BufferedResourceHandler's inability to | 217 // This is a hack to workaround BufferedResourceHandler's inability to |
218 // deal with a ResourceHandler that returns a buffer size of less than | 218 // deal with a ResourceHandler that returns a buffer size of less than |
219 // 2 * net::kMaxBytesToSniff from its OnWillRead method. | 219 // 2 * net::kMaxBytesToSniff from its OnWillRead method. |
220 // TODO(darin): Fix this retardation! | 220 // TODO(darin): Fix this retardation! |
221 return buf_->RemainingCapacity() <= (2 * net::kMaxBytesToSniff); | 221 return buf_->RemainingCapacity() <= (2 * net::kMaxBytesToSniff); |
222 } | 222 } |
OLD | NEW |