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

Side by Side Diff: net/cookies/parsed_cookie.cc

Issue 2273633004: Add Cookie.CookieLineCookieValueValidity histogram (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Portions of this code based on Mozilla: 5 // Portions of this code based on Mozilla:
6 // (netwerk/cookie/src/nsCookieService.cpp) 6 // (netwerk/cookie/src/nsCookieService.cpp)
7 /* ***** BEGIN LICENSE BLOCK ***** 7 /* ***** BEGIN LICENSE BLOCK *****
8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
9 * 9 *
10 * The contents of this file are subject to the Mozilla Public License Version 10 * The contents of this file are subject to the Mozilla Public License Version
(...skipping 27 matching lines...) Expand all
38 * decision by deleting the provisions above and replace them with the notice 38 * decision by deleting the provisions above and replace them with the notice
39 * and other provisions required by the GPL or the LGPL. If you do not delete 39 * and other provisions required by the GPL or the LGPL. If you do not delete
40 * the provisions above, a recipient may use your version of this file under 40 * the provisions above, a recipient may use your version of this file under
41 * the terms of any one of the MPL, the GPL or the LGPL. 41 * the terms of any one of the MPL, the GPL or the LGPL.
42 * 42 *
43 * ***** END LICENSE BLOCK ***** */ 43 * ***** END LICENSE BLOCK ***** */
44 44
45 #include "net/cookies/parsed_cookie.h" 45 #include "net/cookies/parsed_cookie.h"
46 46
47 #include "base/logging.h" 47 #include "base/logging.h"
48 #include "base/metrics/histogram.h"
Ilya Sherman 2016/08/25 20:04:49 nit: histogram_macros
Adam Rice 2016/08/26 01:36:29 Fixed, thanks.
48 #include "base/strings/string_util.h" 49 #include "base/strings/string_util.h"
49 50
50 namespace { 51 namespace {
51 52
52 const char kPathTokenName[] = "path"; 53 const char kPathTokenName[] = "path";
53 const char kDomainTokenName[] = "domain"; 54 const char kDomainTokenName[] = "domain";
54 const char kExpiresTokenName[] = "expires"; 55 const char kExpiresTokenName[] = "expires";
55 const char kMaxAgeTokenName[] = "max-age"; 56 const char kMaxAgeTokenName[] = "max-age";
56 const char kSecureTokenName[] = "secure"; 57 const char kSecureTokenName[] = "secure";
57 const char kHttpOnlyTokenName[] = "httponly"; 58 const char kHttpOnlyTokenName[] = "httponly";
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 if (pair_num != 0) 419 if (pair_num != 0)
419 pair.first = base::ToLowerASCII(pair.first); 420 pair.first = base::ToLowerASCII(pair.first);
420 // Ignore Set-Cookie directives contaning control characters. See 421 // Ignore Set-Cookie directives contaning control characters. See
421 // http://crbug.com/238041. 422 // http://crbug.com/238041.
422 if (!IsValidCookieAttributeValue(pair.first) || 423 if (!IsValidCookieAttributeValue(pair.first) ||
423 !IsValidCookieAttributeValue(pair.second)) { 424 !IsValidCookieAttributeValue(pair.second)) {
424 pairs_.clear(); 425 pairs_.clear();
425 break; 426 break;
426 } 427 }
427 428
429 if (pair_num == 0) {
430 UMA_HISTOGRAM_BOOLEAN("Cookie.CookieLineCookieValueValidity",
431 IsValidCookieValue(pair.second));
432 }
433
428 pairs_.push_back(pair); 434 pairs_.push_back(pair);
429 435
430 // We've processed a token/value pair, we're either at the end of 436 // We've processed a token/value pair, we're either at the end of
431 // the string or a ValueSeparator like ';', which we want to skip. 437 // the string or a ValueSeparator like ';', which we want to skip.
432 if (it != end) 438 if (it != end)
433 ++it; 439 ++it;
434 } 440 }
435 } 441 }
436 442
437 void ParsedCookie::SetupAttributes() { 443 void ParsedCookie::SetupAttributes() {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 --*indexes[i]; 518 --*indexes[i];
513 } 519 }
514 pairs_.erase(pairs_.begin() + index); 520 pairs_.erase(pairs_.begin() + index);
515 } 521 }
516 522
517 bool ParsedCookie::IsSameSiteAttributeValid() const { 523 bool ParsedCookie::IsSameSiteAttributeValid() const {
518 return same_site_index_ == 0 || SameSite() != CookieSameSite::DEFAULT_MODE; 524 return same_site_index_ == 0 || SameSite() != CookieSameSite::DEFAULT_MODE;
519 } 525 }
520 526
521 } // namespace 527 } // namespace
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698