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/string16.h" |
11 #include "base/task.h" | 12 #include "base/task.h" |
12 #include "net/http/http_auth_handler.h" | 13 #include "net/http/http_auth_handler.h" |
13 #include "net/http/http_auth_handler_factory.h" | 14 #include "net/http/http_auth_handler_factory.h" |
14 | 15 |
15 namespace net { | 16 namespace net { |
16 | 17 |
17 // MockAuthHandler is used in tests to reliably trigger edge cases. | 18 // MockAuthHandler is used in tests to reliably trigger edge cases. |
18 class HttpAuthHandlerMock : public HttpAuthHandler { | 19 class HttpAuthHandlerMock : public HttpAuthHandler { |
19 public: | 20 public: |
20 enum Resolve { | 21 enum Resolve { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 const BoundNetLog& net_log, | 63 const BoundNetLog& net_log, |
63 scoped_ptr<HttpAuthHandler>* handler); | 64 scoped_ptr<HttpAuthHandler>* handler); |
64 | 65 |
65 private: | 66 private: |
66 scoped_ptr<HttpAuthHandler> handlers_[HttpAuth::AUTH_NUM_TARGETS]; | 67 scoped_ptr<HttpAuthHandler> handlers_[HttpAuth::AUTH_NUM_TARGETS]; |
67 }; | 68 }; |
68 | 69 |
69 protected: | 70 protected: |
70 virtual bool Init(HttpAuth::ChallengeTokenizer* challenge); | 71 virtual bool Init(HttpAuth::ChallengeTokenizer* challenge); |
71 | 72 |
72 virtual int GenerateAuthTokenImpl(const std::wstring* username, | 73 virtual int GenerateAuthTokenImpl(const string16* username, |
73 const std::wstring* password, | 74 const string16* password, |
74 const HttpRequestInfo* request, | 75 const HttpRequestInfo* request, |
75 CompletionCallback* callback, | 76 CompletionCallback* callback, |
76 std::string* auth_token); | 77 std::string* auth_token); |
77 | 78 |
78 private: | 79 private: |
79 void OnResolveCanonicalName(); | 80 void OnResolveCanonicalName(); |
80 | 81 |
81 void OnGenerateAuthToken(); | 82 void OnGenerateAuthToken(); |
82 | 83 |
83 Resolve resolve_; | 84 Resolve resolve_; |
84 CompletionCallback* user_callback_; | 85 CompletionCallback* user_callback_; |
85 ScopedRunnableMethodFactory<HttpAuthHandlerMock> method_factory_; | 86 ScopedRunnableMethodFactory<HttpAuthHandlerMock> method_factory_; |
86 bool generate_async_; | 87 bool generate_async_; |
87 int generate_rv_; | 88 int generate_rv_; |
88 std::string* auth_token_; | 89 std::string* auth_token_; |
89 bool first_round_; | 90 bool first_round_; |
90 bool connection_based_; | 91 bool connection_based_; |
91 }; | 92 }; |
92 | 93 |
93 } // namespace net | 94 } // namespace net |
94 | 95 |
95 #endif // NET_HTTP_HTTP_AUTH_HANDLER_MOCK_H_ | 96 #endif // NET_HTTP_HTTP_AUTH_HANDLER_MOCK_H_ |
OLD | NEW |