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

Side by Side Diff: net/log/net_log.cc

Issue 2891933004: Remove raw base::DictionaryValue::Set in //content (Closed)
Patch Set: Rebase Created 3 years, 6 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 | « net/log/net_log.h ('k') | no next file » | 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 #include "net/log/net_log.h" 5 #include "net/log/net_log.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/ptr_util.h"
12 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
14 #include "base/values.h" 15 #include "base/values.h"
15 16
16 namespace net { 17 namespace net {
17 18
18 namespace { 19 namespace {
19 20
20 std::unique_ptr<base::Value> NetLogBoolCallback( 21 std::unique_ptr<base::Value> NetLogBoolCallback(
21 const char* name, 22 const char* name,
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 return #label; 193 return #label;
193 #include "net/log/net_log_event_type_list.h" 194 #include "net/log/net_log_event_type_list.h"
194 #undef EVENT_TYPE 195 #undef EVENT_TYPE
195 default: 196 default:
196 NOTREACHED(); 197 NOTREACHED();
197 return NULL; 198 return NULL;
198 } 199 }
199 } 200 }
200 201
201 // static 202 // static
202 base::Value* NetLog::GetEventTypesAsValue() { 203 std::unique_ptr<base::Value> NetLog::GetEventTypesAsValue() {
203 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 204 auto dict = base::MakeUnique<base::DictionaryValue>();
204 for (int i = 0; i < static_cast<int>(NetLogEventType::COUNT); ++i) { 205 for (int i = 0; i < static_cast<int>(NetLogEventType::COUNT); ++i) {
205 dict->SetInteger(EventTypeToString(static_cast<NetLogEventType>(i)), i); 206 dict->SetInteger(EventTypeToString(static_cast<NetLogEventType>(i)), i);
206 } 207 }
207 return dict.release(); 208 return std::move(dict);
208 } 209 }
209 210
210 // static 211 // static
211 const char* NetLog::SourceTypeToString(NetLogSourceType source) { 212 const char* NetLog::SourceTypeToString(NetLogSourceType source) {
212 switch (source) { 213 switch (source) {
213 #define SOURCE_TYPE(label) \ 214 #define SOURCE_TYPE(label) \
214 case NetLogSourceType::label: \ 215 case NetLogSourceType::label: \
215 return #label; 216 return #label;
216 #include "net/log/net_log_source_type_list.h" 217 #include "net/log/net_log_source_type_list.h"
217 #undef SOURCE_TYPE 218 #undef SOURCE_TYPE
218 default: 219 default:
219 NOTREACHED(); 220 NOTREACHED();
220 return NULL; 221 return NULL;
221 } 222 }
222 } 223 }
223 224
224 // static 225 // static
225 base::Value* NetLog::GetSourceTypesAsValue() { 226 std::unique_ptr<base::Value> NetLog::GetSourceTypesAsValue() {
226 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 227 auto dict = base::MakeUnique<base::DictionaryValue>();
227 for (int i = 0; i < static_cast<int>(NetLogSourceType::COUNT); ++i) { 228 for (int i = 0; i < static_cast<int>(NetLogSourceType::COUNT); ++i) {
228 dict->SetInteger(SourceTypeToString(static_cast<NetLogSourceType>(i)), i); 229 dict->SetInteger(SourceTypeToString(static_cast<NetLogSourceType>(i)), i);
229 } 230 }
230 return dict.release(); 231 return std::move(dict);
231 } 232 }
232 233
233 // static 234 // static
234 const char* NetLog::EventPhaseToString(NetLogEventPhase phase) { 235 const char* NetLog::EventPhaseToString(NetLogEventPhase phase) {
235 switch (phase) { 236 switch (phase) {
236 case NetLogEventPhase::BEGIN: 237 case NetLogEventPhase::BEGIN:
237 return "PHASE_BEGIN"; 238 return "PHASE_BEGIN";
238 case NetLogEventPhase::END: 239 case NetLogEventPhase::END:
239 return "PHASE_END"; 240 return "PHASE_END";
240 case NetLogEventPhase::NONE: 241 case NetLogEventPhase::NONE:
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 NetLogEntryData entry_data(type, source, phase, base::TimeTicks::Now(), 291 NetLogEntryData entry_data(type, source, phase, base::TimeTicks::Now(),
291 parameters_callback); 292 parameters_callback);
292 293
293 // Notify all of the log observers. 294 // Notify all of the log observers.
294 base::AutoLock lock(lock_); 295 base::AutoLock lock(lock_);
295 for (auto* observer : observers_) 296 for (auto* observer : observers_)
296 observer->OnAddEntryData(entry_data); 297 observer->OnAddEntryData(entry_data);
297 } 298 }
298 299
299 } // namespace net 300 } // namespace net
OLDNEW
« no previous file with comments | « net/log/net_log.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698