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

Side by Side Diff: net/proxy/proxy_resolver_v8.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 <algorithm> 5 #include <algorithm>
6 #include <cstdio> 6 #include <cstdio>
7 7
8 #include "net/proxy/proxy_resolver_v8.h" 8 #include "net/proxy/proxy_resolver_v8.h"
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 const BoundNetLog& net_log) { 735 const BoundNetLog& net_log) {
736 // If the V8 instance has not been initialized (either because 736 // If the V8 instance has not been initialized (either because
737 // SetPacScript() wasn't called yet, or because it failed. 737 // SetPacScript() wasn't called yet, or because it failed.
738 if (!context_.get()) 738 if (!context_.get())
739 return ERR_FAILED; 739 return ERR_FAILED;
740 740
741 // Associate some short-lived context with this request. This context will be 741 // Associate some short-lived context with this request. This context will be
742 // available to any of the javascript "bindings" that are subsequently invoked 742 // available to any of the javascript "bindings" that are subsequently invoked
743 // from the javascript. 743 // from the javascript.
744 // 744 //
745 // In particular, we create a HostCache that is aggressive about caching 745 // In particular, we create a HostCache to aggressively cache failed DNS
746 // failed DNS resolves. 746 // resolves.
747 HostCache host_cache( 747 const unsigned kMaxCacheEntries = 50;
748 50, 748 HostCache host_cache(kMaxCacheEntries);
749 base::TimeDelta::FromMinutes(5),
750 base::TimeDelta::FromMinutes(5));
751 749
752 ProxyResolverRequestContext request_context(&net_log, &host_cache); 750 ProxyResolverRequestContext request_context(&net_log, &host_cache);
753 751
754 // Otherwise call into V8. 752 // Otherwise call into V8.
755 context_->SetCurrentRequestContext(&request_context); 753 context_->SetCurrentRequestContext(&request_context);
756 int rv = context_->ResolveProxy(query_url, results); 754 int rv = context_->ResolveProxy(query_url, results);
757 context_->SetCurrentRequestContext(NULL); 755 context_->SetCurrentRequestContext(NULL);
758 756
759 return rv; 757 return rv;
760 } 758 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 795
798 // Try parsing the PAC script. 796 // Try parsing the PAC script.
799 scoped_ptr<Context> context(new Context(js_bindings_.get())); 797 scoped_ptr<Context> context(new Context(js_bindings_.get()));
800 int rv = context->InitV8(script_data); 798 int rv = context->InitV8(script_data);
801 if (rv == OK) 799 if (rv == OK)
802 context_.reset(context.release()); 800 context_.reset(context.release());
803 return rv; 801 return rv;
804 } 802 }
805 803
806 } // namespace net 804 } // namespace net
OLDNEW
« net/base/host_resolver_impl.cc ('K') | « net/proxy/proxy_resolver_js_bindings_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698