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

Side by Side Diff: chrome/browser/net/chrome_net_log.h

Issue 11828036: First cut at UI for saving net_logs data into a temporary file on (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 11 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 CHROME_BROWSER_NET_CHROME_NET_LOG_H_ 5 #ifndef CHROME_BROWSER_NET_CHROME_NET_LOG_H_
6 #define CHROME_BROWSER_NET_CHROME_NET_LOG_H_ 6 #define CHROME_BROWSER_NET_CHROME_NET_LOG_H_
7 7
8 #include "base/atomicops.h" 8 #include "base/atomicops.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/observer_list.h" 10 #include "base/observer_list.h"
11 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
12 #include "net/base/net_log.h" 12 #include "net/base/net_log.h"
13 13
14 class LoadTimingObserver; 14 class LoadTimingObserver;
15 class NetLogLogger; 15 class NetLogLogger;
16 class NetLogTempFile;
16 17
17 // ChromeNetLog is an implementation of NetLog that dispatches network log 18 // ChromeNetLog is an implementation of NetLog that dispatches network log
18 // messages to a list of observers. 19 // messages to a list of observers.
19 // 20 //
20 // All methods are thread safe, with the exception that no NetLog or 21 // All methods are thread safe, with the exception that no NetLog or
21 // NetLog::ThreadSafeObserver functions may be called by an observer's 22 // NetLog::ThreadSafeObserver functions may be called by an observer's
22 // OnAddEntry() method. Doing so will result in a deadlock. 23 // OnAddEntry() method. Doing so will result in a deadlock.
23 class ChromeNetLog : public net::NetLog { 24 class ChromeNetLog : public net::NetLog {
24 public: 25 public:
25 ChromeNetLog(); 26 ChromeNetLog();
26 virtual ~ChromeNetLog(); 27 virtual ~ChromeNetLog();
27 28
28 // NetLog implementation: 29 // NetLog implementation:
29 virtual uint32 NextID() OVERRIDE; 30 virtual uint32 NextID() OVERRIDE;
30 virtual LogLevel GetLogLevel() const OVERRIDE; 31 virtual LogLevel GetLogLevel() const OVERRIDE;
31 virtual void AddThreadSafeObserver(ThreadSafeObserver* observer, 32 virtual void AddThreadSafeObserver(ThreadSafeObserver* observer,
32 LogLevel log_level) OVERRIDE; 33 LogLevel log_level) OVERRIDE;
33 virtual void SetObserverLogLevel(ThreadSafeObserver* observer, 34 virtual void SetObserverLogLevel(ThreadSafeObserver* observer,
34 LogLevel log_level) OVERRIDE; 35 LogLevel log_level) OVERRIDE;
35 virtual void RemoveThreadSafeObserver(ThreadSafeObserver* observer) OVERRIDE; 36 virtual void RemoveThreadSafeObserver(ThreadSafeObserver* observer) OVERRIDE;
36 37
37 LoadTimingObserver* load_timing_observer() { 38 LoadTimingObserver* load_timing_observer() {
38 return load_timing_observer_.get(); 39 return load_timing_observer_.get();
39 } 40 }
40 41
42 NetLogTempFile* net_log_temp_file() {
43 return net_log_temp_file_.get();
44 }
45
41 private: 46 private:
42 // NetLog implementation: 47 // NetLog implementation:
43 virtual void OnAddEntry(const net::NetLog::Entry& entry) OVERRIDE; 48 virtual void OnAddEntry(const net::NetLog::Entry& entry) OVERRIDE;
44 49
45 // Called whenever an observer is added or removed, or has its log level 50 // Called whenever an observer is added or removed, or has its log level
46 // changed. Must have acquired |lock_| prior to calling. 51 // changed. Must have acquired |lock_| prior to calling.
47 void UpdateLogLevel(); 52 void UpdateLogLevel();
48 53
49 // |lock_| protects access to |observers_|. 54 // |lock_| protects access to |observers_|.
50 base::Lock lock_; 55 base::Lock lock_;
51 56
52 // Last assigned source ID. Incremented to get the next one. 57 // Last assigned source ID. Incremented to get the next one.
53 base::subtle::Atomic32 last_id_; 58 base::subtle::Atomic32 last_id_;
54 59
55 // The lowest allowed log level, regardless of any ChromeNetLogObservers. 60 // The lowest allowed log level, regardless of any ChromeNetLogObservers.
56 // Normally defaults to LOG_BASIC, but can be changed with command line flags. 61 // Normally defaults to LOG_BASIC, but can be changed with command line flags.
57 LogLevel base_log_level_; 62 LogLevel base_log_level_;
58 63
59 // The current log level. 64 // The current log level.
60 base::subtle::Atomic32 effective_log_level_; 65 base::subtle::Atomic32 effective_log_level_;
61 66
62 scoped_ptr<LoadTimingObserver> load_timing_observer_; 67 scoped_ptr<LoadTimingObserver> load_timing_observer_;
63 scoped_ptr<NetLogLogger> net_log_logger_; 68 scoped_ptr<NetLogLogger> net_log_logger_;
69 scoped_ptr<NetLogTempFile> net_log_temp_file_;
64 70
65 // |lock_| must be acquired whenever reading or writing to this. 71 // |lock_| must be acquired whenever reading or writing to this.
66 ObserverList<ThreadSafeObserver, true> observers_; 72 ObserverList<ThreadSafeObserver, true> observers_;
67 73
68 DISALLOW_COPY_AND_ASSIGN(ChromeNetLog); 74 DISALLOW_COPY_AND_ASSIGN(ChromeNetLog);
69 }; 75 };
70 76
71 #endif // CHROME_BROWSER_NET_CHROME_NET_LOG_H_ 77 #endif // CHROME_BROWSER_NET_CHROME_NET_LOG_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698