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

Side by Side Diff: content/browser/download/save_file_resource_handler.cc

Issue 10578055: Rewrite guts of ResourceLoader and BufferedResourceHandler to suck less. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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/download/save_file_resource_handler.h" 5 #include "content/browser/download/save_file_resource_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 int* buf_size, int min_size) { 77 int* buf_size, int min_size) {
78 DCHECK(buf && buf_size); 78 DCHECK(buf && buf_size);
79 if (!read_buffer_) { 79 if (!read_buffer_) {
80 *buf_size = min_size < 0 ? kReadBufSize : min_size; 80 *buf_size = min_size < 0 ? kReadBufSize : min_size;
81 read_buffer_ = new net::IOBuffer(*buf_size); 81 read_buffer_ = new net::IOBuffer(*buf_size);
82 } 82 }
83 *buf = read_buffer_.get(); 83 *buf = read_buffer_.get();
84 return true; 84 return true;
85 } 85 }
86 86
87 bool SaveFileResourceHandler::OnReadCompleted(int request_id, int* bytes_read, 87 bool SaveFileResourceHandler::OnReadCompleted(int request_id, int bytes_read,
88 bool* defer) { 88 bool* defer) {
89 DCHECK(read_buffer_); 89 DCHECK(read_buffer_);
90 // We are passing ownership of this buffer to the save file manager. 90 // We are passing ownership of this buffer to the save file manager.
91 scoped_refptr<net::IOBuffer> buffer; 91 scoped_refptr<net::IOBuffer> buffer;
92 read_buffer_.swap(buffer); 92 read_buffer_.swap(buffer);
93 BrowserThread::PostTask( 93 BrowserThread::PostTask(
94 BrowserThread::FILE, FROM_HERE, 94 BrowserThread::FILE, FROM_HERE,
95 base::Bind(&SaveFileManager::UpdateSaveProgress, 95 base::Bind(&SaveFileManager::UpdateSaveProgress,
96 save_manager_, save_id_, buffer, *bytes_read)); 96 save_manager_, save_id_, buffer, bytes_read));
97 return true; 97 return true;
98 } 98 }
99 99
100 bool SaveFileResourceHandler::OnResponseCompleted( 100 bool SaveFileResourceHandler::OnResponseCompleted(
101 int request_id, 101 int request_id,
102 const net::URLRequestStatus& status, 102 const net::URLRequestStatus& status,
103 const std::string& security_info) { 103 const std::string& security_info) {
104 BrowserThread::PostTask( 104 BrowserThread::PostTask(
105 BrowserThread::FILE, FROM_HERE, 105 BrowserThread::FILE, FROM_HERE,
106 base::Bind(&SaveFileManager::SaveFinished, save_manager_, save_id_, url_, 106 base::Bind(&SaveFileManager::SaveFinished, save_manager_, save_id_, url_,
107 render_process_id_, status.is_success() && !status.is_io_pending())); 107 render_process_id_, status.is_success() && !status.is_io_pending()));
108 read_buffer_ = NULL; 108 read_buffer_ = NULL;
109 return true; 109 return true;
110 } 110 }
111 111
112 void SaveFileResourceHandler::set_content_length( 112 void SaveFileResourceHandler::set_content_length(
113 const std::string& content_length) { 113 const std::string& content_length) {
114 base::StringToInt64(content_length, &content_length_); 114 base::StringToInt64(content_length, &content_length_);
115 } 115 }
OLDNEW
« no previous file with comments | « content/browser/download/save_file_resource_handler.h ('k') | content/browser/renderer_host/async_resource_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698