customtabs: Don't crash when the client AIDL is incorrect.
[chromium-blink-merge.git] / net / log / test_net_log_entry.cc
blob34e9ffa6dc0518b6281ef54075d2741ca4be318b
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"
11 namespace net {
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)
18 : type(type),
19 time(time),
20 source(source),
21 phase(phase),
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) {
28 *this = entry;
31 TestNetLogEntry::~TestNetLogEntry() {
34 TestNetLogEntry& TestNetLogEntry::operator=(const TestNetLogEntry& entry) {
35 type = entry.type;
36 time = entry.time;
37 source = entry.source;
38 phase = entry.phase;
39 params.reset(entry.params ? entry.params->DeepCopy() : NULL);
40 return *this;
43 bool TestNetLogEntry::GetStringValue(const std::string& name,
44 std::string* value) const {
45 if (!params)
46 return false;
47 return params->GetString(name, value);
50 bool TestNetLogEntry::GetIntegerValue(const std::string& name,
51 int* value) const {
52 if (!params)
53 return false;
54 return params->GetInteger(name, value);
57 bool TestNetLogEntry::GetBooleanValue(const std::string& name,
58 bool* value) const {
59 if (!params)
60 return false;
61 return params->GetBoolean(name, value);
64 bool TestNetLogEntry::GetListValue(const std::string& name,
65 base::ListValue** value) const {
66 if (!params)
67 return false;
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 {
76 if (!params)
77 return std::string();
78 std::string json;
79 base::JSONWriter::Write(*params, &json);
80 return json;
83 } // namespace net