Chromium Code Reviews| 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, |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 : next_id_(0), max_num_entries_(max_num_entries) { | 21 : next_id_(0), max_num_entries_(max_num_entries) { |
| 22 } | 22 } |
| 23 | 23 |
| 24 CapturingNetLog::~CapturingNetLog() {} | 24 CapturingNetLog::~CapturingNetLog() {} |
| 25 | 25 |
| 26 void CapturingNetLog::AddEntry(EventType type, | 26 void CapturingNetLog::AddEntry(EventType type, |
| 27 const base::TimeTicks& time, | 27 const base::TimeTicks& time, |
| 28 const Source& source, | 28 const Source& source, |
| 29 EventPhase phase, | 29 EventPhase phase, |
| 30 EventParameters* extra_parameters) { | 30 EventParameters* extra_parameters) { |
| 31 AutoLock lock(lock_); | |
| 31 Entry entry(type, time, source, phase, extra_parameters); | 32 Entry entry(type, time, source, phase, extra_parameters); |
| 32 if (entries_.size() + 1 < max_num_entries_) | 33 if (entries_.size() + 1 < max_num_entries_) |
| 33 entries_.push_back(entry); | 34 entries_.push_back(entry); |
| 34 } | 35 } |
| 35 | 36 |
| 36 uint32 CapturingNetLog::NextID() { | 37 uint32 CapturingNetLog::NextID() { |
| 37 return next_id_++; | 38 return base::subtle::NoBarrier_AtomicIncrement(&next_id_, 1)-1; |
|
eroman
2010/11/18 18:04:03
I suggest doing what you did in the other file for
| |
| 39 } | |
| 40 | |
| 41 void CapturingNetLog::GetEntries(EntryList* entry_list) const { | |
| 42 AutoLock lock(lock_); | |
| 43 *entry_list = entries_; | |
| 38 } | 44 } |
| 39 | 45 |
| 40 void CapturingNetLog::Clear() { | 46 void CapturingNetLog::Clear() { |
| 47 AutoLock lock(lock_); | |
| 41 entries_.clear(); | 48 entries_.clear(); |
| 42 } | 49 } |
| 43 | 50 |
| 44 CapturingBoundNetLog::CapturingBoundNetLog(const NetLog::Source& source, | 51 CapturingBoundNetLog::CapturingBoundNetLog( |
| 45 CapturingNetLog* net_log) | 52 const NetLog::Source& source, |
| 53 scoped_refptr<CapturingNetLog>& net_log) | |
| 46 : source_(source), capturing_net_log_(net_log) { | 54 : source_(source), capturing_net_log_(net_log) { |
| 47 } | 55 } |
| 48 | 56 |
| 49 CapturingBoundNetLog::CapturingBoundNetLog(size_t max_num_entries) | 57 CapturingBoundNetLog::CapturingBoundNetLog(size_t max_num_entries) |
| 50 : capturing_net_log_(new CapturingNetLog(max_num_entries)) {} | 58 : capturing_net_log_(new CapturingNetLog(max_num_entries)) {} |
| 51 | 59 |
| 52 CapturingBoundNetLog::~CapturingBoundNetLog() {} | 60 CapturingBoundNetLog::~CapturingBoundNetLog() {} |
| 53 | 61 |
| 62 void CapturingBoundNetLog::GetEntries( | |
| 63 CapturingNetLog::EntryList* entry_list) const { | |
| 64 capturing_net_log_->GetEntries(entry_list); | |
| 65 } | |
| 66 | |
| 54 void CapturingBoundNetLog::Clear() { | 67 void CapturingBoundNetLog::Clear() { |
| 55 capturing_net_log_->Clear(); | 68 capturing_net_log_->Clear(); |
| 56 } | 69 } |
| 57 | 70 |
| 58 void CapturingBoundNetLog::AppendTo(const BoundNetLog& net_log) const { | 71 void CapturingBoundNetLog::AppendTo(const BoundNetLog& net_log) const { |
|
eroman
2010/11/18 18:04:03
See earlier comment -- i don't think this is neede
| |
| 59 for (size_t i = 0; i < entries().size(); ++i) { | 72 CapturingNetLog::EntryList entries; |
| 60 const CapturingNetLog::Entry& entry = entries()[i]; | 73 GetEntries(&entries); |
| 74 for (size_t i = 0; i < entries.size(); ++i) { | |
| 75 const CapturingNetLog::Entry& entry = entries[i]; | |
| 61 net_log.AddEntryWithTime(entry.type, entry.time, entry.phase, | 76 net_log.AddEntryWithTime(entry.type, entry.time, entry.phase, |
| 62 entry.extra_parameters); | 77 entry.extra_parameters); |
| 63 } | 78 } |
| 64 } | 79 } |
| 65 | 80 |
| 66 } // namespace net | 81 } // namespace net |
| OLD | NEW |