OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chromeos/login/auth/mock_url_fetchers.h" | 5 #include "chromeos/login/auth/mock_url_fetchers.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
13 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
| 14 #include "net/base/net_errors.h" |
14 #include "net/http/http_status_code.h" | 15 #include "net/http/http_status_code.h" |
15 #include "net/url_request/url_fetcher.h" | 16 #include "net/url_request/url_fetcher.h" |
16 #include "net/url_request/url_fetcher_delegate.h" | 17 #include "net/url_request/url_fetcher_delegate.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 | 19 |
19 namespace chromeos { | 20 namespace chromeos { |
20 | 21 |
21 ExpectCanceledFetcher::ExpectCanceledFetcher( | 22 ExpectCanceledFetcher::ExpectCanceledFetcher( |
22 bool success, | 23 bool success, |
23 const GURL& url, | 24 const GURL& url, |
(...skipping 19 matching lines...) Expand all Loading... |
43 } | 44 } |
44 | 45 |
45 GotCanceledFetcher::GotCanceledFetcher( | 46 GotCanceledFetcher::GotCanceledFetcher( |
46 bool success, | 47 bool success, |
47 const GURL& url, | 48 const GURL& url, |
48 const std::string& results, | 49 const std::string& results, |
49 net::URLFetcher::RequestType request_type, | 50 net::URLFetcher::RequestType request_type, |
50 net::URLFetcherDelegate* d) | 51 net::URLFetcherDelegate* d) |
51 : net::TestURLFetcher(0, url, d) { | 52 : net::TestURLFetcher(0, url, d) { |
52 set_url(url); | 53 set_url(url); |
53 set_status(net::URLRequestStatus(net::URLRequestStatus::CANCELED, 0)); | 54 set_status(net::URLRequestStatus::FromError(net::ERR_ABORTED)); |
54 set_response_code(net::HTTP_FORBIDDEN); | 55 set_response_code(net::HTTP_FORBIDDEN); |
55 } | 56 } |
56 | 57 |
57 GotCanceledFetcher::~GotCanceledFetcher() { | 58 GotCanceledFetcher::~GotCanceledFetcher() { |
58 } | 59 } |
59 | 60 |
60 void GotCanceledFetcher::Start() { | 61 void GotCanceledFetcher::Start() { |
61 delegate()->OnURLFetchComplete(this); | 62 delegate()->OnURLFetchComplete(this); |
62 } | 63 } |
63 | 64 |
(...skipping 15 matching lines...) Expand all Loading... |
79 delegate()->OnURLFetchComplete(this); | 80 delegate()->OnURLFetchComplete(this); |
80 } | 81 } |
81 | 82 |
82 FailFetcher::FailFetcher(bool success, | 83 FailFetcher::FailFetcher(bool success, |
83 const GURL& url, | 84 const GURL& url, |
84 const std::string& results, | 85 const std::string& results, |
85 net::URLFetcher::RequestType request_type, | 86 net::URLFetcher::RequestType request_type, |
86 net::URLFetcherDelegate* d) | 87 net::URLFetcherDelegate* d) |
87 : net::TestURLFetcher(0, url, d) { | 88 : net::TestURLFetcher(0, url, d) { |
88 set_url(url); | 89 set_url(url); |
89 set_status(net::URLRequestStatus(net::URLRequestStatus::FAILED, ECONNRESET)); | 90 set_status(net::URLRequestStatus::FromError(net::ERR_CONNECTION_RESET)); |
90 set_response_code(net::HTTP_OK); | 91 set_response_code(net::HTTP_OK); |
91 } | 92 } |
92 | 93 |
93 FailFetcher::~FailFetcher() { | 94 FailFetcher::~FailFetcher() { |
94 } | 95 } |
95 | 96 |
96 void FailFetcher::Start() { | 97 void FailFetcher::Start() { |
97 delegate()->OnURLFetchComplete(this); | 98 delegate()->OnURLFetchComplete(this); |
98 } | 99 } |
99 | 100 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 VLOG(1) << upload_data(); | 167 VLOG(1) << upload_data(); |
167 if (upload_data().find("HOSTED") == std::string::npos) { | 168 if (upload_data().find("HOSTED") == std::string::npos) { |
168 VLOG(1) << "HostedFetcher failing request"; | 169 VLOG(1) << "HostedFetcher failing request"; |
169 set_response_code(net::HTTP_FORBIDDEN); | 170 set_response_code(net::HTTP_FORBIDDEN); |
170 SetResponseString("Error=BadAuthentication"); | 171 SetResponseString("Error=BadAuthentication"); |
171 } | 172 } |
172 delegate()->OnURLFetchComplete(this); | 173 delegate()->OnURLFetchComplete(this); |
173 } | 174 } |
174 | 175 |
175 } // namespace chromeos | 176 } // namespace chromeos |
OLD | NEW |