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

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

Issue 10399083: Make NetLog take in callbacks that return Values (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix net-internals Created 8 years, 7 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 #include "base/values.h"
8 9
9 namespace net { 10 namespace net {
10 11
11 CapturingNetLog::Entry::Entry(EventType type, 12 CapturingNetLog::CapturedEntry::CapturedEntry(
12 const base::TimeTicks& time, 13 EventType type,
13 Source source, 14 const base::TimeTicks& time,
14 EventPhase phase, 15 Source source,
15 EventParameters* extra_parameters) 16 EventPhase phase)
16 : type(type), time(time), source(source), phase(phase), 17 : type(type), time(time), source(source), phase(phase) {
17 extra_parameters(extra_parameters) {
18 } 18 }
19 19
20 CapturingNetLog::Entry::~Entry() {} 20 CapturingNetLog::CapturedEntry::~CapturedEntry() {}
21 21
22 CapturingNetLog::CapturingNetLog(size_t max_num_entries) 22 CapturingNetLog::CapturingNetLog(size_t max_num_entries)
23 : last_id_(0), 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(CapturedEntryList* entry_list) const {
31 base::AutoLock lock(lock_); 31 base::AutoLock lock(lock_);
32 *entry_list = entries_; 32 *entry_list = captured_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 captured_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( 45 void CapturingNetLog::OnAddEntry(const net::NetLog::Entry& entry) {
46 EventType type, 46 DCHECK(entry.source().is_valid());
47 const Source& source,
48 EventPhase phase,
49 const scoped_refptr<EventParameters>& extra_parameters) {
50 DCHECK(source.is_valid());
51 base::AutoLock lock(lock_); 47 base::AutoLock lock(lock_);
52 Entry entry(type, base::TimeTicks::Now(), source, phase, extra_parameters); 48 if (captured_entries_.size() >= max_num_entries_)
53 if (entries_.size() + 1 < max_num_entries_) 49 return;
54 entries_.push_back(entry); 50 captured_entries_.push_back(
51 CapturedEntry(entry.type(),
52 base::TimeTicks::Now(),
53 entry.source(),
54 entry.phase()));
55 } 55 }
56 56
57 uint32 CapturingNetLog::NextID() { 57 uint32 CapturingNetLog::NextID() {
58 return base::subtle::NoBarrier_AtomicIncrement(&last_id_, 1); 58 return base::subtle::NoBarrier_AtomicIncrement(&last_id_, 1);
59 } 59 }
60 60
61 NetLog::LogLevel CapturingNetLog::GetLogLevel() const { 61 NetLog::LogLevel CapturingNetLog::GetLogLevel() const {
62 base::AutoLock lock(lock_); 62 base::AutoLock lock(lock_);
63 return log_level_; 63 return log_level_;
64 } 64 }
(...skipping 16 matching lines...) Expand all
81 81
82 CapturingBoundNetLog::CapturingBoundNetLog(size_t max_num_entries) 82 CapturingBoundNetLog::CapturingBoundNetLog(size_t max_num_entries)
83 : capturing_net_log_(max_num_entries), 83 : capturing_net_log_(max_num_entries),
84 net_log_(BoundNetLog::Make(&capturing_net_log_, 84 net_log_(BoundNetLog::Make(&capturing_net_log_,
85 net::NetLog::SOURCE_NONE)) { 85 net::NetLog::SOURCE_NONE)) {
86 } 86 }
87 87
88 CapturingBoundNetLog::~CapturingBoundNetLog() {} 88 CapturingBoundNetLog::~CapturingBoundNetLog() {}
89 89
90 void CapturingBoundNetLog::GetEntries( 90 void CapturingBoundNetLog::GetEntries(
91 CapturingNetLog::EntryList* entry_list) const { 91 CapturingNetLog::CapturedEntryList* entry_list) const {
92 capturing_net_log_.GetEntries(entry_list); 92 capturing_net_log_.GetEntries(entry_list);
93 } 93 }
94 94
95 void CapturingBoundNetLog::Clear() { 95 void CapturingBoundNetLog::Clear() {
96 capturing_net_log_.Clear(); 96 capturing_net_log_.Clear();
97 } 97 }
98 98
99 void CapturingBoundNetLog::SetLogLevel(NetLog::LogLevel log_level) { 99 void CapturingBoundNetLog::SetLogLevel(NetLog::LogLevel log_level) {
100 capturing_net_log_.SetLogLevel(log_level); 100 capturing_net_log_.SetLogLevel(log_level);
101 } 101 }
102 102
103 } // namespace net 103 } // namespace net
OLDNEW
« no previous file with comments | « net/base/capturing_net_log.h ('k') | net/base/net_log.h » ('j') | net/base/net_log.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698