OLD | NEW |
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 "net/url_request/url_request_simple_job.h" | 5 #include "net/url_request/url_request_simple_job.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
12 #include "net/url_request/url_request.h" | |
13 #include "net/url_request/url_request_context.h" | |
14 #include "net/url_request/url_request_status.h" | 12 #include "net/url_request/url_request_status.h" |
15 | 13 |
16 namespace net { | 14 namespace net { |
17 | 15 |
18 URLRequestSimpleJob::URLRequestSimpleJob(URLRequest* request) | 16 URLRequestSimpleJob::URLRequestSimpleJob( |
19 : URLRequestJob(request, request->context()->network_delegate()), | 17 URLRequest* request, NetworkDelegate* network_delegate) |
| 18 : URLRequestJob(request, network_delegate), |
20 data_offset_(0), | 19 data_offset_(0), |
21 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {} | 20 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {} |
22 | 21 |
23 void URLRequestSimpleJob::Start() { | 22 void URLRequestSimpleJob::Start() { |
24 // Start reading asynchronously so that all error reporting and data | 23 // Start reading asynchronously so that all error reporting and data |
25 // callbacks happen as they would for network requests. | 24 // callbacks happen as they would for network requests. |
26 MessageLoop::current()->PostTask( | 25 MessageLoop::current()->PostTask( |
27 FROM_HERE, | 26 FROM_HERE, |
28 base::Bind(&URLRequestSimpleJob::StartAsync, | 27 base::Bind(&URLRequestSimpleJob::StartAsync, |
29 weak_factory_.GetWeakPtr())); | 28 weak_factory_.GetWeakPtr())); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 void URLRequestSimpleJob::OnGetDataCompleted(int result) { | 66 void URLRequestSimpleJob::OnGetDataCompleted(int result) { |
68 if (result == OK) { | 67 if (result == OK) { |
69 // Notify that the headers are complete | 68 // Notify that the headers are complete |
70 NotifyHeadersComplete(); | 69 NotifyHeadersComplete(); |
71 } else { | 70 } else { |
72 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, result)); | 71 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, result)); |
73 } | 72 } |
74 } | 73 } |
75 | 74 |
76 } // namespace net | 75 } // namespace net |
OLD | NEW |