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

Side by Side Diff: components/safe_browsing_db/v4_update_protocol_manager.cc

Issue 2467673002: Update histogram names to follow the usual PVer4 format: SafeBrowsing.V4* (Closed)
Patch Set: nparker@ review Created 4 years, 1 month 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "components/safe_browsing_db/v4_update_protocol_manager.h" 5 #include "components/safe_browsing_db/v4_update_protocol_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/base64url.h" 9 #include "base/base64url.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // No state set in the response for one or more lists. 43 // No state set in the response for one or more lists.
44 NO_STATE_ERROR = 4, 44 NO_STATE_ERROR = 4,
45 45
46 // Memory space for histograms is determined by the max. ALWAYS 46 // Memory space for histograms is determined by the max. ALWAYS
47 // ADD NEW VALUES BEFORE THIS ONE. 47 // ADD NEW VALUES BEFORE THIS ONE.
48 PARSE_RESULT_TYPE_MAX = 5 48 PARSE_RESULT_TYPE_MAX = 5
49 }; 49 };
50 50
51 // Record parsing errors of an update result. 51 // Record parsing errors of an update result.
52 void RecordParseUpdateResult(ParseResultType result_type) { 52 void RecordParseUpdateResult(ParseResultType result_type) {
53 UMA_HISTOGRAM_ENUMERATION("SafeBrowsing.ParseV4UpdateResult", result_type, 53 UMA_HISTOGRAM_ENUMERATION("SafeBrowsing.V4Update.Parse.Result", result_type,
54 PARSE_RESULT_TYPE_MAX); 54 PARSE_RESULT_TYPE_MAX);
55 } 55 }
56 56
57 void RecordUpdateResult(safe_browsing::V4OperationResult result) { 57 void RecordUpdateResult(safe_browsing::V4OperationResult result) {
58 UMA_HISTOGRAM_ENUMERATION( 58 UMA_HISTOGRAM_ENUMERATION(
59 "SafeBrowsing.V4UpdateResult", result, 59 "SafeBrowsing.V4Update.Result", result,
60 safe_browsing::V4OperationResult::OPERATION_RESULT_MAX); 60 safe_browsing::V4OperationResult::OPERATION_RESULT_MAX);
61 } 61 }
62 62
63 } // namespace 63 } // namespace
64 64
65 namespace safe_browsing { 65 namespace safe_browsing {
66 66
67 // Minimum time, in seconds, from start up before we must issue an update query. 67 // Minimum time, in seconds, from start up before we must issue an update query.
68 static const int kV4TimerStartIntervalSecMin = 60; 68 static const int kV4TimerStartIntervalSecMin = 60;
69 69
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 // net::URLFetcherDelegate implementation ---------------------------------- 301 // net::URLFetcherDelegate implementation ----------------------------------
302 302
303 // SafeBrowsing request responses are handled here. 303 // SafeBrowsing request responses are handled here.
304 void V4UpdateProtocolManager::OnURLFetchComplete( 304 void V4UpdateProtocolManager::OnURLFetchComplete(
305 const net::URLFetcher* source) { 305 const net::URLFetcher* source) {
306 DCHECK(CalledOnValidThread()); 306 DCHECK(CalledOnValidThread());
307 307
308 int response_code = source->GetResponseCode(); 308 int response_code = source->GetResponseCode();
309 net::URLRequestStatus status = source->GetStatus(); 309 net::URLRequestStatus status = source->GetStatus();
310 V4ProtocolManagerUtil::RecordHttpResponseOrErrorCode( 310 V4ProtocolManagerUtil::RecordHttpResponseOrErrorCode(
311 "SafeBrowsing.V4UpdateHttpResponseOrErrorCode", status, response_code); 311 "SafeBrowsing.V4Update.Network.Result", status, response_code);
312 312
313 last_response_time_ = Time::Now(); 313 last_response_time_ = Time::Now();
314 314
315 std::unique_ptr<ParsedServerResponse> parsed_server_response( 315 std::unique_ptr<ParsedServerResponse> parsed_server_response(
316 new ParsedServerResponse); 316 new ParsedServerResponse);
317 if (status.is_success() && response_code == net::HTTP_OK) { 317 if (status.is_success() && response_code == net::HTTP_OK) {
318 RecordUpdateResult(V4OperationResult::STATUS_200); 318 RecordUpdateResult(V4OperationResult::STATUS_200);
319 ResetUpdateErrors(); 319 ResetUpdateErrors();
320 std::string data; 320 std::string data;
321 source->GetResponseAsString(&data); 321 source->GetResponseAsString(&data);
322 if (!ParseUpdateResponse(data, parsed_server_response.get())) { 322 if (!ParseUpdateResponse(data, parsed_server_response.get())) {
323 parsed_server_response->clear(); 323 parsed_server_response->clear();
324 RecordUpdateResult(V4OperationResult::PARSE_ERROR); 324 RecordUpdateResult(V4OperationResult::PARSE_ERROR);
325 } 325 }
326 request_.reset(); 326 request_.reset();
327 327
328 UMA_HISTOGRAM_COUNTS("SafeBrowsing.V4UpdateResponseSizeKB", 328 UMA_HISTOGRAM_COUNTS("SafeBrowsing.V4Update.ResponseSizeKB",
329 data.size() / 1024); 329 data.size() / 1024);
330 330
331 // The caller should update its state now, based on parsed_server_response. 331 // The caller should update its state now, based on parsed_server_response.
332 // The callback must call ScheduleNextUpdate() at the end to resume 332 // The callback must call ScheduleNextUpdate() at the end to resume
333 // downloading updates. 333 // downloading updates.
334 update_callback_.Run(std::move(parsed_server_response)); 334 update_callback_.Run(std::move(parsed_server_response));
335 } else { 335 } else {
336 DVLOG(1) << "SafeBrowsing GetEncodedUpdates request for: " 336 DVLOG(1) << "SafeBrowsing GetEncodedUpdates request for: "
337 << source->GetURL() << " failed with error: " << status.error() 337 << source->GetURL() << " failed with error: " << status.error()
338 << " and response code: " << response_code; 338 << " and response code: " << response_code;
(...skipping 13 matching lines...) Expand all
352 352
353 void V4UpdateProtocolManager::GetUpdateUrlAndHeaders( 353 void V4UpdateProtocolManager::GetUpdateUrlAndHeaders(
354 const std::string& req_base64, 354 const std::string& req_base64,
355 GURL* gurl, 355 GURL* gurl,
356 net::HttpRequestHeaders* headers) const { 356 net::HttpRequestHeaders* headers) const {
357 V4ProtocolManagerUtil::GetRequestUrlAndHeaders( 357 V4ProtocolManagerUtil::GetRequestUrlAndHeaders(
358 req_base64, "threatListUpdates:fetch", config_, gurl, headers); 358 req_base64, "threatListUpdates:fetch", config_, gurl, headers);
359 } 359 }
360 360
361 } // namespace safe_browsing 361 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « components/safe_browsing_db/v4_get_hash_protocol_manager.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698