Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_REQUEST _H_ | |
| 6 #define COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_REQUEST _H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/memory/ref_counted.h" | |
| 10 #include "components/safe_browsing/password_protection/password_protection_servi ce.h" | |
| 11 #include "net/url_request/url_fetcher.h" | |
| 12 #include "net/url_request/url_fetcher_delegate.h" | |
| 13 #include "net/url_request/url_request_status.h" | |
| 14 | |
| 15 class GURL; | |
| 16 | |
| 17 namespace safe_browsing { | |
| 18 | |
| 19 class PasswordProtectionRequest : public net::URLFetcherDelegate { | |
| 20 public: | |
| 21 // The outcome of the request. These values are used for UMA. | |
|
Nathan Parker
2017/03/23 20:45:50
I'd attach values to each of these, so you can com
Jialiu Lin
2017/03/23 22:43:01
Agree. Done.
| |
| 22 // DO NOT CHANGE THE ORDERING OF THESE VALUES. | |
| 23 enum RequestOutcome { | |
| 24 UNKOWN, | |
|
Nathan Parker
2017/03/23 20:45:50
UNKNOWN
Jialiu Lin
2017/03/23 22:43:00
er..... second time... Fixed.
| |
| 25 SUCCEEDED, | |
| 26 CANCELED, | |
| 27 TIMEDOUT, | |
| 28 MATCHED_WHITELIST, | |
| 29 RESPONSE_ALREADY_CACHED, | |
| 30 NO_EXTENDED_REPORTING, | |
| 31 INCOGNITO, | |
| 32 REQUEST_MALFORMED, | |
| 33 FETCH_FAILED, | |
| 34 RESPONSE_MALFORMED, | |
| 35 SERVICE_DESTROYED, | |
| 36 MAX_OUTCOME | |
| 37 }; | |
| 38 | |
| 39 PasswordProtectionRequest(const GURL& main_frame_url, | |
| 40 LoginReputationClientRequest::TriggerType type, | |
| 41 bool is_extended_reporting, | |
| 42 bool is_incognito, | |
| 43 base::WeakPtr<PasswordProtectionService> pps, | |
| 44 int request_timeout_in_ms); | |
| 45 | |
| 46 ~PasswordProtectionRequest() override; | |
| 47 | |
| 48 base::WeakPtr<PasswordProtectionRequest> GetWeakPtr() { | |
| 49 return weakptr_factory_.GetWeakPtr(); | |
| 50 } | |
| 51 | |
|
Nathan Parker
2017/03/23 20:45:50
Some comments on these functions would be useful h
Jialiu Lin
2017/03/23 22:43:00
Done.
| |
| 52 void Start(); | |
| 53 | |
| 54 void Cancel(bool timed_out); | |
| 55 | |
| 56 // Start a timeout to cancel the request if it takes too long. | |
| 57 void StartTimeout(); | |
| 58 | |
| 59 void Finish(RequestOutcome outcome, | |
| 60 std::unique_ptr<LoginReputationClientResponse> response); | |
| 61 | |
| 62 void CheckWhitelistsOnUIThread(); | |
| 63 | |
| 64 void OnWhitelistCheckDone(bool match_whitelist); | |
| 65 | |
| 66 void CheckCachedVerdicts(); | |
| 67 | |
| 68 GURL main_frame_url() const { return main_frame_url_; } | |
|
Nathan Parker
2017/03/23 20:45:50
Could any of these be private?
Jialiu Lin
2017/03/23 22:43:00
Yes, moved a bunch of them into private.
| |
| 69 | |
| 70 bool is_incognito() const { return is_incognito_; } | |
| 71 | |
| 72 // net::URLFetcherDelegate override. | |
| 73 void OnURLFetchComplete(const net::URLFetcher* source) override; | |
| 74 | |
| 75 private: | |
| 76 void SendRequest(); | |
| 77 | |
| 78 GURL main_frame_url_; | |
| 79 LoginReputationClientRequest::TriggerType request_type_; | |
| 80 bool is_extended_reporting_; | |
| 81 bool is_incognito_; | |
| 82 base::TimeTicks request_start_time_; | |
| 83 base::TimeTicks timeout_start_time_; | |
| 84 std::unique_ptr<net::URLFetcher> fetcher_; | |
| 85 base::WeakPtr<PasswordProtectionService> password_protection_service_; | |
| 86 int request_timeout_in_ms_; | |
| 87 base::WeakPtrFactory<PasswordProtectionRequest> weakptr_factory_; | |
| 88 DISALLOW_COPY_AND_ASSIGN(PasswordProtectionRequest); | |
| 89 }; | |
| 90 | |
| 91 } // namespace safe_browsing | |
| 92 | |
| 93 #endif // COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_REQU EST_H_ | |
| OLD | NEW |