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

Side by Side Diff: components/domain_reliability/config.cc

Issue 2613223002: Remove ScopedVector from base::JSONValueConverter (Closed)
Patch Set: Created 3 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 // Make sure stdint.h includes SIZE_MAX. (See C89, p259, footnote 221.) 5 // Make sure stdint.h includes SIZE_MAX. (See C89, p259, footnote 221.)
6 #ifndef __STDC_LIMIT_MACROS 6 #ifndef __STDC_LIMIT_MACROS
7 #define __STDC_LIMIT_MACROS 1 7 #define __STDC_LIMIT_MACROS 1
8 #endif 8 #endif
9 9
10 #include "components/domain_reliability/config.h" 10 #include "components/domain_reliability/config.h"
11 11
12 #include <stdint.h> 12 #include <stdint.h>
13 #include <utility> 13 #include <utility>
14 14
15 #include "base/json/json_reader.h" 15 #include "base/json/json_reader.h"
16 #include "base/json/json_value_converter.h"
17 #include "base/profiler/scoped_tracker.h" 16 #include "base/profiler/scoped_tracker.h"
18 #include "base/strings/pattern.h" 17 #include "base/strings/pattern.h"
19 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
20 19
21 namespace { 20 namespace {
22 21
23 bool ConvertURL(const base::Value* value, GURL* url) { 22 bool ConvertURL(const base::Value* value, GURL* url) {
24 std::string url_string; 23 std::string url_string;
25 if (!value->GetAsString(&url_string)) 24 if (!value->GetAsString(&url_string))
26 return false; 25 return false;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 return std::unique_ptr<const DomainReliabilityConfig>(); 62 return std::unique_ptr<const DomainReliabilityConfig>();
64 } 63 }
65 64
66 bool DomainReliabilityConfig::IsValid() const { 65 bool DomainReliabilityConfig::IsValid() const {
67 if (!origin.is_valid() || collectors.empty() || 66 if (!origin.is_valid() || collectors.empty() ||
68 !IsValidSampleRate(success_sample_rate) || 67 !IsValidSampleRate(success_sample_rate) ||
69 !IsValidSampleRate(failure_sample_rate)) { 68 !IsValidSampleRate(failure_sample_rate)) {
70 return false; 69 return false;
71 } 70 }
72 71
73 for (const auto* url : collectors) { 72 for (const auto& url : collectors) {
74 if (!url->is_valid()) 73 if (!url->is_valid())
75 return false; 74 return false;
76 } 75 }
77 76
78 return true; 77 return true;
79 } 78 }
80 79
81 bool DomainReliabilityConfig::Equals(const DomainReliabilityConfig& other) 80 bool DomainReliabilityConfig::Equals(const DomainReliabilityConfig& other)
82 const { 81 const {
83 if (include_subdomains != other.include_subdomains || 82 if (include_subdomains != other.include_subdomains ||
(...skipping 30 matching lines...) Expand all
114 "collectors", &DomainReliabilityConfig::collectors, &ConvertURL); 113 "collectors", &DomainReliabilityConfig::collectors, &ConvertURL);
115 converter->RegisterRepeatedString("path_prefixes", 114 converter->RegisterRepeatedString("path_prefixes",
116 &DomainReliabilityConfig::path_prefixes); 115 &DomainReliabilityConfig::path_prefixes);
117 converter->RegisterDoubleField("success_sample_rate", 116 converter->RegisterDoubleField("success_sample_rate",
118 &DomainReliabilityConfig::success_sample_rate); 117 &DomainReliabilityConfig::success_sample_rate);
119 converter->RegisterDoubleField("failure_sample_rate", 118 converter->RegisterDoubleField("failure_sample_rate",
120 &DomainReliabilityConfig::failure_sample_rate); 119 &DomainReliabilityConfig::failure_sample_rate);
121 } 120 }
122 121
123 } // namespace domain_reliability 122 } // namespace domain_reliability
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698