OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_BASE_CAPTURING_NET_LOG_H_ | 5 #ifndef NET_BASE_CAPTURING_NET_LOG_H_ |
6 #define NET_BASE_CAPTURING_NET_LOG_H_ | 6 #define NET_BASE_CAPTURING_NET_LOG_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/atomicops.h" | 11 #include "base/atomicops.h" |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
17 #include "base/time.h" | 17 #include "base/time.h" |
18 #include "net/base/net_api.h" | 18 #include "net/base/net_export.h" |
19 #include "net/base/net_log.h" | 19 #include "net/base/net_log.h" |
20 | 20 |
21 namespace net { | 21 namespace net { |
22 | 22 |
23 // CapturingNetLog is an implementation of NetLog that saves messages to a | 23 // CapturingNetLog is an implementation of NetLog that saves messages to a |
24 // bounded buffer. | 24 // bounded buffer. |
25 class NET_API CapturingNetLog : public NetLog { | 25 class NET_EXPORT CapturingNetLog : public NetLog { |
26 public: | 26 public: |
27 struct NET_API Entry { | 27 struct NET_EXPORT Entry { |
28 Entry(EventType type, | 28 Entry(EventType type, |
29 const base::TimeTicks& time, | 29 const base::TimeTicks& time, |
30 Source source, | 30 Source source, |
31 EventPhase phase, | 31 EventPhase phase, |
32 EventParameters* extra_parameters); | 32 EventParameters* extra_parameters); |
33 ~Entry(); | 33 ~Entry(); |
34 | 34 |
35 EventType type; | 35 EventType type; |
36 base::TimeTicks time; | 36 base::TimeTicks time; |
37 Source source; | 37 Source source; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 NetLog::LogLevel log_level_; | 80 NetLog::LogLevel log_level_; |
81 | 81 |
82 DISALLOW_COPY_AND_ASSIGN(CapturingNetLog); | 82 DISALLOW_COPY_AND_ASSIGN(CapturingNetLog); |
83 }; | 83 }; |
84 | 84 |
85 // Helper class that exposes a similar API as BoundNetLog, but uses a | 85 // Helper class that exposes a similar API as BoundNetLog, but uses a |
86 // CapturingNetLog rather than the more generic NetLog. | 86 // CapturingNetLog rather than the more generic NetLog. |
87 // | 87 // |
88 // CapturingBoundNetLog can easily be converted to a BoundNetLog using the | 88 // CapturingBoundNetLog can easily be converted to a BoundNetLog using the |
89 // bound() method. | 89 // bound() method. |
90 class NET_TEST CapturingBoundNetLog { | 90 class NET_EXPORT_PRIVATE CapturingBoundNetLog { |
91 public: | 91 public: |
92 CapturingBoundNetLog(const NetLog::Source& source, CapturingNetLog* net_log); | 92 CapturingBoundNetLog(const NetLog::Source& source, CapturingNetLog* net_log); |
93 | 93 |
94 explicit CapturingBoundNetLog(size_t max_num_entries); | 94 explicit CapturingBoundNetLog(size_t max_num_entries); |
95 | 95 |
96 ~CapturingBoundNetLog(); | 96 ~CapturingBoundNetLog(); |
97 | 97 |
98 // The returned BoundNetLog is only valid while |this| is alive. | 98 // The returned BoundNetLog is only valid while |this| is alive. |
99 BoundNetLog bound() const { | 99 BoundNetLog bound() const { |
100 return BoundNetLog(source_, capturing_net_log_.get()); | 100 return BoundNetLog(source_, capturing_net_log_.get()); |
(...skipping 10 matching lines...) Expand all Loading... |
111 private: | 111 private: |
112 NetLog::Source source_; | 112 NetLog::Source source_; |
113 scoped_ptr<CapturingNetLog> capturing_net_log_; | 113 scoped_ptr<CapturingNetLog> capturing_net_log_; |
114 | 114 |
115 DISALLOW_COPY_AND_ASSIGN(CapturingBoundNetLog); | 115 DISALLOW_COPY_AND_ASSIGN(CapturingBoundNetLog); |
116 }; | 116 }; |
117 | 117 |
118 } // namespace net | 118 } // namespace net |
119 | 119 |
120 #endif // NET_BASE_CAPTURING_NET_LOG_H_ | 120 #endif // NET_BASE_CAPTURING_NET_LOG_H_ |
OLD | NEW |