Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1323)

Side by Side Diff: net/base/capturing_net_log.h

Issue 10532067: Move CapturingNetLog over to net_test_support from net. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Response to comments Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | net/net.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/atomicops.h" 12 #include "base/atomicops.h"
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/synchronization/lock.h" 17 #include "base/synchronization/lock.h"
18 #include "base/time.h" 18 #include "base/time.h"
19 #include "net/base/net_export.h"
20 #include "net/base/net_log.h" 19 #include "net/base/net_log.h"
21 20
22 namespace base { 21 namespace base {
23 class DictionaryValue; 22 class DictionaryValue;
24 } 23 }
25 24
26 namespace net { 25 namespace net {
27 26
28 // CapturingNetLog is an implementation of NetLog that saves messages to a 27 // CapturingNetLog is an implementation of NetLog that saves messages to a
29 // bounded buffer. CapturingNetLogs should only be used in unit tests, never 28 // bounded buffer. It is intended for testing only, and is part of the
30 // in production code. 29 // net_test_support project.
31 // TODO(mmenke): Move CapturingNetLog to net_unittests project, once the CL 30 class CapturingNetLog : public NetLog {
32 // to remove the use of it in the Jingle unit tests has landed.
33 class NET_EXPORT CapturingNetLog : public NetLog {
34 public: 31 public:
35 struct NET_EXPORT_PRIVATE CapturedEntry { 32 struct CapturedEntry {
36 CapturedEntry(EventType type, 33 CapturedEntry(EventType type,
37 const base::TimeTicks& time, 34 const base::TimeTicks& time,
38 Source source, 35 Source source,
39 EventPhase phase, 36 EventPhase phase,
40 scoped_ptr<base::DictionaryValue> params); 37 scoped_ptr<base::DictionaryValue> params);
41 // Copy constructor needed to store in a std::vector because of the 38 // Copy constructor needed to store in a std::vector because of the
42 // scoped_ptr. 39 // scoped_ptr.
43 CapturedEntry(const CapturedEntry& entry); 40 CapturedEntry(const CapturedEntry& entry);
44 41
45 ~CapturedEntry(); 42 ~CapturedEntry();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 NetLog::LogLevel log_level_; 106 NetLog::LogLevel log_level_;
110 107
111 DISALLOW_COPY_AND_ASSIGN(CapturingNetLog); 108 DISALLOW_COPY_AND_ASSIGN(CapturingNetLog);
112 }; 109 };
113 110
114 // Helper class that exposes a similar API as BoundNetLog, but uses a 111 // Helper class that exposes a similar API as BoundNetLog, but uses a
115 // CapturingNetLog rather than the more generic NetLog. 112 // CapturingNetLog rather than the more generic NetLog.
116 // 113 //
117 // CapturingBoundNetLog can easily be converted to a BoundNetLog using the 114 // CapturingBoundNetLog can easily be converted to a BoundNetLog using the
118 // bound() method. 115 // bound() method.
119 class NET_EXPORT_PRIVATE CapturingBoundNetLog { 116 class CapturingBoundNetLog {
120 public: 117 public:
121 explicit CapturingBoundNetLog(size_t max_num_entries); 118 explicit CapturingBoundNetLog(size_t max_num_entries);
122 119
123 ~CapturingBoundNetLog(); 120 ~CapturingBoundNetLog();
124 121
125 // The returned BoundNetLog is only valid while |this| is alive. 122 // The returned BoundNetLog is only valid while |this| is alive.
126 BoundNetLog bound() const { return net_log_; } 123 BoundNetLog bound() const { return net_log_; }
127 124
128 // Fills |entry_list| with all entries in the log. 125 // Fills |entry_list| with all entries in the log.
129 void GetEntries(CapturingNetLog::CapturedEntryList* entry_list) const; 126 void GetEntries(CapturingNetLog::CapturedEntryList* entry_list) const;
130 127
131 void Clear(); 128 void Clear();
132 129
133 // Sets the log level of the underlying CapturingNetLog. 130 // Sets the log level of the underlying CapturingNetLog.
134 void SetLogLevel(NetLog::LogLevel log_level); 131 void SetLogLevel(NetLog::LogLevel log_level);
135 132
136 private: 133 private:
137 CapturingNetLog capturing_net_log_; 134 CapturingNetLog capturing_net_log_;
138 const BoundNetLog net_log_; 135 const BoundNetLog net_log_;
139 136
140 DISALLOW_COPY_AND_ASSIGN(CapturingBoundNetLog); 137 DISALLOW_COPY_AND_ASSIGN(CapturingBoundNetLog);
141 }; 138 };
142 139
143 } // namespace net 140 } // namespace net
144 141
145 #endif // NET_BASE_CAPTURING_NET_LOG_H_ 142 #endif // NET_BASE_CAPTURING_NET_LOG_H_
OLDNEW
« no previous file with comments | « no previous file | net/net.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698