OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/renderer_host/redirect_to_file_resource_handler.h" | 5 #include "content/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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 const GURL& url, | 69 const GURL& url, |
70 bool* defer) { | 70 bool* defer) { |
71 request_id_ = request_id; | 71 request_id_ = request_id; |
72 if (!deletable_file_) { | 72 if (!deletable_file_) { |
73 // Defer starting the request until we have created the temporary file. | 73 // Defer starting the request until we have created the temporary file. |
74 // TODO(darin): This is sub-optimal. We should not delay starting the | 74 // TODO(darin): This is sub-optimal. We should not delay starting the |
75 // network request like this. | 75 // network request like this. |
76 *defer = true; | 76 *defer = true; |
77 base::FileUtilProxy::CreateTemporary( | 77 base::FileUtilProxy::CreateTemporary( |
78 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | 78 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
| 79 base::PLATFORM_FILE_ASYNC, |
79 callback_factory_.NewCallback( | 80 callback_factory_.NewCallback( |
80 &RedirectToFileResourceHandler::DidCreateTemporaryFile)); | 81 &RedirectToFileResourceHandler::DidCreateTemporaryFile)); |
81 return true; | 82 return true; |
82 } | 83 } |
83 return next_handler_->OnWillStart(request_id, url, defer); | 84 return next_handler_->OnWillStart(request_id, url, defer); |
84 } | 85 } |
85 | 86 |
86 bool RedirectToFileResourceHandler::OnWillRead(int request_id, | 87 bool RedirectToFileResourceHandler::OnWillRead(int request_id, |
87 net::IOBuffer** buf, | 88 net::IOBuffer** buf, |
88 int* buf_size, | 89 int* buf_size, |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 } | 225 } |
225 } | 226 } |
226 | 227 |
227 bool RedirectToFileResourceHandler::BufIsFull() const { | 228 bool RedirectToFileResourceHandler::BufIsFull() const { |
228 // This is a hack to workaround BufferedResourceHandler's inability to | 229 // This is a hack to workaround BufferedResourceHandler's inability to |
229 // deal with a ResourceHandler that returns a buffer size of less than | 230 // deal with a ResourceHandler that returns a buffer size of less than |
230 // 2 * net::kMaxBytesToSniff from its OnWillRead method. | 231 // 2 * net::kMaxBytesToSniff from its OnWillRead method. |
231 // TODO(darin): Fix this retardation! | 232 // TODO(darin): Fix this retardation! |
232 return buf_->RemainingCapacity() <= (2 * net::kMaxBytesToSniff); | 233 return buf_->RemainingCapacity() <= (2 * net::kMaxBytesToSniff); |
233 } | 234 } |
OLD | NEW |