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

Side by Side Diff: net/proxy/proxy_resolver_js_bindings.cc

Issue 9121055: Add a source to V8 proxy resolver-initiated DNS requests, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Update year Created 8 years, 10 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 | « no previous file | net/proxy/proxy_resolver_js_bindings_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/proxy/proxy_resolver_js_bindings.h" 5 #include "net/proxy/proxy_resolver_js_bindings.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 const HostCache::Entry* entry = 255 const HostCache::Entry* entry =
256 host_cache->Lookup(cache_key, base::TimeTicks::Now()); 256 host_cache->Lookup(cache_key, base::TimeTicks::Now());
257 if (entry) { 257 if (entry) {
258 if (entry->error == OK) 258 if (entry->error == OK)
259 *address_list = entry->addrlist; 259 *address_list = entry->addrlist;
260 return entry->error; 260 return entry->error;
261 } 261 }
262 } 262 }
263 263
264 // Otherwise ask the host resolver. 264 // Otherwise ask the host resolver.
265 int result = host_resolver_->Resolve(info, address_list); 265 const BoundNetLog* net_log = GetNetLogForCurrentRequest();
266 int result = host_resolver_->Resolve(info,
267 address_list,
268 net_log ? *net_log : BoundNetLog());
266 269
267 // Save the result back to the per-request DNS cache. 270 // Save the result back to the per-request DNS cache.
268 if (host_cache) { 271 if (host_cache) {
269 host_cache->Set(cache_key, result, *address_list, 272 host_cache->Set(cache_key, result, *address_list,
270 base::TimeTicks::Now(), 273 base::TimeTicks::Now(),
271 base::TimeDelta::FromSeconds(kCacheEntryTTLSeconds)); 274 base::TimeDelta::FromSeconds(kCacheEntryTTLSeconds));
272 } 275 }
273 276
274 return result; 277 return result;
275 } 278 }
276 279
280 // May return NULL.
281 const BoundNetLog* GetNetLogForCurrentRequest() {
282 if (!current_request_context())
283 return NULL;
284 return current_request_context()->net_log;
285 }
286
277 void LogEventToCurrentRequest( 287 void LogEventToCurrentRequest(
278 NetLog::EventPhase phase, 288 NetLog::EventPhase phase,
279 NetLog::EventType type, 289 NetLog::EventType type,
280 scoped_refptr<NetLog::EventParameters> params) { 290 scoped_refptr<NetLog::EventParameters> params) {
281 if (current_request_context() && current_request_context()->net_log) 291 const BoundNetLog* net_log = GetNetLogForCurrentRequest();
282 current_request_context()->net_log->AddEntry(type, phase, params); 292 if (net_log)
293 net_log->AddEntry(type, phase, params);
283 } 294 }
284 295
285 void LogEventToCurrentRequestAndGlobally( 296 void LogEventToCurrentRequestAndGlobally(
286 NetLog::EventType type, 297 NetLog::EventType type,
287 scoped_refptr<NetLog::EventParameters> params) { 298 scoped_refptr<NetLog::EventParameters> params) {
288 LogEventToCurrentRequest(NetLog::PHASE_NONE, type, params); 299 LogEventToCurrentRequest(NetLog::PHASE_NONE, type, params);
289 300
290 // Emit to the global NetLog event stream. 301 // Emit to the global NetLog event stream.
291 if (net_log_) { 302 if (net_log_) {
292 net_log_->AddEntry( 303 net_log_->AddEntry(
(...skipping 15 matching lines...) Expand all
308 319
309 // static 320 // static
310 ProxyResolverJSBindings* ProxyResolverJSBindings::CreateDefault( 321 ProxyResolverJSBindings* ProxyResolverJSBindings::CreateDefault(
311 SyncHostResolver* host_resolver, 322 SyncHostResolver* host_resolver,
312 NetLog* net_log, 323 NetLog* net_log,
313 ProxyResolverErrorObserver* error_observer) { 324 ProxyResolverErrorObserver* error_observer) {
314 return new DefaultJSBindings(host_resolver, net_log, error_observer); 325 return new DefaultJSBindings(host_resolver, net_log, error_observer);
315 } 326 }
316 327
317 } // namespace net 328 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/proxy/proxy_resolver_js_bindings_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698