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/log/test_net_log_entry.h"
7 #include "base/json/json_writer.h"
8 #include "base/logging.h"
9 #include "base/values.h"
13 TestNetLogEntry::TestNetLogEntry(NetLog::EventType type
,
14 const base::TimeTicks
& time
,
15 NetLog::Source source
,
16 NetLog::EventPhase phase
,
17 scoped_ptr
<base::DictionaryValue
> params
)
22 params(params
.Pass()) {
23 // Only entries without a NetLog should have an invalid source.
24 CHECK(source
.IsValid());
27 TestNetLogEntry::TestNetLogEntry(const TestNetLogEntry
& entry
) {
31 TestNetLogEntry::~TestNetLogEntry() {
34 TestNetLogEntry
& TestNetLogEntry::operator=(const TestNetLogEntry
& entry
) {
37 source
= entry
.source
;
39 params
.reset(entry
.params
? entry
.params
->DeepCopy() : NULL
);
43 bool TestNetLogEntry::GetStringValue(const std::string
& name
,
44 std::string
* value
) const {
47 return params
->GetString(name
, value
);
50 bool TestNetLogEntry::GetIntegerValue(const std::string
& name
,
54 return params
->GetInteger(name
, value
);
57 bool TestNetLogEntry::GetBooleanValue(const std::string
& name
,
61 return params
->GetBoolean(name
, value
);
64 bool TestNetLogEntry::GetListValue(const std::string
& name
,
65 base::ListValue
** value
) const {
68 return params
->GetList(name
, value
);
71 bool TestNetLogEntry::GetNetErrorCode(int* value
) const {
72 return GetIntegerValue("net_error", value
);
75 std::string
TestNetLogEntry::GetParamsJson() const {
79 base::JSONWriter::Write(*params
, &json
);