OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_AUTH_REQUES
T_HANDLER_H_ | 5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_AUTH_REQUES
T_HANDLER_H_ |
6 #define COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_AUTH_REQUES
T_HANDLER_H_ | 6 #define COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_AUTH_REQUES
T_HANDLER_H_ |
7 | 7 |
8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
11 | 11 |
12 namespace net { | 12 namespace net { |
13 class AuthChallengeInfo; | 13 class AuthChallengeInfo; |
14 } | 14 } |
15 | 15 |
16 namespace data_reduction_proxy { | 16 namespace data_reduction_proxy { |
17 | 17 |
| 18 class DataReductionProxySettings; |
| 19 |
18 class DataReductionProxyAuthRequestHandler { | 20 class DataReductionProxyAuthRequestHandler { |
19 public: | 21 public: |
20 enum TryHandleResult { | 22 enum TryHandleResult { |
21 TRY_HANDLE_RESULT_IGNORE, | 23 TRY_HANDLE_RESULT_IGNORE, |
22 TRY_HANDLE_RESULT_PROCEED, | 24 TRY_HANDLE_RESULT_PROCEED, |
23 TRY_HANDLE_RESULT_CANCEL | 25 TRY_HANDLE_RESULT_CANCEL |
24 }; | 26 }; |
25 | 27 |
26 DataReductionProxyAuthRequestHandler(); | 28 // Constructs an authentication request handler and takes a pointer to a |
| 29 // |settings| object, which must outlive the handler. |
| 30 explicit DataReductionProxyAuthRequestHandler( |
| 31 DataReductionProxySettings* settings); |
27 virtual ~DataReductionProxyAuthRequestHandler(); | 32 virtual ~DataReductionProxyAuthRequestHandler(); |
28 | 33 |
29 // Returns |PROCEED| if the authentication challenge provided is one that the | 34 // Returns |PROCEED| if the authentication challenge provided is one that the |
30 // data reduction proxy should handle and |IGNORE| if not. Returns |CANCEL| if | 35 // data reduction proxy should handle and |IGNORE| if not. Returns |CANCEL| if |
31 // there are a string of |MAX_BACK_TO_BACK_FAILURES| successive retries. | 36 // there are a string of |MAX_BACK_TO_BACK_FAILURES| successive retries. |
32 TryHandleResult TryHandleAuthentication(net::AuthChallengeInfo* auth_info, | 37 TryHandleResult TryHandleAuthentication(net::AuthChallengeInfo* auth_info, |
33 base::string16* user, | 38 base::string16* user, |
34 base::string16* password); | 39 base::string16* password); |
35 | 40 |
36 protected: | 41 protected: |
(...skipping 21 matching lines...) Expand all Loading... |
58 // The number of back to back data reduction proxy authentication failures | 63 // The number of back to back data reduction proxy authentication failures |
59 // that occurred with no more than |MIN_AUTH_REQUEST_INTERVAL_MS| between each | 64 // that occurred with no more than |MIN_AUTH_REQUEST_INTERVAL_MS| between each |
60 // adjacent pair of them. | 65 // adjacent pair of them. |
61 static int back_to_back_failure_count_; | 66 static int back_to_back_failure_count_; |
62 | 67 |
63 // System timestamp of the last data reduction proxy auth token invalidation. | 68 // System timestamp of the last data reduction proxy auth token invalidation. |
64 // This is used to expire old tokens on back-to-back failures, and distinguish | 69 // This is used to expire old tokens on back-to-back failures, and distinguish |
65 // invalidation from repeat failures due to the client not being authorized. | 70 // invalidation from repeat failures due to the client not being authorized. |
66 static int64 auth_token_invalidation_timestamp_; | 71 static int64 auth_token_invalidation_timestamp_; |
67 | 72 |
| 73 // Settings object for the data reduction proxy. Must outlive the handler. |
| 74 DataReductionProxySettings* settings_; |
| 75 |
68 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyAuthRequestHandler); | 76 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyAuthRequestHandler); |
69 }; | 77 }; |
70 | 78 |
71 } // namespace data_reduction_proxy | 79 } // namespace data_reduction_proxy |
72 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_AUTH_REQ
UEST_HANDLER_H_ | 80 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_AUTH_REQ
UEST_HANDLER_H_ |
OLD | NEW |