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.
5 #include "net/base/captured_net_log_entry.h"
7 #include "base/json/json_writer.h"
8 #include "base/logging.h"
9 #include "base/values.h"
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
)
23 params(params
.Pass()) {
24 // Only entries without a NetLog should have an invalid source.
25 CHECK(source
.IsValid());
28 CapturedNetLogEntry::CapturedNetLogEntry(const CapturedNetLogEntry
& entry
) {
32 CapturedNetLogEntry::~CapturedNetLogEntry() {}
34 CapturedNetLogEntry
& CapturedNetLogEntry::operator=(
35 const CapturedNetLogEntry
& entry
) {
38 source
= entry
.source
;
40 params
.reset(entry
.params
? entry
.params
->DeepCopy() : NULL
);
44 bool CapturedNetLogEntry::GetStringValue(const std::string
& name
,
45 std::string
* value
) const {
48 return params
->GetString(name
, value
);
51 bool CapturedNetLogEntry::GetIntegerValue(const std::string
& name
,
55 return params
->GetInteger(name
, value
);
58 bool CapturedNetLogEntry::GetListValue(const std::string
& name
,
59 base::ListValue
** value
) const {
62 return params
->GetList(name
, value
);
65 bool CapturedNetLogEntry::GetNetErrorCode(int* value
) const {
66 return GetIntegerValue("net_error", value
);
69 std::string
CapturedNetLogEntry::GetParamsJson() const {
73 base::JSONWriter::Write(params
.get(), &json
);