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

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

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

Powered by Google App Engine
This is Rietveld 408576698