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

Side by Side Diff: chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.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) 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 "chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.h" 5 #include "chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 const std::string& hostname, 45 const std::string& hostname,
46 const std::string& ip_literal, 46 const std::string& ip_literal,
47 int net_error, 47 int net_error,
48 int expire_days_from_now) { 48 int expire_days_from_now) {
49 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); 49 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO));
50 net::URLRequestContext* context = context_getter->GetURLRequestContext(); 50 net::URLRequestContext* context = context_getter->GetURLRequestContext();
51 net::HostCache* cache = context->host_resolver()->GetHostCache(); 51 net::HostCache* cache = context->host_resolver()->GetHostCache();
52 ASSERT_TRUE(cache); 52 ASSERT_TRUE(cache);
53 53
54 net::HostCache::Key key(hostname, net::ADDRESS_FAMILY_UNSPECIFIED, 0); 54 net::HostCache::Key key(hostname, net::ADDRESS_FAMILY_UNSPECIFIED, 0);
55 base::TimeTicks expires = 55 base::TimeDelta ttl = base::TimeDelta::FromDays(expire_days_from_now);
56 base::TimeTicks::Now() + base::TimeDelta::FromDays(expire_days_from_now);
57 56
58 net::AddressList address_list; 57 net::AddressList address_list;
59 if (net_error == net::OK) { 58 if (net_error == net::OK) {
60 // If |net_error| does not indicate an error, convert |ip_literal| to a 59 // If |net_error| does not indicate an error, convert |ip_literal| to a
61 // net::AddressList, so it can be used with the cache. 60 // net::AddressList, so it can be used with the cache.
62 int rv = net::SystemHostResolverProc(ip_literal, 61 int rv = net::SystemHostResolverProc(ip_literal,
63 net::ADDRESS_FAMILY_UNSPECIFIED, 62 net::ADDRESS_FAMILY_UNSPECIFIED,
64 0, 63 0,
65 &address_list, 64 &address_list,
66 NULL); 65 NULL);
67 ASSERT_EQ(net::OK, rv); 66 ASSERT_EQ(net::OK, rv);
68 } else { 67 } else {
69 ASSERT_TRUE(ip_literal.empty()); 68 ASSERT_TRUE(ip_literal.empty());
70 } 69 }
71 70
72 // Add entry to the cache. 71 // Add entry to the cache.
73 cache->Set(net::HostCache::Key(hostname, net::ADDRESS_FAMILY_UNSPECIFIED, 0), 72 cache->Set(net::HostCache::Key(hostname, net::ADDRESS_FAMILY_UNSPECIFIED, 0),
74 net_error, 73 net_error,
75 address_list, 74 address_list,
76 expires); 75 base::TimeTicks::Now(),
76 ttl);
77 } 77 }
78 78
79 // Called on IO thread. Adds an entry to the list of known HTTP pipelining 79 // Called on IO thread. Adds an entry to the list of known HTTP pipelining
80 // hosts. 80 // hosts.
81 void AddDummyHttpPipelineFeedbackOnIOThread( 81 void AddDummyHttpPipelineFeedbackOnIOThread(
82 net::URLRequestContextGetter* context_getter, 82 net::URLRequestContextGetter* context_getter,
83 const std::string& hostname, 83 const std::string& hostname,
84 int port, 84 int port,
85 net::HttpPipelinedHostCapability capability) { 85 net::HttpPipelinedHostCapability capability) {
86 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); 86 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO));
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 GURL url_loader = test_server()->GetURL(replacement_path); 347 GURL url_loader = test_server()->GetURL(replacement_path);
348 return url_loader; 348 return url_loader;
349 } 349 }
350 350
351 bool NetInternalsTest::StartTestServer() { 351 bool NetInternalsTest::StartTestServer() {
352 if (test_server_started_) 352 if (test_server_started_)
353 return true; 353 return true;
354 test_server_started_ = test_server()->Start(); 354 test_server_started_ = test_server()->Start();
355 return test_server_started_; 355 return test_server_started_;
356 } 356 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698