Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: components/safe_browsing/password_protection/password_protection_request.h

Issue 2869253002: Add UMA metrics to phishguard pings (Closed)
Patch Set: resolve comments on histograms.xml Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/task/cancelable_task_tracker.h" 10 #include "base/task/cancelable_task_tracker.h"
(...skipping 22 matching lines...) Expand all
33 // (5) | UI | If verdict cached, quit request; else prepare request proto. 33 // (5) | UI | If verdict cached, quit request; else prepare request proto.
34 // (6) | UI | Start a timeout task, and send network request. 34 // (6) | UI | Start a timeout task, and send network request.
35 // (7) | UI | On receiving response, handle response and finish. 35 // (7) | UI | On receiving response, handle response and finish.
36 // | | On request timeout, cancel request. 36 // | | On request timeout, cancel request.
37 // | | On deletion of |password_protection_service_|, cancel request. 37 // | | On deletion of |password_protection_service_|, cancel request.
38 class PasswordProtectionRequest : public base::RefCountedThreadSafe< 38 class PasswordProtectionRequest : public base::RefCountedThreadSafe<
39 PasswordProtectionRequest, 39 PasswordProtectionRequest,
40 content::BrowserThread::DeleteOnUIThread>, 40 content::BrowserThread::DeleteOnUIThread>,
41 public net::URLFetcherDelegate { 41 public net::URLFetcherDelegate {
42 public: 42 public:
43 // The outcome of the request. These values are used for UMA.
44 // DO NOT CHANGE THE ORDERING OF THESE VALUES.
45 enum RequestOutcome {
46 UNKNOWN = 0,
47 SUCCEEDED = 1,
48 CANCELED = 2,
49 TIMEDOUT = 3,
50 MATCHED_WHITELIST = 4,
51 RESPONSE_ALREADY_CACHED = 5,
52 DEPRECATED_NO_EXTENDED_REPORTING = 6,
53 DEPRECATED_INCOGNITO = 7,
54 REQUEST_MALFORMED = 8,
55 FETCH_FAILED = 9,
56 RESPONSE_MALFORMED = 10,
57 SERVICE_DESTROYED = 11,
58 MAX_OUTCOME
59 };
60
61 PasswordProtectionRequest(const GURL& main_frame_url, 43 PasswordProtectionRequest(const GURL& main_frame_url,
62 const GURL& password_form_action, 44 const GURL& password_form_action,
63 const GURL& password_form_frame_url, 45 const GURL& password_form_frame_url,
64 LoginReputationClientRequest::TriggerType type, 46 LoginReputationClientRequest::TriggerType type,
65 PasswordProtectionService* pps, 47 PasswordProtectionService* pps,
66 int request_timeout_in_ms); 48 int request_timeout_in_ms);
67 49
68 base::WeakPtr<PasswordProtectionRequest> GetWeakPtr() { 50 base::WeakPtr<PasswordProtectionRequest> GetWeakPtr() {
69 return weakptr_factory_.GetWeakPtr(); 51 return weakptr_factory_.GetWeakPtr();
70 } 52 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // Fill |request_proto_| with appropriate values. 90 // Fill |request_proto_| with appropriate values.
109 void FillRequestProto(); 91 void FillRequestProto();
110 92
111 // Initiates network request to Safe Browsing backend. 93 // Initiates network request to Safe Browsing backend.
112 void SendRequest(); 94 void SendRequest();
113 95
114 // Start a timer to cancel the request if it takes too long. 96 // Start a timer to cancel the request if it takes too long.
115 void StartTimeout(); 97 void StartTimeout();
116 98
117 // |this| will be destroyed after calling this function. 99 // |this| will be destroyed after calling this function.
118 void Finish(RequestOutcome outcome, 100 void Finish(PasswordProtectionService::RequestOutcome outcome,
119 std::unique_ptr<LoginReputationClientResponse> response); 101 std::unique_ptr<LoginReputationClientResponse> response);
120 102
121 // Main frame URL of the login form. 103 // Main frame URL of the login form.
122 const GURL main_frame_url_; 104 const GURL main_frame_url_;
123 105
124 // The action URL of the password form. 106 // The action URL of the password form.
125 const GURL password_form_action_; 107 const GURL password_form_action_;
126 108
127 // Frame url of the detected password form. 109 // Frame url of the detected password form.
128 const GURL password_form_frame_url_; 110 const GURL password_form_frame_url_;
(...skipping 24 matching lines...) Expand all
153 // Needed for canceling tasks posted to different threads. 135 // Needed for canceling tasks posted to different threads.
154 base::CancelableTaskTracker tracker_; 136 base::CancelableTaskTracker tracker_;
155 137
156 base::WeakPtrFactory<PasswordProtectionRequest> weakptr_factory_; 138 base::WeakPtrFactory<PasswordProtectionRequest> weakptr_factory_;
157 DISALLOW_COPY_AND_ASSIGN(PasswordProtectionRequest); 139 DISALLOW_COPY_AND_ASSIGN(PasswordProtectionRequest);
158 }; 140 };
159 141
160 } // namespace safe_browsing 142 } // namespace safe_browsing
161 143
162 #endif // COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_REQU EST_H_ 144 #endif // COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_REQU EST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698