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

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

Issue 9585026: Add a source id to global NetLog entries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Move friend declaration Created 8 years, 9 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
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 <vector> 9 #include <vector>
10 10
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 virtual ~CapturingNetLog(); 50 virtual ~CapturingNetLog();
51 51
52 // Returns the list of all entries in the log. 52 // Returns the list of all entries in the log.
53 void GetEntries(EntryList* entry_list) const; 53 void GetEntries(EntryList* entry_list) const;
54 54
55 void Clear(); 55 void Clear();
56 56
57 void SetLogLevel(NetLog::LogLevel log_level); 57 void SetLogLevel(NetLog::LogLevel log_level);
58 58
59 // NetLog implementation: 59 // NetLog implementation:
60 virtual void AddEntry(EventType type, 60 virtual void AddEntry(
61 const base::TimeTicks& time, 61 EventType type,
62 const Source& source, 62 const Source& source,
63 EventPhase phase, 63 EventPhase phase,
64 EventParameters* extra_parameters) OVERRIDE; 64 const scoped_refptr<EventParameters>& extra_parameters) OVERRIDE;
65 virtual uint32 NextID() OVERRIDE; 65 virtual uint32 NextID() OVERRIDE;
66 virtual LogLevel GetLogLevel() const OVERRIDE; 66 virtual LogLevel GetLogLevel() const OVERRIDE;
67 virtual void AddThreadSafeObserver(ThreadSafeObserver* observer, 67 virtual void AddThreadSafeObserver(ThreadSafeObserver* observer,
68 LogLevel log_level) OVERRIDE; 68 LogLevel log_level) OVERRIDE;
69 virtual void SetObserverLogLevel(ThreadSafeObserver* observer, 69 virtual void SetObserverLogLevel(ThreadSafeObserver* observer,
70 LogLevel log_level) OVERRIDE; 70 LogLevel log_level) OVERRIDE;
71 virtual void RemoveThreadSafeObserver(ThreadSafeObserver* observer) OVERRIDE; 71 virtual void RemoveThreadSafeObserver(ThreadSafeObserver* observer) OVERRIDE;
72 72
73 private: 73 private:
74 // Needs to be "mutable" so can use it in GetEntries(). 74 // Needs to be "mutable" so can use it in GetEntries().
(...skipping 10 matching lines...) Expand all
85 DISALLOW_COPY_AND_ASSIGN(CapturingNetLog); 85 DISALLOW_COPY_AND_ASSIGN(CapturingNetLog);
86 }; 86 };
87 87
88 // Helper class that exposes a similar API as BoundNetLog, but uses a 88 // Helper class that exposes a similar API as BoundNetLog, but uses a
89 // CapturingNetLog rather than the more generic NetLog. 89 // CapturingNetLog rather than the more generic NetLog.
90 // 90 //
91 // CapturingBoundNetLog can easily be converted to a BoundNetLog using the 91 // CapturingBoundNetLog can easily be converted to a BoundNetLog using the
92 // bound() method. 92 // bound() method.
93 class NET_EXPORT_PRIVATE CapturingBoundNetLog { 93 class NET_EXPORT_PRIVATE CapturingBoundNetLog {
94 public: 94 public:
95 CapturingBoundNetLog(const NetLog::Source& source, CapturingNetLog* net_log);
96
97 explicit CapturingBoundNetLog(size_t max_num_entries); 95 explicit CapturingBoundNetLog(size_t max_num_entries);
98 96
99 ~CapturingBoundNetLog(); 97 ~CapturingBoundNetLog();
100 98
101 // The returned BoundNetLog is only valid while |this| is alive. 99 // The returned BoundNetLog is only valid while |this| is alive.
102 BoundNetLog bound() const { 100 BoundNetLog bound() const {
103 return BoundNetLog(source_, capturing_net_log_.get()); 101 // The source type doesn't matter, since we only use |this| for a single
102 // source, and pull the results directly from |this|.
103 return BoundNetLog::Make(capturing_net_log_.get(),
104 net::NetLog::SOURCE_NONE);
eroman 2012/03/14 21:53:48 I think we should preserve the Source for generali
mmenke 2012/03/14 22:25:23 Ahh, good point. Done.
104 } 105 }
105 106
106 // Fills |entry_list| with all entries in the log. 107 // Fills |entry_list| with all entries in the log.
107 void GetEntries(CapturingNetLog::EntryList* entry_list) const; 108 void GetEntries(CapturingNetLog::EntryList* entry_list) const;
108 109
109 void Clear(); 110 void Clear();
110 111
111 // Sets the log level of the underlying CapturingNetLog. 112 // Sets the log level of the underlying CapturingNetLog.
112 void SetLogLevel(NetLog::LogLevel log_level); 113 void SetLogLevel(NetLog::LogLevel log_level);
113 114
114 private: 115 private:
115 NetLog::Source source_;
116 scoped_ptr<CapturingNetLog> capturing_net_log_; 116 scoped_ptr<CapturingNetLog> capturing_net_log_;
eroman 2012/03/14 21:53:48 Could make this into an instance now.
mmenke 2012/03/14 22:25:23 Done.
117 117
118 DISALLOW_COPY_AND_ASSIGN(CapturingBoundNetLog); 118 DISALLOW_COPY_AND_ASSIGN(CapturingBoundNetLog);
119 }; 119 };
120 120
121 } // namespace net 121 } // namespace net
122 122
123 #endif // NET_BASE_CAPTURING_NET_LOG_H_ 123 #endif // NET_BASE_CAPTURING_NET_LOG_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698