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 #ifndef NET_LOG_TEST_NET_LOG_ENTRY_H_
6 #define NET_LOG_TEST_NET_LOG_ENTRY_H_
11 #include "base/memory/scoped_ptr.h"
12 #include "base/time/time.h"
13 #include "net/log/net_log.h"
16 class DictionaryValue
;
22 // TestNetLogEntry is much like NetLog::Entry, except it has its own copy of all
23 // log data, so a list of entries can be gathered over the course of a test, and
24 // then inspected at the end. It is intended for testing only, and is part of
25 // the net_test_support project.
26 struct TestNetLogEntry
{
27 // Ordered set of logged entries.
28 typedef std::vector
<TestNetLogEntry
> List
;
30 TestNetLogEntry(NetLog::EventType type
,
31 const base::TimeTicks
& time
,
32 NetLog::Source source
,
33 NetLog::EventPhase phase
,
34 scoped_ptr
<base::DictionaryValue
> params
);
35 // Copy constructor needed to store in a std::vector because of the
37 TestNetLogEntry(const TestNetLogEntry
& entry
);
41 // Equality operator needed to store in a std::vector because of the
43 TestNetLogEntry
& operator=(const TestNetLogEntry
& entry
);
45 // Attempt to retrieve an value of the specified type with the given name
46 // from |params|. Returns true on success, false on failure. Does not
47 // modify |value| on failure.
48 bool GetStringValue(const std::string
& name
, std::string
* value
) const;
49 bool GetIntegerValue(const std::string
& name
, int* value
) const;
50 bool GetBooleanValue(const std::string
& name
, bool* value
) const;
51 bool GetListValue(const std::string
& name
, base::ListValue
** value
) const;
53 // Same as GetIntegerValue, but returns the error code associated with a
55 bool GetNetErrorCode(int* value
) const;
57 // Returns the parameters as a JSON string, or empty string if there are no
59 std::string
GetParamsJson() const;
61 NetLog::EventType type
;
63 NetLog::Source source
;
64 NetLog::EventPhase phase
;
65 scoped_ptr
<base::DictionaryValue
> params
;
70 #endif // NET_LOG_TEST_NET_LOG_ENTRY_H_