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

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

Issue 1556018: Add support for attaching custom parameters to NetLog events. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Address willchan's comments Created 10 years, 8 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/host_resolver_impl.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/host_resolver_impl.h" 5 #include "net/base/host_resolver_impl.h"
6 #include "net/base/net_log.h" 6 #include "net/base/net_log.h"
7 7
8 #include <cmath> 8 #include <cmath>
9 #include <deque> 9 #include <deque>
10 10
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 156
157 //----------------------------------------------------------------------------- 157 //-----------------------------------------------------------------------------
158 158
159 // Threadsafe log. 159 // Threadsafe log.
160 class HostResolverImpl::RequestsTrace 160 class HostResolverImpl::RequestsTrace
161 : public base::RefCountedThreadSafe<HostResolverImpl::RequestsTrace> { 161 : public base::RefCountedThreadSafe<HostResolverImpl::RequestsTrace> {
162 public: 162 public:
163 RequestsTrace() {} 163 RequestsTrace() {}
164 164
165 void Add(const std::string& msg) { 165 void Add(const std::string& msg) {
166 NetLog::Entry entry; 166 CapturingNetLog::Entry entry(NetLog::TYPE_TODO_STRING,
167 entry.type = NetLog::Entry::TYPE_STRING; 167 base::TimeTicks::Now(),
168 entry.time = base::TimeTicks::Now(); 168 NetLog::Source(),
169 entry.string = msg; 169 NetLog::PHASE_NONE,
170 170 new NetLogStringParameter(msg));
171 AutoLock l(lock_); 171 AutoLock l(lock_);
172 entries_.push_back(entry); 172 entries_.push_back(entry);
173 } 173 }
174 174
175 void Get(std::vector<NetLog::Entry>* entries) { 175 void Get(CapturingNetLog::EntryList* entries) {
176 AutoLock l(lock_); 176 AutoLock l(lock_);
177 *entries = entries_; 177 *entries = entries_;
178 } 178 }
179 179
180 void Clear() { 180 void Clear() {
181 AutoLock l(lock_); 181 AutoLock l(lock_);
182 entries_.clear(); 182 entries_.clear();
183 } 183 }
184 184
185 private: 185 private:
186 Lock lock_; 186 Lock lock_;
187 std::vector<NetLog::Entry> entries_; 187 CapturingNetLog::EntryList entries_;
188 }; 188 };
189 189
190 //----------------------------------------------------------------------------- 190 //-----------------------------------------------------------------------------
191 191
192 // This class represents a request to the worker pool for a "getaddrinfo()" 192 // This class represents a request to the worker pool for a "getaddrinfo()"
193 // call. 193 // call.
194 class HostResolverImpl::Job 194 class HostResolverImpl::Job
195 : public base::RefCountedThreadSafe<HostResolverImpl::Job> { 195 : public base::RefCountedThreadSafe<HostResolverImpl::Job> {
196 public: 196 public:
197 Job(int id, HostResolverImpl* resolver, const Key& key, 197 Job(int id, HostResolverImpl* resolver, const Key& key,
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 905
906 requests_trace_->Add(StringPrintf( 906 requests_trace_->Add(StringPrintf(
907 "Number of queued requests: %d", static_cast<int>(total))); 907 "Number of queued requests: %d", static_cast<int>(total)));
908 } 908 }
909 } 909 }
910 910
911 bool HostResolverImpl::IsRequestsTracingEnabled() const { 911 bool HostResolverImpl::IsRequestsTracingEnabled() const {
912 return !!requests_trace_; // Cast to bool. 912 return !!requests_trace_; // Cast to bool.
913 } 913 }
914 914
915 bool HostResolverImpl::GetRequestsTrace(std::vector<NetLog::Entry>* entries) { 915 bool HostResolverImpl::GetRequestsTrace(CapturingNetLog::EntryList* entries) {
916 if (!requests_trace_) 916 if (!requests_trace_)
917 return false; 917 return false;
918 requests_trace_->Get(entries); 918 requests_trace_->Get(entries);
919 return true; 919 return true;
920 } 920 }
921 921
922 void HostResolverImpl::SetPoolConstraints(JobPoolIndex pool_index, 922 void HostResolverImpl::SetPoolConstraints(JobPoolIndex pool_index,
923 size_t max_outstanding_jobs, 923 size_t max_outstanding_jobs,
924 size_t max_pending_requests) { 924 size_t max_pending_requests) {
925 CHECK_GE(pool_index, 0); 925 CHECK_GE(pool_index, 0);
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1185 if (r == req) 1185 if (r == req)
1186 return error; 1186 return error;
1187 1187
1188 r->OnComplete(error, AddressList()); 1188 r->OnComplete(error, AddressList());
1189 } 1189 }
1190 1190
1191 return ERR_IO_PENDING; 1191 return ERR_IO_PENDING;
1192 } 1192 }
1193 1193
1194 } // namespace net 1194 } // namespace net
OLDNEW
« no previous file with comments | « net/base/host_resolver_impl.h ('k') | net/base/net_log.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698