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

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

Issue 10546071: CapturingNetLog - remove maximum entries constructor argument. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: sync Created 8 years, 6 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_unittest.cc » ('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) 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 #include "base/values.h"
9 9
10 namespace net { 10 namespace net {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 int* value) const { 51 int* value) const {
52 if (!params.get()) 52 if (!params.get())
53 return false; 53 return false;
54 return params->GetInteger(name, value); 54 return params->GetInteger(name, value);
55 } 55 }
56 56
57 bool CapturingNetLog::CapturedEntry::GetNetErrorCode(int* value) const { 57 bool CapturingNetLog::CapturedEntry::GetNetErrorCode(int* value) const {
58 return GetIntegerValue("net_error", value); 58 return GetIntegerValue("net_error", value);
59 } 59 }
60 60
61 CapturingNetLog::CapturingNetLog(size_t max_num_entries) 61 CapturingNetLog::CapturingNetLog()
62 : last_id_(0), 62 : last_id_(0),
63 max_num_entries_(max_num_entries),
64 log_level_(LOG_ALL_BUT_BYTES) { 63 log_level_(LOG_ALL_BUT_BYTES) {
65 } 64 }
66 65
67 CapturingNetLog::~CapturingNetLog() {} 66 CapturingNetLog::~CapturingNetLog() {}
68 67
69 void CapturingNetLog::GetEntries(CapturedEntryList* entry_list) const { 68 void CapturingNetLog::GetEntries(CapturedEntryList* entry_list) const {
70 base::AutoLock lock(lock_); 69 base::AutoLock lock(lock_);
71 *entry_list = captured_entries_; 70 *entry_list = captured_entries_;
72 } 71 }
73 72
74 void CapturingNetLog::Clear() { 73 void CapturingNetLog::Clear() {
75 base::AutoLock lock(lock_); 74 base::AutoLock lock(lock_);
76 captured_entries_.clear(); 75 captured_entries_.clear();
77 } 76 }
78 77
79 void CapturingNetLog::SetLogLevel(NetLog::LogLevel log_level) { 78 void CapturingNetLog::SetLogLevel(NetLog::LogLevel log_level) {
80 base::AutoLock lock(lock_); 79 base::AutoLock lock(lock_);
81 log_level_ = log_level; 80 log_level_ = log_level;
82 } 81 }
83 82
84 void CapturingNetLog::AddEntry( 83 void CapturingNetLog::AddEntry(
85 EventType type, 84 EventType type,
86 const Source& source, 85 const Source& source,
87 EventPhase phase, 86 EventPhase phase,
88 const scoped_refptr<EventParameters>& extra_parameters) { 87 const scoped_refptr<EventParameters>& extra_parameters) {
88 // Only BoundNetLogs without a NetLog should have an invalid source.
89 DCHECK(source.is_valid()); 89 DCHECK(source.is_valid());
90 base::AutoLock lock(lock_); 90
91 if (captured_entries_.size() >= max_num_entries_)
92 return;
93 // Using Dictionaries instead of Values makes checking values a little 91 // Using Dictionaries instead of Values makes checking values a little
94 // simpler. 92 // simpler.
95 DictionaryValue* param_dict = NULL; 93 DictionaryValue* param_dict = NULL;
96 if (extra_parameters) { 94 if (extra_parameters) {
97 Value* param_value = extra_parameters->ToValue(); 95 Value* param_value = extra_parameters->ToValue();
98 if (param_value && !param_value->GetAsDictionary(&param_dict)) 96 if (param_value && !param_value->GetAsDictionary(&param_dict))
99 delete param_value; 97 delete param_value;
100 } 98 }
99
100 // Only need to acquire the lock when accessing class variables.
101 base::AutoLock lock(lock_);
101 captured_entries_.push_back( 102 captured_entries_.push_back(
102 CapturedEntry(type, 103 CapturedEntry(type,
103 base::TimeTicks::Now(), 104 base::TimeTicks::Now(),
104 source, 105 source,
105 phase, 106 phase,
106 scoped_ptr<DictionaryValue>(param_dict))); 107 scoped_ptr<DictionaryValue>(param_dict)));
107 } 108 }
108 109
109 uint32 CapturingNetLog::NextID() { 110 uint32 CapturingNetLog::NextID() {
110 return base::subtle::NoBarrier_AtomicIncrement(&last_id_, 1); 111 return base::subtle::NoBarrier_AtomicIncrement(&last_id_, 1);
(...skipping 13 matching lines...) Expand all
124 void CapturingNetLog::SetObserverLogLevel(ThreadSafeObserver* observer, 125 void CapturingNetLog::SetObserverLogLevel(ThreadSafeObserver* observer,
125 LogLevel log_level) { 126 LogLevel log_level) {
126 NOTIMPLEMENTED() << "Not currently used by net unit tests."; 127 NOTIMPLEMENTED() << "Not currently used by net unit tests.";
127 } 128 }
128 129
129 void CapturingNetLog::RemoveThreadSafeObserver( 130 void CapturingNetLog::RemoveThreadSafeObserver(
130 NetLog::ThreadSafeObserver* observer) { 131 NetLog::ThreadSafeObserver* observer) {
131 NOTIMPLEMENTED() << "Not currently used by net unit tests."; 132 NOTIMPLEMENTED() << "Not currently used by net unit tests.";
132 } 133 }
133 134
134 CapturingBoundNetLog::CapturingBoundNetLog(size_t max_num_entries) 135 CapturingBoundNetLog::CapturingBoundNetLog()
135 : capturing_net_log_(max_num_entries), 136 : net_log_(BoundNetLog::Make(&capturing_net_log_,
136 net_log_(BoundNetLog::Make(&capturing_net_log_,
137 net::NetLog::SOURCE_NONE)) { 137 net::NetLog::SOURCE_NONE)) {
138 } 138 }
139 139
140 CapturingBoundNetLog::~CapturingBoundNetLog() {} 140 CapturingBoundNetLog::~CapturingBoundNetLog() {}
141 141
142 void CapturingBoundNetLog::GetEntries( 142 void CapturingBoundNetLog::GetEntries(
143 CapturingNetLog::CapturedEntryList* entry_list) const { 143 CapturingNetLog::CapturedEntryList* entry_list) const {
144 capturing_net_log_.GetEntries(entry_list); 144 capturing_net_log_.GetEntries(entry_list);
145 } 145 }
146 146
147 void CapturingBoundNetLog::Clear() { 147 void CapturingBoundNetLog::Clear() {
148 capturing_net_log_.Clear(); 148 capturing_net_log_.Clear();
149 } 149 }
150 150
151 void CapturingBoundNetLog::SetLogLevel(NetLog::LogLevel log_level) { 151 void CapturingBoundNetLog::SetLogLevel(NetLog::LogLevel log_level) {
152 capturing_net_log_.SetLogLevel(log_level); 152 capturing_net_log_.SetLogLevel(log_level);
153 } 153 }
154 154
155 } // namespace net 155 } // namespace net
OLDNEW
« no previous file with comments | « net/base/capturing_net_log.h ('k') | net/base/net_log_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698