OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef NET_BASE_CAPTURED_NET_LOG_ENTRY_H_ |
| 6 #define NET_BASE_CAPTURED_NET_LOG_ENTRY_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/time/time.h" |
| 13 #include "net/base/net_log.h" |
| 14 |
| 15 namespace base { |
| 16 class DictionaryValue; |
| 17 class ListValue; |
| 18 } |
| 19 |
| 20 namespace net { |
| 21 |
| 22 // CapturedNetLogEntry is much like NetLog::Entry, except it has its own copy of |
| 23 // all log data, so a list of entries can be gathered over the course of a test, |
| 24 // and then inspected at the end. It is intended for testing only, and is part |
| 25 // of the net_test_support project. |
| 26 struct CapturedNetLogEntry { |
| 27 // Ordered set of logged entries. |
| 28 typedef std::vector<CapturedNetLogEntry> List; |
| 29 |
| 30 CapturedNetLogEntry(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 |
| 36 // scoped_ptr. |
| 37 CapturedNetLogEntry(const CapturedNetLogEntry& entry); |
| 38 |
| 39 ~CapturedNetLogEntry(); |
| 40 |
| 41 // Equality operator needed to store in a std::vector because of the |
| 42 // scoped_ptr. |
| 43 CapturedNetLogEntry& operator=(const CapturedNetLogEntry& entry); |
| 44 |
| 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 GetListValue(const std::string& name, base::ListValue** value) const; |
| 51 |
| 52 // Same as GetIntegerValue, but returns the error code associated with a |
| 53 // log entry. |
| 54 bool GetNetErrorCode(int* value) const; |
| 55 |
| 56 // Returns the parameters as a JSON string, or empty string if there are no |
| 57 // parameters. |
| 58 std::string GetParamsJson() const; |
| 59 |
| 60 NetLog::EventType type; |
| 61 base::TimeTicks time; |
| 62 NetLog::Source source; |
| 63 NetLog::EventPhase phase; |
| 64 scoped_ptr<base::DictionaryValue> params; |
| 65 }; |
| 66 |
| 67 } // namespace net |
| 68 |
| 69 #endif // NET_BASE_CAPTURED_NET_LOG_ENTRY_H_ |
OLD | NEW |