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_redirect_job.h" | 5 #include "net/url_request/url_request_redirect_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 | 10 |
11 namespace net { | 11 namespace net { |
12 | 12 |
13 URLRequestRedirectJob::URLRequestRedirectJob(URLRequest* request, | 13 URLRequestRedirectJob::URLRequestRedirectJob(URLRequest* request, |
14 NetworkDelegate* network_delegate, | 14 NetworkDelegate* network_delegate, |
15 const GURL& redirect_destination) | 15 const GURL& redirect_destination, |
| 16 StatusCode http_status_code) |
16 : URLRequestJob(request, network_delegate), | 17 : URLRequestJob(request, network_delegate), |
17 redirect_destination_(redirect_destination), | 18 redirect_destination_(redirect_destination), |
18 http_status_code_(302), | 19 http_status_code_(http_status_code), |
19 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {} | 20 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {} |
20 | 21 |
21 void URLRequestRedirectJob::Start() { | 22 void URLRequestRedirectJob::Start() { |
22 MessageLoop::current()->PostTask( | 23 MessageLoop::current()->PostTask( |
23 FROM_HERE, | 24 FROM_HERE, |
24 base::Bind(&URLRequestRedirectJob::StartAsync, | 25 base::Bind(&URLRequestRedirectJob::StartAsync, |
25 weak_factory_.GetWeakPtr())); | 26 weak_factory_.GetWeakPtr())); |
26 } | 27 } |
27 | 28 |
28 bool URLRequestRedirectJob::IsRedirectResponse(GURL* location, | 29 bool URLRequestRedirectJob::IsRedirectResponse(GURL* location, |
29 int* http_status_code) { | 30 int* http_status_code) { |
30 *location = redirect_destination_; | 31 *location = redirect_destination_; |
31 *http_status_code = http_status_code_; | 32 *http_status_code = http_status_code_; |
32 return true; | 33 return true; |
33 } | 34 } |
34 | 35 |
35 URLRequestRedirectJob::~URLRequestRedirectJob() {} | 36 URLRequestRedirectJob::~URLRequestRedirectJob() {} |
36 | 37 |
37 void URLRequestRedirectJob::StartAsync() { | 38 void URLRequestRedirectJob::StartAsync() { |
38 NotifyHeadersComplete(); | 39 NotifyHeadersComplete(); |
39 } | 40 } |
40 | 41 |
41 } // namespace net | 42 } // namespace net |
OLD | NEW |