| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_REQUEST
_H_ | 5 #ifndef COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_REQUEST
_H_ |
| 6 #define COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_REQUEST
_H_ | 6 #define COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_REQUEST
_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "components/safe_browsing/password_protection/password_protection_servi
ce.h" | 10 #include "components/safe_browsing/password_protection/password_protection_servi
ce.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 70 |
| 71 private: | 71 private: |
| 72 // If |main_frame_url_| matches whitelist, call Finish() immediately; | 72 // If |main_frame_url_| matches whitelist, call Finish() immediately; |
| 73 // otherwise call CheckCachedVerdicts(). | 73 // otherwise call CheckCachedVerdicts(). |
| 74 void OnWhitelistCheckDone(bool match_whitelist); | 74 void OnWhitelistCheckDone(bool match_whitelist); |
| 75 | 75 |
| 76 // Looks up cached verdicts. If verdict is already cached, call SendRequest(); | 76 // Looks up cached verdicts. If verdict is already cached, call SendRequest(); |
| 77 // otherwise call Finish(). | 77 // otherwise call Finish(). |
| 78 void CheckCachedVerdicts(); | 78 void CheckCachedVerdicts(); |
| 79 | 79 |
| 80 // Fill |request_proto_| with appropriate values. |
| 81 void FillRequestProto(); |
| 82 |
| 80 // Initiates network request to Safe Browsing backend. | 83 // Initiates network request to Safe Browsing backend. |
| 81 void SendRequest(); | 84 void SendRequest(); |
| 82 | 85 |
| 83 // Start a timer to cancel the request if it takes too long. | 86 // Start a timer to cancel the request if it takes too long. |
| 84 void StartTimeout(); | 87 void StartTimeout(); |
| 85 | 88 |
| 86 // |this| will be destroyed after calling this function. | 89 // |this| will be destroyed after calling this function. |
| 87 void Finish(RequestOutcome outcome, | 90 void Finish(RequestOutcome outcome, |
| 88 std::unique_ptr<LoginReputationClientResponse> response); | 91 std::unique_ptr<LoginReputationClientResponse> response); |
| 89 | 92 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 107 // URLFetcher instance for sending request and receiving response. | 110 // URLFetcher instance for sending request and receiving response. |
| 108 std::unique_ptr<net::URLFetcher> fetcher_; | 111 std::unique_ptr<net::URLFetcher> fetcher_; |
| 109 | 112 |
| 110 // The PasswordProtectionService instance owns |this|. | 113 // The PasswordProtectionService instance owns |this|. |
| 111 base::WeakPtr<PasswordProtectionService> password_protection_service_; | 114 base::WeakPtr<PasswordProtectionService> password_protection_service_; |
| 112 | 115 |
| 113 // If we haven't receive response after this period of time, we cancel this | 116 // If we haven't receive response after this period of time, we cancel this |
| 114 // request. | 117 // request. |
| 115 const int request_timeout_in_ms_; | 118 const int request_timeout_in_ms_; |
| 116 | 119 |
| 120 std::unique_ptr<LoginReputationClientRequest> request_proto_; |
| 121 |
| 117 base::WeakPtrFactory<PasswordProtectionRequest> weakptr_factory_; | 122 base::WeakPtrFactory<PasswordProtectionRequest> weakptr_factory_; |
| 118 DISALLOW_COPY_AND_ASSIGN(PasswordProtectionRequest); | 123 DISALLOW_COPY_AND_ASSIGN(PasswordProtectionRequest); |
| 119 }; | 124 }; |
| 120 | 125 |
| 121 } // namespace safe_browsing | 126 } // namespace safe_browsing |
| 122 | 127 |
| 123 #endif // COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_REQU
EST_H_ | 128 #endif // COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_REQU
EST_H_ |
| OLD | NEW |