Chromium Code Reviews| Index: components/safe_browsing/password_protection/password_protection_request.h |
| diff --git a/components/safe_browsing/password_protection/password_protection_request.h b/components/safe_browsing/password_protection/password_protection_request.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0851729e8663f5aacf448021d93c461b978f7150 |
| --- /dev/null |
| +++ b/components/safe_browsing/password_protection/password_protection_request.h |
| @@ -0,0 +1,93 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_REQUEST_H_ |
| +#define COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_REQUEST_H_ |
| + |
| +#include "base/macros.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "components/safe_browsing/password_protection/password_protection_service.h" |
| +#include "net/url_request/url_fetcher.h" |
| +#include "net/url_request/url_fetcher_delegate.h" |
| +#include "net/url_request/url_request_status.h" |
| + |
| +class GURL; |
| + |
| +namespace safe_browsing { |
| + |
| +class PasswordProtectionRequest : public net::URLFetcherDelegate { |
| + public: |
| + // 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.
|
| + // DO NOT CHANGE THE ORDERING OF THESE VALUES. |
| + enum RequestOutcome { |
| + UNKOWN, |
|
Nathan Parker
2017/03/23 20:45:50
UNKNOWN
Jialiu Lin
2017/03/23 22:43:00
er..... second time... Fixed.
|
| + SUCCEEDED, |
| + CANCELED, |
| + TIMEDOUT, |
| + MATCHED_WHITELIST, |
| + RESPONSE_ALREADY_CACHED, |
| + NO_EXTENDED_REPORTING, |
| + INCOGNITO, |
| + REQUEST_MALFORMED, |
| + FETCH_FAILED, |
| + RESPONSE_MALFORMED, |
| + SERVICE_DESTROYED, |
| + MAX_OUTCOME |
| + }; |
| + |
| + PasswordProtectionRequest(const GURL& main_frame_url, |
| + LoginReputationClientRequest::TriggerType type, |
| + bool is_extended_reporting, |
| + bool is_incognito, |
| + base::WeakPtr<PasswordProtectionService> pps, |
| + int request_timeout_in_ms); |
| + |
| + ~PasswordProtectionRequest() override; |
| + |
| + base::WeakPtr<PasswordProtectionRequest> GetWeakPtr() { |
| + return weakptr_factory_.GetWeakPtr(); |
| + } |
| + |
|
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.
|
| + void Start(); |
| + |
| + void Cancel(bool timed_out); |
| + |
| + // Start a timeout to cancel the request if it takes too long. |
| + void StartTimeout(); |
| + |
| + void Finish(RequestOutcome outcome, |
| + std::unique_ptr<LoginReputationClientResponse> response); |
| + |
| + void CheckWhitelistsOnUIThread(); |
| + |
| + void OnWhitelistCheckDone(bool match_whitelist); |
| + |
| + void CheckCachedVerdicts(); |
| + |
| + 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.
|
| + |
| + bool is_incognito() const { return is_incognito_; } |
| + |
| + // net::URLFetcherDelegate override. |
| + void OnURLFetchComplete(const net::URLFetcher* source) override; |
| + |
| + private: |
| + void SendRequest(); |
| + |
| + GURL main_frame_url_; |
| + LoginReputationClientRequest::TriggerType request_type_; |
| + bool is_extended_reporting_; |
| + bool is_incognito_; |
| + base::TimeTicks request_start_time_; |
| + base::TimeTicks timeout_start_time_; |
| + std::unique_ptr<net::URLFetcher> fetcher_; |
| + base::WeakPtr<PasswordProtectionService> password_protection_service_; |
| + int request_timeout_in_ms_; |
| + base::WeakPtrFactory<PasswordProtectionRequest> weakptr_factory_; |
| + DISALLOW_COPY_AND_ASSIGN(PasswordProtectionRequest); |
| +}; |
| + |
| +} // namespace safe_browsing |
| + |
| +#endif // COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_REQUEST_H_ |