| OLD | NEW |
| 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/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/prerender/prerender_manager.h" | 13 #include "chrome/browser/prerender/prerender_manager.h" |
| 14 #include "chrome/browser/prerender/prerender_manager_factory.h" | 14 #include "chrome/browser/prerender/prerender_manager_factory.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/test/base/ui_test_utils.h" | 19 #include "chrome/test/base/ui_test_utils.h" |
| 20 #include "content/public/browser/render_view_host.h" | 20 #include "content/public/browser/render_view_host.h" |
| 21 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 22 #include "content/public/browser/web_ui_message_handler.h" | 22 #include "content/public/browser/web_ui_message_handler.h" |
| 23 #include "googleurl/src/gurl.h" | 23 #include "googleurl/src/gurl.h" |
| 24 #include "net/base/address_list.h" | 24 #include "net/base/address_list.h" |
| 25 #include "net/base/net_errors.h" | 25 #include "net/base/net_errors.h" |
| 26 #include "net/dns/host_cache.h" | 26 #include "net/dns/host_cache.h" |
| 27 #include "net/dns/host_resolver.h" | 27 #include "net/dns/host_resolver.h" |
| 28 #include "net/dns/host_resolver_proc.h" | 28 #include "net/dns/mock_host_resolver.h" |
| 29 #include "net/http/http_network_session.h" | 29 #include "net/http/http_network_session.h" |
| 30 #include "net/http/http_pipelined_host_capability.h" | 30 #include "net/http/http_pipelined_host_capability.h" |
| 31 #include "net/http/http_transaction_factory.h" | 31 #include "net/http/http_transaction_factory.h" |
| 32 #include "net/url_request/url_request_context.h" | 32 #include "net/url_request/url_request_context.h" |
| 33 #include "net/url_request/url_request_context_getter.h" | 33 #include "net/url_request/url_request_context_getter.h" |
| 34 #include "testing/gtest/include/gtest/gtest.h" | 34 #include "testing/gtest/include/gtest/gtest.h" |
| 35 | 35 |
| 36 using content::BrowserThread; | 36 using content::BrowserThread; |
| 37 using content::WebUIMessageHandler; | 37 using content::WebUIMessageHandler; |
| 38 | 38 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 50 net::HostCache* cache = context->host_resolver()->GetHostCache(); | 50 net::HostCache* cache = context->host_resolver()->GetHostCache(); |
| 51 ASSERT_TRUE(cache); | 51 ASSERT_TRUE(cache); |
| 52 | 52 |
| 53 net::HostCache::Key key(hostname, net::ADDRESS_FAMILY_UNSPECIFIED, 0); | 53 net::HostCache::Key key(hostname, net::ADDRESS_FAMILY_UNSPECIFIED, 0); |
| 54 base::TimeDelta ttl = base::TimeDelta::FromDays(expire_days_from_now); | 54 base::TimeDelta ttl = base::TimeDelta::FromDays(expire_days_from_now); |
| 55 | 55 |
| 56 net::AddressList address_list; | 56 net::AddressList address_list; |
| 57 if (net_error == net::OK) { | 57 if (net_error == net::OK) { |
| 58 // If |net_error| does not indicate an error, convert |ip_literal| to a | 58 // If |net_error| does not indicate an error, convert |ip_literal| to a |
| 59 // net::AddressList, so it can be used with the cache. | 59 // net::AddressList, so it can be used with the cache. |
| 60 int rv = net::SystemHostResolverProc(ip_literal, | 60 int rv = net::ParseAddressList(ip_literal, hostname, &address_list); |
| 61 net::ADDRESS_FAMILY_UNSPECIFIED, | |
| 62 0, | |
| 63 &address_list, | |
| 64 NULL); | |
| 65 ASSERT_EQ(net::OK, rv); | 61 ASSERT_EQ(net::OK, rv); |
| 66 } else { | 62 } else { |
| 67 ASSERT_TRUE(ip_literal.empty()); | 63 ASSERT_TRUE(ip_literal.empty()); |
| 68 } | 64 } |
| 69 | 65 |
| 70 // Add entry to the cache. | 66 // Add entry to the cache. |
| 71 cache->Set(net::HostCache::Key(hostname, net::ADDRESS_FAMILY_UNSPECIFIED, 0), | 67 cache->Set(net::HostCache::Key(hostname, net::ADDRESS_FAMILY_UNSPECIFIED, 0), |
| 72 net::HostCache::Entry(net_error, address_list), | 68 net::HostCache::Entry(net_error, address_list), |
| 73 base::TimeTicks::Now(), | 69 base::TimeTicks::Now(), |
| 74 ttl); | 70 ttl); |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 GURL url_loader = test_server()->GetURL(replacement_path); | 369 GURL url_loader = test_server()->GetURL(replacement_path); |
| 374 return url_loader; | 370 return url_loader; |
| 375 } | 371 } |
| 376 | 372 |
| 377 bool NetInternalsTest::StartTestServer() { | 373 bool NetInternalsTest::StartTestServer() { |
| 378 if (test_server_started_) | 374 if (test_server_started_) |
| 379 return true; | 375 return true; |
| 380 test_server_started_ = test_server()->Start(); | 376 test_server_started_ = test_server()->Start(); |
| 381 return test_server_started_; | 377 return test_server_started_; |
| 382 } | 378 } |
| OLD | NEW |