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

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

Issue 9197009: Adds custom ttl argument to HostCache::Set. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 8 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
11 #include "net/base/address_list.h" 11 #include "net/base/address_list.h"
12 #include "net/base/host_cache.h" 12 #include "net/base/host_cache.h"
13 #include "net/base/host_resolver.h" 13 #include "net/base/host_resolver.h"
14 #include "net/base/net_errors.h" 14 #include "net/base/net_errors.h"
15 #include "net/base/net_log.h" 15 #include "net/base/net_log.h"
16 #include "net/base/net_util.h" 16 #include "net/base/net_util.h"
17 #include "net/base/sys_addrinfo.h" 17 #include "net/base/sys_addrinfo.h"
18 #include "net/proxy/proxy_resolver_error_observer.h" 18 #include "net/proxy/proxy_resolver_error_observer.h"
19 #include "net/proxy/proxy_resolver_request_context.h" 19 #include "net/proxy/proxy_resolver_request_context.h"
20 #include "net/proxy/sync_host_resolver.h" 20 #include "net/proxy/sync_host_resolver.h"
21 21
22 namespace net { 22 namespace net {
23 23
24 namespace { 24 namespace {
25 25
26 // TTL for the per-request DNS cache. Applies to both successful and failed
27 // DNS resolutions.
28 const base::TimeDelta kCacheEntryTTL = base::TimeDelta::FromMinutes(5);
29
26 // Event parameters for a PAC error message (line number + message). 30 // Event parameters for a PAC error message (line number + message).
27 class ErrorNetlogParams : public NetLog::EventParameters { 31 class ErrorNetlogParams : public NetLog::EventParameters {
28 public: 32 public:
29 ErrorNetlogParams(int line_number, 33 ErrorNetlogParams(int line_number,
30 const string16& message) 34 const string16& message)
31 : line_number_(line_number), 35 : line_number_(line_number),
32 message_(message) { 36 message_(message) {
33 } 37 }
34 38
35 virtual Value* ToValue() const OVERRIDE { 39 virtual Value* ToValue() const OVERRIDE {
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 return entry->error; 260 return entry->error;
257 } 261 }
258 } 262 }
259 263
260 // Otherwise ask the host resolver. 264 // Otherwise ask the host resolver.
261 int result = host_resolver_->Resolve(info, address_list); 265 int result = host_resolver_->Resolve(info, address_list);
262 266
263 // Save the result back to the per-request DNS cache. 267 // Save the result back to the per-request DNS cache.
264 if (host_cache) { 268 if (host_cache) {
265 host_cache->Set(cache_key, result, *address_list, 269 host_cache->Set(cache_key, result, *address_list,
266 base::TimeTicks::Now()); 270 base::TimeTicks::Now(),
271 kCacheEntryTTL);
267 } 272 }
268 273
269 return result; 274 return result;
270 } 275 }
271 276
272 void LogEventToCurrentRequest( 277 void LogEventToCurrentRequest(
273 NetLog::EventPhase phase, 278 NetLog::EventPhase phase,
274 NetLog::EventType type, 279 NetLog::EventType type,
275 scoped_refptr<NetLog::EventParameters> params) { 280 scoped_refptr<NetLog::EventParameters> params) {
276 if (current_request_context() && current_request_context()->net_log) 281 if (current_request_context() && current_request_context()->net_log)
(...skipping 26 matching lines...) Expand all
303 308
304 // static 309 // static
305 ProxyResolverJSBindings* ProxyResolverJSBindings::CreateDefault( 310 ProxyResolverJSBindings* ProxyResolverJSBindings::CreateDefault(
306 SyncHostResolver* host_resolver, 311 SyncHostResolver* host_resolver,
307 NetLog* net_log, 312 NetLog* net_log,
308 ProxyResolverErrorObserver* error_observer) { 313 ProxyResolverErrorObserver* error_observer) {
309 return new DefaultJSBindings(host_resolver, net_log, error_observer); 314 return new DefaultJSBindings(host_resolver, net_log, error_observer);
310 } 315 }
311 316
312 } // namespace net 317 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698