| 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 #include "net/http/http_auth_handler_mock.h" | 5 #include "net/http/http_auth_handler_mock.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 return allows_explicit_credentials_; | 98 return allows_explicit_credentials_; |
| 99 } | 99 } |
| 100 | 100 |
| 101 bool HttpAuthHandlerMock::Init(HttpAuth::ChallengeTokenizer* challenge) { | 101 bool HttpAuthHandlerMock::Init(HttpAuth::ChallengeTokenizer* challenge) { |
| 102 auth_scheme_ = HttpAuth::AUTH_SCHEME_MOCK; | 102 auth_scheme_ = HttpAuth::AUTH_SCHEME_MOCK; |
| 103 score_ = 1; | 103 score_ = 1; |
| 104 properties_ = connection_based_ ? IS_CONNECTION_BASED : 0; | 104 properties_ = connection_based_ ? IS_CONNECTION_BASED : 0; |
| 105 return true; | 105 return true; |
| 106 } | 106 } |
| 107 | 107 |
| 108 int HttpAuthHandlerMock::GenerateAuthTokenImpl(const string16* username, | 108 int HttpAuthHandlerMock::GenerateAuthTokenImpl( |
| 109 const string16* password, | 109 const AuthCredentials* credentials, |
| 110 const HttpRequestInfo* request, | 110 const HttpRequestInfo* request, |
| 111 OldCompletionCallback* callback, | 111 OldCompletionCallback* callback, |
| 112 std::string* auth_token) { | 112 std::string* auth_token) { |
| 113 first_round_ = false; | 113 first_round_ = false; |
| 114 request_url_ = request->url; | 114 request_url_ = request->url; |
| 115 if (generate_async_) { | 115 if (generate_async_) { |
| 116 EXPECT_TRUE(user_callback_ == NULL); | 116 EXPECT_TRUE(user_callback_ == NULL); |
| 117 EXPECT_TRUE(auth_token_ == NULL); | 117 EXPECT_TRUE(auth_token_ == NULL); |
| 118 user_callback_ = callback; | 118 user_callback_ = callback; |
| 119 auth_token_ = auth_token; | 119 auth_token_ = auth_token; |
| 120 MessageLoop::current()->PostTask( | 120 MessageLoop::current()->PostTask( |
| 121 FROM_HERE, base::Bind( | 121 FROM_HERE, base::Bind( |
| 122 &HttpAuthHandlerMock::OnGenerateAuthToken, | 122 &HttpAuthHandlerMock::OnGenerateAuthToken, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 std::vector<HttpAuthHandler*>& handlers = handlers_[target].get(); | 176 std::vector<HttpAuthHandler*>& handlers = handlers_[target].get(); |
| 177 handlers.erase(handlers.begin()); | 177 handlers.erase(handlers.begin()); |
| 178 if (do_init_from_challenge_ && | 178 if (do_init_from_challenge_ && |
| 179 !tmp_handler->InitFromChallenge(challenge, target, origin, net_log)) | 179 !tmp_handler->InitFromChallenge(challenge, target, origin, net_log)) |
| 180 return ERR_INVALID_RESPONSE; | 180 return ERR_INVALID_RESPONSE; |
| 181 handler->swap(tmp_handler); | 181 handler->swap(tmp_handler); |
| 182 return OK; | 182 return OK; |
| 183 } | 183 } |
| 184 | 184 |
| 185 } // namespace net | 185 } // namespace net |
| OLD | NEW |