| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |