Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / net / log / captured_net_log_entry.cc
blobefd344b59fa910ff0a2302f822f5b8e5221bf3f5
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/captured_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 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());
28 CapturedNetLogEntry::CapturedNetLogEntry(const CapturedNetLogEntry& entry) {
29 *this = entry;
32 CapturedNetLogEntry::~CapturedNetLogEntry() {
35 CapturedNetLogEntry& CapturedNetLogEntry::operator=(
36 const CapturedNetLogEntry& entry) {
37 type = entry.type;
38 time = entry.time;
39 source = entry.source;
40 phase = entry.phase;
41 params.reset(entry.params ? entry.params->DeepCopy() : NULL);
42 return *this;
45 bool CapturedNetLogEntry::GetStringValue(const std::string& name,
46 std::string* value) const {
47 if (!params)
48 return false;
49 return params->GetString(name, value);
52 bool CapturedNetLogEntry::GetIntegerValue(const std::string& name,
53 int* value) const {
54 if (!params)
55 return false;
56 return params->GetInteger(name, value);
59 bool CapturedNetLogEntry::GetListValue(const std::string& name,
60 base::ListValue** value) const {
61 if (!params)
62 return false;
63 return params->GetList(name, value);
66 bool CapturedNetLogEntry::GetNetErrorCode(int* value) const {
67 return GetIntegerValue("net_error", value);
70 std::string CapturedNetLogEntry::GetParamsJson() const {
71 if (!params)
72 return std::string();
73 std::string json;
74 base::JSONWriter::Write(params.get(), &json);
75 return json;
78 } // namespace net