OLD | NEW |
---|---|
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 #ifndef NET_HTTP_HTTP_AUTH_HANDLER_MOCK_H_ | 5 #ifndef NET_HTTP_HTTP_AUTH_HANDLER_MOCK_H_ |
6 #define NET_HTTP_HTTP_AUTH_HANDLER_MOCK_H_ | 6 #define NET_HTTP_HTTP_AUTH_HANDLER_MOCK_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/scoped_vector.h" | |
11 #include "base/string16.h" | 12 #include "base/string16.h" |
12 #include "base/task.h" | 13 #include "base/task.h" |
13 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
14 #include "net/http/http_auth_handler.h" | 15 #include "net/http/http_auth_handler.h" |
15 #include "net/http/http_auth_handler_factory.h" | 16 #include "net/http/http_auth_handler_factory.h" |
16 | 17 |
17 namespace net { | 18 namespace net { |
18 | 19 |
19 class HostResolver; | 20 class HostResolver; |
20 | 21 |
21 // MockAuthHandler is used in tests to reliably trigger edge cases. | 22 // MockAuthHandler is used in tests to reliably trigger edge cases. |
22 class HttpAuthHandlerMock : public HttpAuthHandler { | 23 class HttpAuthHandlerMock : public HttpAuthHandler { |
23 public: | 24 public: |
24 enum Resolve { | 25 enum Resolve { |
25 RESOLVE_INIT, | 26 RESOLVE_INIT, |
26 RESOLVE_SKIP, | 27 RESOLVE_SKIP, |
27 RESOLVE_SYNC, | 28 RESOLVE_SYNC, |
28 RESOLVE_ASYNC, | 29 RESOLVE_ASYNC, |
29 RESOLVE_TESTED, | 30 RESOLVE_TESTED, |
30 }; | 31 }; |
31 | 32 |
32 // The Factory class simply returns the same handler each time | 33 // The Factory class simply returns the same handler each time |
33 // CreateAuthHandler is called. | 34 // CreateAuthHandler is called. |
cbentzel
2011/08/03 21:27:38
Can you change this comment?
Ryan Hamilton
2011/08/03 22:03:37
Done.
| |
34 class Factory : public HttpAuthHandlerFactory { | 35 class Factory : public HttpAuthHandlerFactory { |
35 public: | 36 public: |
36 Factory(); | 37 Factory(); |
37 virtual ~Factory(); | 38 virtual ~Factory(); |
38 | 39 |
39 void set_mock_handler(HttpAuthHandler* handler, HttpAuth::Target target); | 40 void AddMockHandler(HttpAuthHandler* handler, HttpAuth::Target target); |
40 | 41 |
41 void set_do_init_from_challenge(bool do_init_from_challenge) { | 42 void set_do_init_from_challenge(bool do_init_from_challenge) { |
42 do_init_from_challenge_ = do_init_from_challenge; | 43 do_init_from_challenge_ = do_init_from_challenge; |
43 } | 44 } |
44 | 45 |
45 // HttpAuthHandlerFactory: | 46 // HttpAuthHandlerFactory: |
46 virtual int CreateAuthHandler(HttpAuth::ChallengeTokenizer* challenge, | 47 virtual int CreateAuthHandler(HttpAuth::ChallengeTokenizer* challenge, |
47 HttpAuth::Target target, | 48 HttpAuth::Target target, |
48 const GURL& origin, | 49 const GURL& origin, |
49 CreateReason reason, | 50 CreateReason reason, |
50 int nonce_count, | 51 int nonce_count, |
51 const BoundNetLog& net_log, | 52 const BoundNetLog& net_log, |
52 scoped_ptr<HttpAuthHandler>* handler); | 53 scoped_ptr<HttpAuthHandler>* handler); |
53 | 54 |
54 private: | 55 private: |
55 scoped_ptr<HttpAuthHandler> handlers_[HttpAuth::AUTH_NUM_TARGETS]; | 56 ScopedVector<HttpAuthHandler> handlers_[HttpAuth::AUTH_NUM_TARGETS]; |
56 bool do_init_from_challenge_; | 57 bool do_init_from_challenge_; |
57 }; | 58 }; |
58 | 59 |
59 HttpAuthHandlerMock(); | 60 HttpAuthHandlerMock(); |
60 | 61 |
61 virtual ~HttpAuthHandlerMock(); | 62 virtual ~HttpAuthHandlerMock(); |
62 | 63 |
63 void SetResolveExpectation(Resolve resolve); | 64 void SetResolveExpectation(Resolve resolve); |
64 | 65 |
65 virtual bool NeedsCanonicalName(); | 66 virtual bool NeedsCanonicalName(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
104 int generate_rv_; | 105 int generate_rv_; |
105 std::string* auth_token_; | 106 std::string* auth_token_; |
106 bool first_round_; | 107 bool first_round_; |
107 bool connection_based_; | 108 bool connection_based_; |
108 GURL request_url_; | 109 GURL request_url_; |
109 }; | 110 }; |
110 | 111 |
111 } // namespace net | 112 } // namespace net |
112 | 113 |
113 #endif // NET_HTTP_HTTP_AUTH_HANDLER_MOCK_H_ | 114 #endif // NET_HTTP_HTTP_AUTH_HANDLER_MOCK_H_ |
OLD | NEW |