OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 net::URLRequest, meaning it is a "simple" | 6 // The class is implemented using net::URLRequest, meaning it is a "simple" |
7 // version that directly issues requests. The more complicated one used in the | 7 // version that directly issues requests. The more complicated one used in the |
8 // browser uses IPC. | 8 // browser uses IPC. |
9 // | 9 // |
10 // Because net::URLRequest only provides an asynchronous resource loading API, | 10 // Because net::URLRequest only provides an asynchronous resource loading API, |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 // Continue reading more data into buf_ | 298 // Continue reading more data into buf_ |
299 // Note: Doing this before notifying our peer ensures our load events get | 299 // Note: Doing this before notifying our peer ensures our load events get |
300 // dispatched in a manner consistent with DumpRenderTree (and also avoids a | 300 // dispatched in a manner consistent with DumpRenderTree (and also avoids a |
301 // race condition). If the order of the next 2 functions were reversed, the | 301 // race condition). If the order of the next 2 functions were reversed, the |
302 // peer could generate new requests in reponse to the received data, which | 302 // peer could generate new requests in reponse to the received data, which |
303 // when run on the io thread, could race against this function in doing | 303 // when run on the io thread, could race against this function in doing |
304 // another InvokeLater. See bug 769249. | 304 // another InvokeLater. See bug 769249. |
305 g_io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 305 g_io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( |
306 this, &RequestProxy::AsyncReadData)); | 306 this, &RequestProxy::AsyncReadData)); |
307 | 307 |
308 peer_->OnReceivedData(buf_copy.get(), bytes_read); | 308 peer_->OnReceivedData(buf_copy.get(), bytes_read, -1); |
309 } | 309 } |
310 | 310 |
311 void NotifyDownloadedData(int bytes_read) { | 311 void NotifyDownloadedData(int bytes_read) { |
312 if (!peer_) | 312 if (!peer_) |
313 return; | 313 return; |
314 | 314 |
315 // Continue reading more data, see the comment in NotifyReceivedData. | 315 // Continue reading more data, see the comment in NotifyReceivedData. |
316 g_io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 316 g_io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( |
317 this, &RequestProxy::AsyncReadData)); | 317 this, &RequestProxy::AsyncReadData)); |
318 | 318 |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 | 947 |
948 // static | 948 // static |
949 scoped_refptr<base::MessageLoopProxy> | 949 scoped_refptr<base::MessageLoopProxy> |
950 SimpleResourceLoaderBridge::GetIoThread() { | 950 SimpleResourceLoaderBridge::GetIoThread() { |
951 if (!EnsureIOThread()) { | 951 if (!EnsureIOThread()) { |
952 LOG(DFATAL) << "Failed to create IO thread."; | 952 LOG(DFATAL) << "Failed to create IO thread."; |
953 return NULL; | 953 return NULL; |
954 } | 954 } |
955 return g_io_thread->message_loop_proxy(); | 955 return g_io_thread->message_loop_proxy(); |
956 } | 956 } |
OLD | NEW |