| 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 // This file contains an implementation of the ResourceLoaderBridge class. | 5 // This file contains an implementation of the ResourceLoaderBridge class. |
| 6 // The class is implemented using URLRequest, meaning it is a "simple" version | 6 // The class is implemented using URLRequest, meaning it is a "simple" version |
| 7 // that directly issues requests. The more complicated one used in the | 7 // that directly issues requests. The more complicated one used in the |
| 8 // browser uses IPC. | 8 // browser uses IPC. |
| 9 // | 9 // |
| 10 // Because URLRequest only provides an asynchronous resource loading API, this | 10 // Because URLRequest only provides an asynchronous resource loading API, this |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 // race condition). If the order of the next 2 functions were reversed, the | 165 // race condition). If the order of the next 2 functions were reversed, the |
| 166 // peer could generate new requests in reponse to the received data, which | 166 // peer could generate new requests in reponse to the received data, which |
| 167 // when run on the io thread, could race against this function in doing | 167 // when run on the io thread, could race against this function in doing |
| 168 // another InvokeLater. See bug 769249. | 168 // another InvokeLater. See bug 769249. |
| 169 io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 169 io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( |
| 170 this, &RequestProxy::AsyncReadData)); | 170 this, &RequestProxy::AsyncReadData)); |
| 171 | 171 |
| 172 peer_->OnReceivedData(buf_copy.get(), bytes_read); | 172 peer_->OnReceivedData(buf_copy.get(), bytes_read); |
| 173 } | 173 } |
| 174 | 174 |
| 175 void NotifyCompletedRequest(const URLRequestStatus& status) { | 175 void NotifyCompletedRequest(const URLRequestStatus& status, |
| 176 const std::string& security_info) { |
| 176 if (peer_) { | 177 if (peer_) { |
| 177 peer_->OnCompletedRequest(status); | 178 peer_->OnCompletedRequest(status, security_info); |
| 178 DropPeer(); // ensure no further notifications | 179 DropPeer(); // ensure no further notifications |
| 179 } | 180 } |
| 180 } | 181 } |
| 181 | 182 |
| 182 // -------------------------------------------------------------------------- | 183 // -------------------------------------------------------------------------- |
| 183 // The following methods are called on the io thread. They correspond to | 184 // The following methods are called on the io thread. They correspond to |
| 184 // actions performed on the owner's thread. | 185 // actions performed on the owner's thread. |
| 185 | 186 |
| 186 void AsyncStart(RequestParams* params) { | 187 void AsyncStart(RequestParams* params) { |
| 187 request_.reset(new URLRequest(params->url, this)); | 188 request_.reset(new URLRequest(params->url, this)); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 bool content_filtered) { | 239 bool content_filtered) { |
| 239 owner_loop_->PostTask(FROM_HERE, NewRunnableMethod( | 240 owner_loop_->PostTask(FROM_HERE, NewRunnableMethod( |
| 240 this, &RequestProxy::NotifyReceivedResponse, info, content_filtered)); | 241 this, &RequestProxy::NotifyReceivedResponse, info, content_filtered)); |
| 241 } | 242 } |
| 242 | 243 |
| 243 virtual void OnReceivedData(int bytes_read) { | 244 virtual void OnReceivedData(int bytes_read) { |
| 244 owner_loop_->PostTask(FROM_HERE, NewRunnableMethod( | 245 owner_loop_->PostTask(FROM_HERE, NewRunnableMethod( |
| 245 this, &RequestProxy::NotifyReceivedData, bytes_read)); | 246 this, &RequestProxy::NotifyReceivedData, bytes_read)); |
| 246 } | 247 } |
| 247 | 248 |
| 248 virtual void OnCompletedRequest(const URLRequestStatus& status) { | 249 virtual void OnCompletedRequest(const URLRequestStatus& status, |
| 250 const std::string& security_info) { |
| 249 owner_loop_->PostTask(FROM_HERE, NewRunnableMethod( | 251 owner_loop_->PostTask(FROM_HERE, NewRunnableMethod( |
| 250 this, &RequestProxy::NotifyCompletedRequest, status)); | 252 this, &RequestProxy::NotifyCompletedRequest, status, security_info)); |
| 251 } | 253 } |
| 252 | 254 |
| 253 // -------------------------------------------------------------------------- | 255 // -------------------------------------------------------------------------- |
| 254 // URLRequest::Delegate implementation: | 256 // URLRequest::Delegate implementation: |
| 255 | 257 |
| 256 virtual void OnReceivedRedirect(URLRequest* request, | 258 virtual void OnReceivedRedirect(URLRequest* request, |
| 257 const GURL& new_url) { | 259 const GURL& new_url) { |
| 258 DCHECK(request->status().is_success()); | 260 DCHECK(request->status().is_success()); |
| 259 OnReceivedRedirect(new_url); | 261 OnReceivedRedirect(new_url); |
| 260 } | 262 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 281 } else { | 283 } else { |
| 282 Done(); | 284 Done(); |
| 283 } | 285 } |
| 284 } | 286 } |
| 285 | 287 |
| 286 // -------------------------------------------------------------------------- | 288 // -------------------------------------------------------------------------- |
| 287 // Helpers and data: | 289 // Helpers and data: |
| 288 | 290 |
| 289 void Done() { | 291 void Done() { |
| 290 DCHECK(request_.get()); | 292 DCHECK(request_.get()); |
| 291 OnCompletedRequest(request_->status()); | 293 OnCompletedRequest(request_->status(), std::string()); |
| 292 request_.reset(); // destroy on the io thread | 294 request_.reset(); // destroy on the io thread |
| 293 } | 295 } |
| 294 | 296 |
| 295 scoped_ptr<URLRequest> request_; | 297 scoped_ptr<URLRequest> request_; |
| 296 | 298 |
| 297 // Size of our async IO data buffers | 299 // Size of our async IO data buffers |
| 298 static const int kDataSize = 16*1024; | 300 static const int kDataSize = 16*1024; |
| 299 | 301 |
| 300 // read buffer for async IO | 302 // read buffer for async IO |
| 301 scoped_refptr<net::IOBuffer> buf_; | 303 scoped_refptr<net::IOBuffer> buf_; |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 // static | 568 // static |
| 567 void SimpleResourceLoaderBridge::Shutdown() { | 569 void SimpleResourceLoaderBridge::Shutdown() { |
| 568 if (io_thread) { | 570 if (io_thread) { |
| 569 delete io_thread; | 571 delete io_thread; |
| 570 io_thread = NULL; | 572 io_thread = NULL; |
| 571 | 573 |
| 572 DCHECK(!request_context) << "should have been nulled by thread dtor"; | 574 DCHECK(!request_context) << "should have been nulled by thread dtor"; |
| 573 } | 575 } |
| 574 } | 576 } |
| 575 | 577 |
| OLD | NEW |