Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: net/http/http_auth_handler_mock.cc

Issue 7477055: Change HttpAuthHandlerMock to accept and return more than one (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/http/http_request_info.h" 10 #include "net/http/http_request_info.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 135 }
136 136
137 HttpAuthHandlerMock::Factory::Factory() 137 HttpAuthHandlerMock::Factory::Factory()
138 : do_init_from_challenge_(false) { 138 : do_init_from_challenge_(false) {
139 // TODO(cbentzel): Default do_init_from_challenge_ to true. 139 // TODO(cbentzel): Default do_init_from_challenge_ to true.
140 } 140 }
141 141
142 HttpAuthHandlerMock::Factory::~Factory() { 142 HttpAuthHandlerMock::Factory::~Factory() {
143 } 143 }
144 144
145 void HttpAuthHandlerMock::Factory::set_mock_handler( 145 void HttpAuthHandlerMock::Factory::AddMockHandler(
146 HttpAuthHandler* handler, HttpAuth::Target target) { 146 HttpAuthHandler* handler, HttpAuth::Target target) {
147 EXPECT_TRUE(handlers_[target].get() == NULL); 147 handlers_[target].push_back(handler);
148 handlers_[target].reset(handler);
149 } 148 }
150 149
151 int HttpAuthHandlerMock::Factory::CreateAuthHandler( 150 int HttpAuthHandlerMock::Factory::CreateAuthHandler(
152 HttpAuth::ChallengeTokenizer* challenge, 151 HttpAuth::ChallengeTokenizer* challenge,
153 HttpAuth::Target target, 152 HttpAuth::Target target,
154 const GURL& origin, 153 const GURL& origin,
155 CreateReason reason, 154 CreateReason reason,
156 int nonce_count, 155 int nonce_count,
157 const BoundNetLog& net_log, 156 const BoundNetLog& net_log,
158 scoped_ptr<HttpAuthHandler>* handler) { 157 scoped_ptr<HttpAuthHandler>* handler) {
159 if (!handlers_[target].get()) 158 if (handlers_[target].empty())
160 return ERR_UNEXPECTED; 159 return ERR_UNEXPECTED;
161 scoped_ptr<HttpAuthHandler> tmp_handler(handlers_[target].release()); 160 scoped_ptr<HttpAuthHandler> tmp_handler(handlers_[target][0]);
cbentzel 2011/08/03 21:22:10 I'd add an alias to handlers_[target].get() here t
Ryan Hamilton 2011/08/03 22:03:37 Done.
161 handlers_[target].get().erase(handlers_[target].get().begin());
162 if (do_init_from_challenge_ && 162 if (do_init_from_challenge_ &&
163 !tmp_handler->InitFromChallenge(challenge, target, origin, net_log)) 163 !tmp_handler->InitFromChallenge(challenge, target, origin, net_log))
164 return ERR_INVALID_RESPONSE; 164 return ERR_INVALID_RESPONSE;
165 handler->swap(tmp_handler); 165 handler->swap(tmp_handler);
166 return OK; 166 return OK;
167 } 167 }
168 168
169 } // namespace net 169 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698