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

Side by Side Diff: chrome/browser/renderer_host/sync_resource_handler.cc

Issue 19004: Change URLRequest to use a ref-counted buffer for actual IO.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/sync_resource_handler.h" 5 #include "chrome/browser/renderer_host/sync_resource_handler.h"
6 6
7 SyncResourceHandler::SyncResourceHandler( 7 SyncResourceHandler::SyncResourceHandler(
8 ResourceDispatcherHost::Receiver* receiver, 8 ResourceDispatcherHost::Receiver* receiver,
9 const GURL& url, 9 const GURL& url,
10 IPC::Message* result_message) 10 IPC::Message* result_message)
11 : receiver_(receiver), 11 : read_buffer_(new net::IOBuffer(kReadBufSize)),
12 receiver_(receiver),
12 result_message_(result_message) { 13 result_message_(result_message) {
13 result_.final_url = url; 14 result_.final_url = url;
14 result_.filter_policy = FilterPolicy::DONT_FILTER; 15 result_.filter_policy = FilterPolicy::DONT_FILTER;
15 } 16 }
16 17
17 bool SyncResourceHandler::OnRequestRedirected(int request_id, 18 bool SyncResourceHandler::OnRequestRedirected(int request_id,
18 const GURL& new_url) { 19 const GURL& new_url) {
19 result_.final_url = new_url; 20 result_.final_url = new_url;
20 return true; 21 return true;
21 } 22 }
22 23
23 bool SyncResourceHandler::OnResponseStarted(int request_id, 24 bool SyncResourceHandler::OnResponseStarted(int request_id,
24 ResourceResponse* response) { 25 ResourceResponse* response) {
25 // We don't care about copying the status here. 26 // We don't care about copying the status here.
26 result_.headers = response->response_head.headers; 27 result_.headers = response->response_head.headers;
27 result_.mime_type = response->response_head.mime_type; 28 result_.mime_type = response->response_head.mime_type;
28 result_.charset = response->response_head.charset; 29 result_.charset = response->response_head.charset;
29 return true; 30 return true;
30 } 31 }
31 32
32 bool SyncResourceHandler::OnWillRead(int request_id, 33 bool SyncResourceHandler::OnWillRead(int request_id, net::IOBuffer** buf,
33 char** buf, int* buf_size, int min_size) { 34 int* buf_size, int min_size) {
34 DCHECK(min_size == -1); 35 DCHECK(min_size == -1);
35 *buf = read_buffer_; 36 *buf = read_buffer_.get();
36 *buf_size = kReadBufSize; 37 *buf_size = kReadBufSize;
37 return true; 38 return true;
38 } 39 }
39 40
40 bool SyncResourceHandler::OnReadCompleted(int request_id, int* bytes_read) { 41 bool SyncResourceHandler::OnReadCompleted(int request_id, int* bytes_read) {
41 if (!*bytes_read) 42 if (!*bytes_read)
42 return true; 43 return true;
43 result_.data.append(read_buffer_, *bytes_read); 44 result_.data.append(read_buffer_->data(), *bytes_read);
44 return true; 45 return true;
45 } 46 }
46 47
47 bool SyncResourceHandler::OnResponseCompleted(int request_id, 48 bool SyncResourceHandler::OnResponseCompleted(int request_id,
48 const URLRequestStatus& status) { 49 const URLRequestStatus& status) {
49 result_.status = status; 50 result_.status = status;
50 51
51 ViewHostMsg_SyncLoad::WriteReplyParams(result_message_, result_); 52 ViewHostMsg_SyncLoad::WriteReplyParams(result_message_, result_);
52 receiver_->Send(result_message_); 53 receiver_->Send(result_message_);
53 return true; 54 return true;
54 } 55 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/sync_resource_handler.h ('k') | chrome/common/chrome_plugin_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698