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

Side by Side Diff: net/base/captured_net_log_entry.cc

Issue 754433003: Update from https://crrev.com/305340 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 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
« no previous file with comments | « net/base/captured_net_log_entry.h ('k') | net/base/capturing_net_log.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "net/base/captured_net_log_entry.h"
6
7 #include "base/json/json_writer.h"
8 #include "base/logging.h"
9 #include "base/values.h"
10
11 namespace net {
12
13 CapturedNetLogEntry::CapturedNetLogEntry(
14 NetLog::EventType type,
15 const base::TimeTicks& time,
16 NetLog::Source source,
17 NetLog::EventPhase phase,
18 scoped_ptr<base::DictionaryValue> params)
19 : type(type),
20 time(time),
21 source(source),
22 phase(phase),
23 params(params.Pass()) {
24 // Only entries without a NetLog should have an invalid source.
25 CHECK(source.IsValid());
26 }
27
28 CapturedNetLogEntry::CapturedNetLogEntry(const CapturedNetLogEntry& entry) {
29 *this = entry;
30 }
31
32 CapturedNetLogEntry::~CapturedNetLogEntry() {}
33
34 CapturedNetLogEntry& CapturedNetLogEntry::operator=(
35 const CapturedNetLogEntry& entry) {
36 type = entry.type;
37 time = entry.time;
38 source = entry.source;
39 phase = entry.phase;
40 params.reset(entry.params ? entry.params->DeepCopy() : NULL);
41 return *this;
42 }
43
44 bool CapturedNetLogEntry::GetStringValue(const std::string& name,
45 std::string* value) const {
46 if (!params)
47 return false;
48 return params->GetString(name, value);
49 }
50
51 bool CapturedNetLogEntry::GetIntegerValue(const std::string& name,
52 int* value) const {
53 if (!params)
54 return false;
55 return params->GetInteger(name, value);
56 }
57
58 bool CapturedNetLogEntry::GetListValue(const std::string& name,
59 base::ListValue** value) const {
60 if (!params)
61 return false;
62 return params->GetList(name, value);
63 }
64
65 bool CapturedNetLogEntry::GetNetErrorCode(int* value) const {
66 return GetIntegerValue("net_error", value);
67 }
68
69 std::string CapturedNetLogEntry::GetParamsJson() const {
70 if (!params)
71 return std::string();
72 std::string json;
73 base::JSONWriter::Write(params.get(), &json);
74 return json;
75 }
76
77 } // namespace net
OLDNEW
« no previous file with comments | « net/base/captured_net_log_entry.h ('k') | net/base/capturing_net_log.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698