OLD | NEW |
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 #include "base/logging.h" |
6 #include "chrome/common/render_messages.h" | 7 #include "chrome/common/render_messages.h" |
7 | 8 |
8 SyncResourceHandler::SyncResourceHandler( | 9 SyncResourceHandler::SyncResourceHandler( |
9 ResourceDispatcherHost::Receiver* receiver, | 10 ResourceDispatcherHost::Receiver* receiver, |
10 const GURL& url, | 11 const GURL& url, |
11 IPC::Message* result_message) | 12 IPC::Message* result_message) |
12 : read_buffer_(new net::IOBuffer(kReadBufSize)), | 13 : read_buffer_(new net::IOBuffer(kReadBufSize)), |
13 receiver_(receiver), | 14 receiver_(receiver), |
14 result_message_(result_message) { | 15 result_message_(result_message) { |
15 result_.final_url = url; | 16 result_.final_url = url; |
(...skipping 20 matching lines...) Expand all Loading... |
36 result_.headers = response->response_head.headers; | 37 result_.headers = response->response_head.headers; |
37 result_.mime_type = response->response_head.mime_type; | 38 result_.mime_type = response->response_head.mime_type; |
38 result_.charset = response->response_head.charset; | 39 result_.charset = response->response_head.charset; |
39 return true; | 40 return true; |
40 } | 41 } |
41 | 42 |
42 bool SyncResourceHandler::OnWillRead(int request_id, net::IOBuffer** buf, | 43 bool SyncResourceHandler::OnWillRead(int request_id, net::IOBuffer** buf, |
43 int* buf_size, int min_size) { | 44 int* buf_size, int min_size) { |
44 DCHECK(min_size == -1); | 45 DCHECK(min_size == -1); |
45 *buf = read_buffer_.get(); | 46 *buf = read_buffer_.get(); |
| 47 // TODO(willchan): Remove after debugging bug 16371. |
| 48 CHECK(read_buffer_->data()); |
46 *buf_size = kReadBufSize; | 49 *buf_size = kReadBufSize; |
47 return true; | 50 return true; |
48 } | 51 } |
49 | 52 |
50 bool SyncResourceHandler::OnReadCompleted(int request_id, int* bytes_read) { | 53 bool SyncResourceHandler::OnReadCompleted(int request_id, int* bytes_read) { |
51 if (!*bytes_read) | 54 if (!*bytes_read) |
52 return true; | 55 return true; |
53 result_.data.append(read_buffer_->data(), *bytes_read); | 56 result_.data.append(read_buffer_->data(), *bytes_read); |
54 return true; | 57 return true; |
55 } | 58 } |
56 | 59 |
57 bool SyncResourceHandler::OnResponseCompleted( | 60 bool SyncResourceHandler::OnResponseCompleted( |
58 int request_id, | 61 int request_id, |
59 const URLRequestStatus& status, | 62 const URLRequestStatus& status, |
60 const std::string& security_info) { | 63 const std::string& security_info) { |
61 result_.status = status; | 64 result_.status = status; |
62 | 65 |
63 ViewHostMsg_SyncLoad::WriteReplyParams(result_message_, result_); | 66 ViewHostMsg_SyncLoad::WriteReplyParams(result_message_, result_); |
64 receiver_->Send(result_message_); | 67 receiver_->Send(result_message_); |
65 result_message_ = NULL; | 68 result_message_ = NULL; |
66 return true; | 69 return true; |
67 } | 70 } |
OLD | NEW |