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

Side by Side Diff: content/browser/tracing/background_tracing_config_impl.cc

Issue 1545243002: Convert Pass()→std::move() in //content/browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/browser/tracing/background_tracing_config_impl.h"
6
7 #include <utility>
8
5 #include "base/macros.h" 9 #include "base/macros.h"
6 #include "base/values.h" 10 #include "base/values.h"
7 #include "content/browser/tracing/background_tracing_config_impl.h"
8 #include "content/browser/tracing/background_tracing_rule.h" 11 #include "content/browser/tracing/background_tracing_rule.h"
9 12
10 namespace content { 13 namespace content {
11 14
12 namespace { 15 namespace {
13 16
14 const char kConfigsKey[] = "configs"; 17 const char kConfigsKey[] = "configs";
15 18
16 const char kConfigModeKey[] = "mode"; 19 const char kConfigModeKey[] = "mode";
17 const char kConfigModePreemptive[] = "PREEMPTIVE_TRACING_MODE"; 20 const char kConfigModePreemptive[] = "PREEMPTIVE_TRACING_MODE";
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 case BackgroundTracingConfigImpl::REACTIVE: 107 case BackgroundTracingConfigImpl::REACTIVE:
105 dict->SetString(kConfigModeKey, kConfigModeReactive); 108 dict->SetString(kConfigModeKey, kConfigModeReactive);
106 break; 109 break;
107 } 110 }
108 111
109 scoped_ptr<base::ListValue> configs_list(new base::ListValue()); 112 scoped_ptr<base::ListValue> configs_list(new base::ListValue());
110 for (const auto& it : rules_) { 113 for (const auto& it : rules_) {
111 scoped_ptr<base::DictionaryValue> config_dict(new base::DictionaryValue()); 114 scoped_ptr<base::DictionaryValue> config_dict(new base::DictionaryValue());
112 DCHECK(it); 115 DCHECK(it);
113 it->IntoDict(config_dict.get()); 116 it->IntoDict(config_dict.get());
114 configs_list->Append(config_dict.Pass()); 117 configs_list->Append(std::move(config_dict));
115 } 118 }
116 119
117 dict->Set(kConfigsKey, configs_list.Pass()); 120 dict->Set(kConfigsKey, std::move(configs_list));
118 121
119 if (!scenario_name_.empty()) 122 if (!scenario_name_.empty())
120 dict->SetString(kConfigScenarioName, scenario_name_); 123 dict->SetString(kConfigScenarioName, scenario_name_);
121 if (!enable_blink_features_.empty()) 124 if (!enable_blink_features_.empty())
122 dict->SetString(kConfigEnableBlinkFeatures, enable_blink_features_); 125 dict->SetString(kConfigEnableBlinkFeatures, enable_blink_features_);
123 if (!disable_blink_features_.empty()) 126 if (!disable_blink_features_.empty())
124 dict->SetString(kConfigDisableBlinkFeatures, disable_blink_features_); 127 dict->SetString(kConfigDisableBlinkFeatures, disable_blink_features_);
125 } 128 }
126 129
127 void BackgroundTracingConfigImpl::AddPreemptiveRule( 130 void BackgroundTracingConfigImpl::AddPreemptiveRule(
128 const base::DictionaryValue* dict) { 131 const base::DictionaryValue* dict) {
129 scoped_ptr<BackgroundTracingRule> rule = 132 scoped_ptr<BackgroundTracingRule> rule =
130 BackgroundTracingRule::PreemptiveRuleFromDict(dict); 133 BackgroundTracingRule::PreemptiveRuleFromDict(dict);
131 if (rule) 134 if (rule)
132 rules_.push_back(rule.Pass()); 135 rules_.push_back(std::move(rule));
133 } 136 }
134 137
135 void BackgroundTracingConfigImpl::AddReactiveRule( 138 void BackgroundTracingConfigImpl::AddReactiveRule(
136 const base::DictionaryValue* dict, 139 const base::DictionaryValue* dict,
137 BackgroundTracingConfigImpl::CategoryPreset category_preset) { 140 BackgroundTracingConfigImpl::CategoryPreset category_preset) {
138 scoped_ptr<BackgroundTracingRule> rule = 141 scoped_ptr<BackgroundTracingRule> rule =
139 BackgroundTracingRule::ReactiveRuleFromDict(dict, category_preset); 142 BackgroundTracingRule::ReactiveRuleFromDict(dict, category_preset);
140 if (rule) 143 if (rule)
141 rules_.push_back(rule.Pass()); 144 rules_.push_back(std::move(rule));
142 } 145 }
143 146
144 scoped_ptr<BackgroundTracingConfigImpl> BackgroundTracingConfigImpl::FromDict( 147 scoped_ptr<BackgroundTracingConfigImpl> BackgroundTracingConfigImpl::FromDict(
145 const base::DictionaryValue* dict) { 148 const base::DictionaryValue* dict) {
146 DCHECK(dict); 149 DCHECK(dict);
147 150
148 std::string mode; 151 std::string mode;
149 if (!dict->GetString(kConfigModeKey, &mode)) 152 if (!dict->GetString(kConfigModeKey, &mode))
150 return nullptr; 153 return nullptr;
151 154
152 scoped_ptr<BackgroundTracingConfigImpl> config; 155 scoped_ptr<BackgroundTracingConfigImpl> config;
153 156
154 if (mode == kConfigModePreemptive) { 157 if (mode == kConfigModePreemptive) {
155 config = PreemptiveFromDict(dict); 158 config = PreemptiveFromDict(dict);
156 } else if (mode == kConfigModeReactive) { 159 } else if (mode == kConfigModeReactive) {
157 config = ReactiveFromDict(dict); 160 config = ReactiveFromDict(dict);
158 } else { 161 } else {
159 return nullptr; 162 return nullptr;
160 } 163 }
161 164
162 if (config) { 165 if (config) {
163 dict->GetString(kConfigScenarioName, &config->scenario_name_); 166 dict->GetString(kConfigScenarioName, &config->scenario_name_);
164 dict->GetString(kConfigEnableBlinkFeatures, 167 dict->GetString(kConfigEnableBlinkFeatures,
165 &config->enable_blink_features_); 168 &config->enable_blink_features_);
166 dict->GetString(kConfigDisableBlinkFeatures, 169 dict->GetString(kConfigDisableBlinkFeatures,
167 &config->disable_blink_features_); 170 &config->disable_blink_features_);
168 } 171 }
169 172
170 return config.Pass(); 173 return config;
171 } 174 }
172 175
173 scoped_ptr<BackgroundTracingConfigImpl> 176 scoped_ptr<BackgroundTracingConfigImpl>
174 BackgroundTracingConfigImpl::PreemptiveFromDict( 177 BackgroundTracingConfigImpl::PreemptiveFromDict(
175 const base::DictionaryValue* dict) { 178 const base::DictionaryValue* dict) {
176 DCHECK(dict); 179 DCHECK(dict);
177 180
178 scoped_ptr<BackgroundTracingConfigImpl> config( 181 scoped_ptr<BackgroundTracingConfigImpl> config(
179 new BackgroundTracingConfigImpl(BackgroundTracingConfigImpl::PREEMPTIVE)); 182 new BackgroundTracingConfigImpl(BackgroundTracingConfigImpl::PREEMPTIVE));
180 183
(...skipping 13 matching lines...) Expand all
194 const base::DictionaryValue* config_dict = nullptr; 197 const base::DictionaryValue* config_dict = nullptr;
195 if (!it->GetAsDictionary(&config_dict)) 198 if (!it->GetAsDictionary(&config_dict))
196 return nullptr; 199 return nullptr;
197 200
198 config->AddPreemptiveRule(config_dict); 201 config->AddPreemptiveRule(config_dict);
199 } 202 }
200 203
201 if (config->rules().empty()) 204 if (config->rules().empty())
202 return nullptr; 205 return nullptr;
203 206
204 return config.Pass(); 207 return config;
205 } 208 }
206 209
207 scoped_ptr<BackgroundTracingConfigImpl> 210 scoped_ptr<BackgroundTracingConfigImpl>
208 BackgroundTracingConfigImpl::ReactiveFromDict( 211 BackgroundTracingConfigImpl::ReactiveFromDict(
209 const base::DictionaryValue* dict) { 212 const base::DictionaryValue* dict) {
210 DCHECK(dict); 213 DCHECK(dict);
211 214
212 scoped_ptr<BackgroundTracingConfigImpl> config( 215 scoped_ptr<BackgroundTracingConfigImpl> config(
213 new BackgroundTracingConfigImpl(BackgroundTracingConfigImpl::REACTIVE)); 216 new BackgroundTracingConfigImpl(BackgroundTracingConfigImpl::REACTIVE));
214 217
(...skipping 13 matching lines...) Expand all
228 BackgroundTracingConfigImpl::CategoryPreset new_category_preset; 231 BackgroundTracingConfigImpl::CategoryPreset new_category_preset;
229 if (!StringToCategoryPreset(category_preset_string, &new_category_preset)) 232 if (!StringToCategoryPreset(category_preset_string, &new_category_preset))
230 return nullptr; 233 return nullptr;
231 234
232 config->AddReactiveRule(config_dict, new_category_preset); 235 config->AddReactiveRule(config_dict, new_category_preset);
233 } 236 }
234 237
235 if (config->rules().empty()) 238 if (config->rules().empty())
236 return nullptr; 239 return nullptr;
237 240
238 return config.Pass(); 241 return config;
239 } 242 }
240 243
241 } // namspace content 244 } // namspace content
OLDNEW
« no previous file with comments | « content/browser/streams/stream.cc ('k') | content/browser/tracing/background_tracing_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698