| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 namespace net { | 7 namespace net { |
| 8 | 8 |
| 9 CapturingNetLog::Entry::Entry(EventType type, | 9 CapturingNetLog::Entry::Entry(EventType type, |
| 10 const base::TimeTicks& time, | 10 const base::TimeTicks& time, |
| 11 Source source, | 11 Source source, |
| 12 EventPhase phase, | 12 EventPhase phase, |
| 13 EventParameters* extra_parameters) | 13 EventParameters* extra_parameters) |
| 14 : type(type), time(time), source(source), phase(phase), | 14 : type(type), time(time), source(source), phase(phase), |
| 15 extra_parameters(extra_parameters) { | 15 extra_parameters(extra_parameters) { |
| 16 } | 16 } |
| 17 | 17 |
| 18 CapturingNetLog::Entry::~Entry() {} | 18 CapturingNetLog::Entry::~Entry() {} |
| 19 | 19 |
| 20 CapturingNetLog::CapturingNetLog(size_t max_num_entries) | 20 CapturingNetLog::CapturingNetLog(size_t max_num_entries) |
| 21 : last_id_(-1), | 21 : last_id_(-1), max_num_entries_(max_num_entries) { |
| 22 max_num_entries_(max_num_entries), | |
| 23 log_level_(LOG_ALL_BUT_BYTES) { | |
| 24 } | 22 } |
| 25 | 23 |
| 26 CapturingNetLog::~CapturingNetLog() {} | 24 CapturingNetLog::~CapturingNetLog() {} |
| 27 | 25 |
| 28 void CapturingNetLog::AddEntry(EventType type, | 26 void CapturingNetLog::AddEntry(EventType type, |
| 29 const base::TimeTicks& time, | 27 const base::TimeTicks& time, |
| 30 const Source& source, | 28 const Source& source, |
| 31 EventPhase phase, | 29 EventPhase phase, |
| 32 EventParameters* extra_parameters) { | 30 EventParameters* extra_parameters) { |
| 33 AutoLock lock(lock_); | 31 AutoLock lock(lock_); |
| 34 Entry entry(type, time, source, phase, extra_parameters); | 32 Entry entry(type, time, source, phase, extra_parameters); |
| 35 if (entries_.size() + 1 < max_num_entries_) | 33 if (entries_.size() + 1 < max_num_entries_) |
| 36 entries_.push_back(entry); | 34 entries_.push_back(entry); |
| 37 } | 35 } |
| 38 | 36 |
| 39 uint32 CapturingNetLog::NextID() { | 37 uint32 CapturingNetLog::NextID() { |
| 40 return base::subtle::NoBarrier_AtomicIncrement(&last_id_, 1); | 38 return base::subtle::NoBarrier_AtomicIncrement(&last_id_, 1); |
| 41 } | 39 } |
| 42 | 40 |
| 43 NetLog::LogLevel CapturingNetLog::GetLogLevel() const { | 41 NetLog::LogLevel CapturingNetLog::GetLogLevel() const { |
| 44 AutoLock lock(lock_); | 42 return LOG_ALL_BUT_BYTES; |
| 45 return log_level_; | |
| 46 } | 43 } |
| 47 | 44 |
| 48 void CapturingNetLog::GetEntries(EntryList* entry_list) const { | 45 void CapturingNetLog::GetEntries(EntryList* entry_list) const { |
| 49 AutoLock lock(lock_); | 46 AutoLock lock(lock_); |
| 50 *entry_list = entries_; | 47 *entry_list = entries_; |
| 51 } | 48 } |
| 52 | 49 |
| 53 void CapturingNetLog::Clear() { | 50 void CapturingNetLog::Clear() { |
| 54 AutoLock lock(lock_); | 51 AutoLock lock(lock_); |
| 55 entries_.clear(); | 52 entries_.clear(); |
| 56 } | 53 } |
| 57 | 54 |
| 58 void CapturingNetLog::SetLogLevel(NetLog::LogLevel log_level) { | |
| 59 AutoLock lock(lock_); | |
| 60 log_level_ = log_level; | |
| 61 } | |
| 62 | |
| 63 CapturingBoundNetLog::CapturingBoundNetLog(const NetLog::Source& source, | 55 CapturingBoundNetLog::CapturingBoundNetLog(const NetLog::Source& source, |
| 64 CapturingNetLog* net_log) | 56 CapturingNetLog* net_log) |
| 65 : source_(source), capturing_net_log_(net_log) { | 57 : source_(source), capturing_net_log_(net_log) { |
| 66 } | 58 } |
| 67 | 59 |
| 68 CapturingBoundNetLog::CapturingBoundNetLog(size_t max_num_entries) | 60 CapturingBoundNetLog::CapturingBoundNetLog(size_t max_num_entries) |
| 69 : capturing_net_log_(new CapturingNetLog(max_num_entries)) {} | 61 : capturing_net_log_(new CapturingNetLog(max_num_entries)) {} |
| 70 | 62 |
| 71 CapturingBoundNetLog::~CapturingBoundNetLog() {} | 63 CapturingBoundNetLog::~CapturingBoundNetLog() {} |
| 72 | 64 |
| 73 void CapturingBoundNetLog::GetEntries( | 65 void CapturingBoundNetLog::GetEntries( |
| 74 CapturingNetLog::EntryList* entry_list) const { | 66 CapturingNetLog::EntryList* entry_list) const { |
| 75 capturing_net_log_->GetEntries(entry_list); | 67 capturing_net_log_->GetEntries(entry_list); |
| 76 } | 68 } |
| 77 | 69 |
| 78 void CapturingBoundNetLog::Clear() { | 70 void CapturingBoundNetLog::Clear() { |
| 79 capturing_net_log_->Clear(); | 71 capturing_net_log_->Clear(); |
| 80 } | 72 } |
| 81 | 73 |
| 82 void CapturingBoundNetLog::SetLogLevel(NetLog::LogLevel log_level) { | |
| 83 capturing_net_log_->SetLogLevel(log_level); | |
| 84 } | |
| 85 | |
| 86 } // namespace net | 74 } // namespace net |
| OLD | NEW |