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

Side by Side Diff: net/proxy/proxy_resolver_js_bindings_unittest.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/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "net/base/address_list.h" 10 #include "net/base/address_list.h"
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 EXPECT_FALSE(bindings->DnsResolve("foo", &ip_address)); 228 EXPECT_FALSE(bindings->DnsResolve("foo", &ip_address));
229 EXPECT_FALSE(bindings->DnsResolve("foo", &ip_address)); 229 EXPECT_FALSE(bindings->DnsResolve("foo", &ip_address));
230 EXPECT_FALSE(bindings->DnsResolve("foo", &ip_address)); 230 EXPECT_FALSE(bindings->DnsResolve("foo", &ip_address));
231 EXPECT_EQ(4, host_resolver->count()); 231 EXPECT_EQ(4, host_resolver->count());
232 232
233 host_resolver->ResetCount(); 233 host_resolver->ResetCount();
234 234
235 // Now setup a per-request context, and try the same experiment -- we 235 // Now setup a per-request context, and try the same experiment -- we
236 // expect the underlying host resolver to receive only 1 request this time, 236 // expect the underlying host resolver to receive only 1 request this time,
237 // since it will service the others from the per-request DNS cache. 237 // since it will service the others from the per-request DNS cache.
238 HostCache cache(50, 238 const unsigned kMaxCacheEntries = 50;
239 base::TimeDelta::FromMinutes(10), 239 HostCache cache(kMaxCacheEntries);
240 base::TimeDelta::FromMinutes(10));
241 ProxyResolverRequestContext context(NULL, &cache); 240 ProxyResolverRequestContext context(NULL, &cache);
242 bindings->set_current_request_context(&context); 241 bindings->set_current_request_context(&context);
243 242
244 EXPECT_FALSE(bindings->DnsResolve("foo", &ip_address)); 243 EXPECT_FALSE(bindings->DnsResolve("foo", &ip_address));
245 EXPECT_FALSE(bindings->DnsResolve("foo", &ip_address)); 244 EXPECT_FALSE(bindings->DnsResolve("foo", &ip_address));
246 EXPECT_FALSE(bindings->DnsResolve("foo", &ip_address)); 245 EXPECT_FALSE(bindings->DnsResolve("foo", &ip_address));
247 EXPECT_FALSE(bindings->DnsResolve("foo", &ip_address)); 246 EXPECT_FALSE(bindings->DnsResolve("foo", &ip_address));
248 EXPECT_EQ(1, host_resolver->count()); 247 EXPECT_EQ(1, host_resolver->count());
249 248
250 host_resolver->ResetCount(); 249 host_resolver->ResetCount();
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 global_log.GetEntries(&global_log_entries); 352 global_log.GetEntries(&global_log_entries);
354 EXPECT_EQ(2u, global_log_entries.size()); 353 EXPECT_EQ(2u, global_log_entries.size());
355 EXPECT_TRUE(LogContainsEvent( 354 EXPECT_TRUE(LogContainsEvent(
356 global_log_entries, 1, NetLog::TYPE_PAC_JAVASCRIPT_ALERT, 355 global_log_entries, 1, NetLog::TYPE_PAC_JAVASCRIPT_ALERT,
357 NetLog::PHASE_NONE)); 356 NetLog::PHASE_NONE));
358 } 357 }
359 358
360 } // namespace 359 } // namespace
361 360
362 } // namespace net 361 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698