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

Side by Side Diff: content/browser/loader/redirect_to_file_resource_handler.cc

Issue 15984016: Call scoped_refptr<T>::get() rather than relying on implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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 #include "content/browser/loader/redirect_to_file_resource_handler.h" 5 #include "content/browser/loader/redirect_to_file_resource_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_util_proxy.h" 8 #include "base/files/file_util_proxy.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 bool RedirectToFileResourceHandler::OnWillStart(int request_id, 88 bool RedirectToFileResourceHandler::OnWillStart(int request_id,
89 const GURL& url, 89 const GURL& url,
90 bool* defer) { 90 bool* defer) {
91 request_id_ = request_id; 91 request_id_ = request_id;
92 if (!deletable_file_.get()) { 92 if (!deletable_file_.get()) {
93 // Defer starting the request until we have created the temporary file. 93 // Defer starting the request until we have created the temporary file.
94 // TODO(darin): This is sub-optimal. We should not delay starting the 94 // TODO(darin): This is sub-optimal. We should not delay starting the
95 // network request like this. 95 // network request like this.
96 did_defer_ = *defer = true; 96 did_defer_ = *defer = true;
97 base::FileUtilProxy::CreateTemporary( 97 base::FileUtilProxy::CreateTemporary(
98 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), 98 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE).get(),
99 base::PLATFORM_FILE_ASYNC, 99 base::PLATFORM_FILE_ASYNC,
100 base::Bind(&RedirectToFileResourceHandler::DidCreateTemporaryFile, 100 base::Bind(&RedirectToFileResourceHandler::DidCreateTemporaryFile,
101 weak_factory_.GetWeakPtr())); 101 weak_factory_.GetWeakPtr()));
102 return true; 102 return true;
103 } 103 }
104 return next_handler_->OnWillStart(request_id, url, defer); 104 return next_handler_->OnWillStart(request_id, url, defer);
105 } 105 }
106 106
107 bool RedirectToFileResourceHandler::OnWillRead(int request_id, 107 bool RedirectToFileResourceHandler::OnWillRead(int request_id,
108 net::IOBuffer** buf, 108 net::IOBuffer** buf,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 return false; 158 return false;
159 } 159 }
160 return next_handler_->OnResponseCompleted(request_id, status, security_info); 160 return next_handler_->OnResponseCompleted(request_id, status, security_info);
161 } 161 }
162 162
163 void RedirectToFileResourceHandler::DidCreateTemporaryFile( 163 void RedirectToFileResourceHandler::DidCreateTemporaryFile(
164 base::PlatformFileError /*error_code*/, 164 base::PlatformFileError /*error_code*/,
165 base::PassPlatformFile file_handle, 165 base::PassPlatformFile file_handle,
166 const base::FilePath& file_path) { 166 const base::FilePath& file_path) {
167 deletable_file_ = ShareableFileReference::GetOrCreate( 167 deletable_file_ = ShareableFileReference::GetOrCreate(
168 file_path, ShareableFileReference::DELETE_ON_FINAL_RELEASE, 168 file_path,
169 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); 169 ShareableFileReference::DELETE_ON_FINAL_RELEASE,
170 file_stream_.reset(new net::FileStream(file_handle.ReleaseValue(), 170 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE).get());
171 base::PLATFORM_FILE_WRITE | 171 file_stream_.reset(
172 base::PLATFORM_FILE_ASYNC, 172 new net::FileStream(file_handle.ReleaseValue(),
173 NULL)); 173 base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_ASYNC,
174 NULL));
174 host_->RegisterDownloadedTempFile( 175 host_->RegisterDownloadedTempFile(
175 process_id_, request_id_, deletable_file_.get()); 176 process_id_, request_id_, deletable_file_.get());
176 ResumeIfDeferred(); 177 ResumeIfDeferred();
177 } 178 }
178 179
179 void RedirectToFileResourceHandler::DidWriteToFile(int result) { 180 void RedirectToFileResourceHandler::DidWriteToFile(int result) {
180 write_callback_pending_ = false; 181 write_callback_pending_ = false;
181 182
182 bool failed = false; 183 bool failed = false;
183 if (result > 0) { 184 if (result > 0) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 } 260 }
260 261
261 void RedirectToFileResourceHandler::ResumeIfDeferred() { 262 void RedirectToFileResourceHandler::ResumeIfDeferred() {
262 if (did_defer_) { 263 if (did_defer_) {
263 did_defer_ = false; 264 did_defer_ = false;
264 controller()->Resume(); 265 controller()->Resume();
265 } 266 }
266 } 267 }
267 268
268 } // namespace content 269 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/webidbdatabase_impl.cc ('k') | content/browser/loader/resource_dispatcher_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698