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/location.h" | 8 #include "base/location.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 HttpAuthHandlerMock::Factory::Factory() | 154 HttpAuthHandlerMock::Factory::Factory() |
155 : do_init_from_challenge_(false) { | 155 : do_init_from_challenge_(false) { |
156 // TODO(cbentzel): Default do_init_from_challenge_ to true. | 156 // TODO(cbentzel): Default do_init_from_challenge_ to true. |
157 } | 157 } |
158 | 158 |
159 HttpAuthHandlerMock::Factory::~Factory() { | 159 HttpAuthHandlerMock::Factory::~Factory() { |
160 } | 160 } |
161 | 161 |
162 void HttpAuthHandlerMock::Factory::AddMockHandler( | 162 void HttpAuthHandlerMock::Factory::AddMockHandler( |
163 HttpAuthHandler* handler, HttpAuth::Target target) { | 163 HttpAuthHandler* handler, HttpAuth::Target target) { |
164 handlers_[target].push_back(handler); | 164 handlers_[target].push_back(make_scoped_ptr(handler)); |
165 } | 165 } |
166 | 166 |
167 int HttpAuthHandlerMock::Factory::CreateAuthHandler( | 167 int HttpAuthHandlerMock::Factory::CreateAuthHandler( |
168 HttpAuthChallengeTokenizer* challenge, | 168 HttpAuthChallengeTokenizer* challenge, |
169 HttpAuth::Target target, | 169 HttpAuth::Target target, |
170 const GURL& origin, | 170 const GURL& origin, |
171 CreateReason reason, | 171 CreateReason reason, |
172 int nonce_count, | 172 int nonce_count, |
173 const BoundNetLog& net_log, | 173 const BoundNetLog& net_log, |
174 scoped_ptr<HttpAuthHandler>* handler) { | 174 scoped_ptr<HttpAuthHandler>* handler) { |
175 if (handlers_[target].empty()) | 175 if (handlers_[target].empty()) |
176 return ERR_UNEXPECTED; | 176 return ERR_UNEXPECTED; |
177 scoped_ptr<HttpAuthHandler> tmp_handler(handlers_[target][0]); | 177 scoped_ptr<HttpAuthHandler> tmp_handler = std::move(handlers_[target][0]); |
178 std::vector<HttpAuthHandler*>& handlers = handlers_[target].get(); | 178 std::vector<scoped_ptr<HttpAuthHandler>>& handlers = handlers_[target]; |
179 handlers.erase(handlers.begin()); | 179 handlers.erase(handlers.begin()); |
180 if (do_init_from_challenge_ && | 180 if (do_init_from_challenge_ && |
181 !tmp_handler->InitFromChallenge(challenge, target, origin, net_log)) | 181 !tmp_handler->InitFromChallenge(challenge, target, origin, net_log)) |
182 return ERR_INVALID_RESPONSE; | 182 return ERR_INVALID_RESPONSE; |
183 handler->swap(tmp_handler); | 183 handler->swap(tmp_handler); |
184 return OK; | 184 return OK; |
185 } | 185 } |
186 | 186 |
187 } // namespace net | 187 } // namespace net |
OLD | NEW |