• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #include "net/url_request/url_request_redirect_job.h"
6 
7 #include "base/compiler_specific.h"
8 #include "base/message_loop.h"
9 
10 namespace net {
11 
URLRequestRedirectJob(URLRequest * request,const GURL & redirect_destination)12 URLRequestRedirectJob::URLRequestRedirectJob(URLRequest* request,
13                                              const GURL& redirect_destination)
14     : URLRequestJob(request),
15       redirect_destination_(redirect_destination),
16       ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {}
17 
Start()18 void URLRequestRedirectJob::Start() {
19   MessageLoop::current()->PostTask(
20       FROM_HERE,
21       method_factory_.NewRunnableMethod(&URLRequestRedirectJob::StartAsync));
22 }
23 
IsRedirectResponse(GURL * location,int * http_status_code)24 bool URLRequestRedirectJob::IsRedirectResponse(GURL* location,
25                                                int* http_status_code) {
26   *location = redirect_destination_;
27   *http_status_code = 302;
28   return true;
29 }
30 
~URLRequestRedirectJob()31 URLRequestRedirectJob::~URLRequestRedirectJob() {}
32 
StartAsync()33 void URLRequestRedirectJob::StartAsync() {
34   NotifyHeadersComplete();
35 }
36 
37 }  // namespace net
38