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

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

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 #include "net/base/capturing_net_log.h" 5 #include "net/base/capturing_net_log.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace net { 9 namespace net {
10 10
11 CapturingNetLog::Entry::Entry(EventType type, 11 CapturingNetLog::Entry::Entry(EventType type,
12 const base::TimeTicks& time, 12 const base::TimeTicks& time,
13 Source source, 13 Source source,
14 EventPhase phase, 14 EventPhase phase,
15 EventParameters* extra_parameters) 15 EventParameters* extra_parameters)
16 : type(type), time(time), source(source), phase(phase), 16 : type(type), time(time), source(source), phase(phase),
17 extra_parameters(extra_parameters) { 17 extra_parameters(extra_parameters) {
18 } 18 }
19 19
20 CapturingNetLog::Entry::~Entry() {} 20 CapturingNetLog::Entry::~Entry() {}
21 21
22 CapturingNetLog::CapturingNetLog(size_t max_num_entries) 22 CapturingNetLog::CapturingNetLog(size_t max_num_entries)
23 : last_id_(-1), 23 : last_id_(0),
24 max_num_entries_(max_num_entries), 24 max_num_entries_(max_num_entries),
25 log_level_(LOG_ALL_BUT_BYTES) { 25 log_level_(LOG_ALL_BUT_BYTES) {
26 } 26 }
27 27
28 CapturingNetLog::~CapturingNetLog() {} 28 CapturingNetLog::~CapturingNetLog() {}
29 29
30 void CapturingNetLog::GetEntries(EntryList* entry_list) const { 30 void CapturingNetLog::GetEntries(EntryList* entry_list) const {
31 base::AutoLock lock(lock_); 31 base::AutoLock lock(lock_);
32 *entry_list = entries_; 32 *entry_list = entries_;
33 } 33 }
34 34
35 void CapturingNetLog::Clear() { 35 void CapturingNetLog::Clear() {
36 base::AutoLock lock(lock_); 36 base::AutoLock lock(lock_);
37 entries_.clear(); 37 entries_.clear();
38 } 38 }
39 39
40 void CapturingNetLog::SetLogLevel(NetLog::LogLevel log_level) { 40 void CapturingNetLog::SetLogLevel(NetLog::LogLevel log_level) {
41 base::AutoLock lock(lock_); 41 base::AutoLock lock(lock_);
42 log_level_ = log_level; 42 log_level_ = log_level;
43 } 43 }
44 44
45 void CapturingNetLog::AddEntry(EventType type, 45 void CapturingNetLog::AddEntry(
46 const base::TimeTicks& time, 46 EventType type,
47 const Source& source, 47 const Source& source,
48 EventPhase phase, 48 EventPhase phase,
49 EventParameters* extra_parameters) { 49 const scoped_refptr<EventParameters>& extra_parameters) {
50 DCHECK(source.is_valid());
50 base::AutoLock lock(lock_); 51 base::AutoLock lock(lock_);
51 Entry entry(type, time, source, phase, extra_parameters); 52 Entry entry(type, base::TimeTicks::Now(), source, phase, extra_parameters);
52 if (entries_.size() + 1 < max_num_entries_) 53 if (entries_.size() + 1 < max_num_entries_)
53 entries_.push_back(entry); 54 entries_.push_back(entry);
54 } 55 }
55 56
56 uint32 CapturingNetLog::NextID() { 57 uint32 CapturingNetLog::NextID() {
57 return base::subtle::NoBarrier_AtomicIncrement(&last_id_, 1); 58 return base::subtle::NoBarrier_AtomicIncrement(&last_id_, 1);
58 } 59 }
59 60
60 NetLog::LogLevel CapturingNetLog::GetLogLevel() const { 61 NetLog::LogLevel CapturingNetLog::GetLogLevel() const {
61 base::AutoLock lock(lock_); 62 base::AutoLock lock(lock_);
62 return log_level_; 63 return log_level_;
63 } 64 }
64 65
65 void CapturingNetLog::AddThreadSafeObserver( 66 void CapturingNetLog::AddThreadSafeObserver(
66 NetLog::ThreadSafeObserver* observer, 67 NetLog::ThreadSafeObserver* observer,
67 NetLog::LogLevel log_level) { 68 NetLog::LogLevel log_level) {
68 NOTIMPLEMENTED() << "Not currently used by net unit tests."; 69 NOTIMPLEMENTED() << "Not currently used by net unit tests.";
69 } 70 }
70 71
71 void CapturingNetLog::SetObserverLogLevel(ThreadSafeObserver* observer, 72 void CapturingNetLog::SetObserverLogLevel(ThreadSafeObserver* observer,
72 LogLevel log_level) { 73 LogLevel log_level) {
73 NOTIMPLEMENTED() << "Not currently used by net unit tests."; 74 NOTIMPLEMENTED() << "Not currently used by net unit tests.";
74 } 75 }
75 76
76 void CapturingNetLog::RemoveThreadSafeObserver( 77 void CapturingNetLog::RemoveThreadSafeObserver(
77 NetLog::ThreadSafeObserver* observer) { 78 NetLog::ThreadSafeObserver* observer) {
78 NOTIMPLEMENTED() << "Not currently used by net unit tests."; 79 NOTIMPLEMENTED() << "Not currently used by net unit tests.";
79 } 80 }
80 81
81 CapturingBoundNetLog::CapturingBoundNetLog(const NetLog::Source& source, 82 CapturingBoundNetLog::CapturingBoundNetLog(size_t max_num_entries)
82 CapturingNetLog* net_log) 83 : capturing_net_log_(new CapturingNetLog(max_num_entries)) {
83 : source_(source), capturing_net_log_(net_log) {
84 } 84 }
85 85
86 CapturingBoundNetLog::CapturingBoundNetLog(size_t max_num_entries)
87 : capturing_net_log_(new CapturingNetLog(max_num_entries)) {}
88
89 CapturingBoundNetLog::~CapturingBoundNetLog() {} 86 CapturingBoundNetLog::~CapturingBoundNetLog() {}
90 87
91 void CapturingBoundNetLog::GetEntries( 88 void CapturingBoundNetLog::GetEntries(
92 CapturingNetLog::EntryList* entry_list) const { 89 CapturingNetLog::EntryList* entry_list) const {
93 capturing_net_log_->GetEntries(entry_list); 90 capturing_net_log_->GetEntries(entry_list);
94 } 91 }
95 92
96 void CapturingBoundNetLog::Clear() { 93 void CapturingBoundNetLog::Clear() {
97 capturing_net_log_->Clear(); 94 capturing_net_log_->Clear();
98 } 95 }
99 96
100 void CapturingBoundNetLog::SetLogLevel(NetLog::LogLevel log_level) { 97 void CapturingBoundNetLog::SetLogLevel(NetLog::LogLevel log_level) {
101 capturing_net_log_->SetLogLevel(log_level); 98 capturing_net_log_->SetLogLevel(log_level);
102 } 99 }
103 100
104 } // namespace net 101 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698