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

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

Issue 4067002: First pass at adding http/backend cache to NetLog (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Minor lint-ish fixes Created 9 years, 11 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 | « net/base/capturing_net_log.h ('k') | net/base/net_log.h » ('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) 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), max_num_entries_(max_num_entries) { 21 : last_id_(-1),
22 max_num_entries_(max_num_entries),
23 log_level_(LOG_ALL_BUT_BYTES) {
22 } 24 }
23 25
24 CapturingNetLog::~CapturingNetLog() {} 26 CapturingNetLog::~CapturingNetLog() {}
25 27
26 void CapturingNetLog::AddEntry(EventType type, 28 void CapturingNetLog::AddEntry(EventType type,
27 const base::TimeTicks& time, 29 const base::TimeTicks& time,
28 const Source& source, 30 const Source& source,
29 EventPhase phase, 31 EventPhase phase,
30 EventParameters* extra_parameters) { 32 EventParameters* extra_parameters) {
31 AutoLock lock(lock_); 33 AutoLock lock(lock_);
32 Entry entry(type, time, source, phase, extra_parameters); 34 Entry entry(type, time, source, phase, extra_parameters);
33 if (entries_.size() + 1 < max_num_entries_) 35 if (entries_.size() + 1 < max_num_entries_)
34 entries_.push_back(entry); 36 entries_.push_back(entry);
35 } 37 }
36 38
37 uint32 CapturingNetLog::NextID() { 39 uint32 CapturingNetLog::NextID() {
38 return base::subtle::NoBarrier_AtomicIncrement(&last_id_, 1); 40 return base::subtle::NoBarrier_AtomicIncrement(&last_id_, 1);
39 } 41 }
40 42
41 NetLog::LogLevel CapturingNetLog::GetLogLevel() const { 43 NetLog::LogLevel CapturingNetLog::GetLogLevel() const {
42 return LOG_ALL_BUT_BYTES; 44 return log_level_;
eroman 2011/01/05 19:17:48 Should hold |lock_| when reading this.
mmenke 2011/01/05 19:20:33 Indeed I should be. Done.
43 } 45 }
44 46
45 void CapturingNetLog::GetEntries(EntryList* entry_list) const { 47 void CapturingNetLog::GetEntries(EntryList* entry_list) const {
46 AutoLock lock(lock_); 48 AutoLock lock(lock_);
47 *entry_list = entries_; 49 *entry_list = entries_;
48 } 50 }
49 51
50 void CapturingNetLog::Clear() { 52 void CapturingNetLog::Clear() {
51 AutoLock lock(lock_); 53 AutoLock lock(lock_);
52 entries_.clear(); 54 entries_.clear();
53 } 55 }
54 56
57 void CapturingNetLog::SetLogLevel(NetLog::LogLevel log_level) {
58 AutoLock lock(lock_);
59 log_level_ = log_level;
60 }
61
55 CapturingBoundNetLog::CapturingBoundNetLog(const NetLog::Source& source, 62 CapturingBoundNetLog::CapturingBoundNetLog(const NetLog::Source& source,
56 CapturingNetLog* net_log) 63 CapturingNetLog* net_log)
57 : source_(source), capturing_net_log_(net_log) { 64 : source_(source), capturing_net_log_(net_log) {
58 } 65 }
59 66
60 CapturingBoundNetLog::CapturingBoundNetLog(size_t max_num_entries) 67 CapturingBoundNetLog::CapturingBoundNetLog(size_t max_num_entries)
61 : capturing_net_log_(new CapturingNetLog(max_num_entries)) {} 68 : capturing_net_log_(new CapturingNetLog(max_num_entries)) {}
62 69
63 CapturingBoundNetLog::~CapturingBoundNetLog() {} 70 CapturingBoundNetLog::~CapturingBoundNetLog() {}
64 71
65 void CapturingBoundNetLog::GetEntries( 72 void CapturingBoundNetLog::GetEntries(
66 CapturingNetLog::EntryList* entry_list) const { 73 CapturingNetLog::EntryList* entry_list) const {
67 capturing_net_log_->GetEntries(entry_list); 74 capturing_net_log_->GetEntries(entry_list);
68 } 75 }
69 76
70 void CapturingBoundNetLog::Clear() { 77 void CapturingBoundNetLog::Clear() {
71 capturing_net_log_->Clear(); 78 capturing_net_log_->Clear();
72 } 79 }
73 80
81 void CapturingBoundNetLog::SetLogLevel(NetLog::LogLevel log_level) {
82 capturing_net_log_->SetLogLevel(log_level);
83 }
84
74 } // namespace net 85 } // namespace net
OLDNEW
« no previous file with comments | « net/base/capturing_net_log.h ('k') | net/base/net_log.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698