diff options
author | pmeenan <pmeenan@chromium.org> | 2015-01-30 13:59:59 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-30 22:00:53 +0000 |
commit | ed4b6f8b7392eb64fc664aa49f2627ecb5fdc073 (patch) | |
tree | c41b78ef68d5d37d5ec28ecaaa4037607524060d | |
parent | 7a47c4214a06aa1778ced28dc6c57658326bbf3d (diff) | |
download | chromium_src-ed4b6f8b7392eb64fc664aa49f2627ecb5fdc073.zip chromium_src-ed4b6f8b7392eb64fc664aa49f2627ecb5fdc073.tar.gz chromium_src-ed4b6f8b7392eb64fc664aa49f2627ecb5fdc073.tar.bz2 |
Renamed the dns_prefetch component to network_predictor
This is in preparation for adding preconnect support which goes through
the same underlying plumbing. dns_prefetch was too restrictive of a
component name and was only exposing the single method.
There are no functionality changes in this CL, just the rename (the namespace was also renamed)
BUG=450682
Review URL: https://codereview.chromium.org/848303005
Cr-Commit-Position: refs/heads/master@{#314001}
49 files changed, 288 insertions, 279 deletions
diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS index e6cc97e..09cfc34 100644 --- a/chrome/browser/DEPS +++ b/chrome/browser/DEPS @@ -27,7 +27,7 @@ include_rules = [ "+components/crash", "+components/crx_file", "+components/data_reduction_proxy", - "+components/dns_prefetch", + "+components/network_hints", "+components/dom_distiller", "+components/domain_reliability", "+components/enhanced_bookmarks", diff --git a/chrome/browser/net/predictor.h b/chrome/browser/net/predictor.h index 2cb01a9..d1983e3 100644 --- a/chrome/browser/net/predictor.h +++ b/chrome/browser/net/predictor.h @@ -32,7 +32,7 @@ #include "chrome/browser/net/referrer.h" #include "chrome/browser/net/timed_cache.h" #include "chrome/browser/net/url_info.h" -#include "components/dns_prefetch/common/prefetch_common.h" +#include "components/network_hints/common/network_hints_common.h" #include "net/base/host_port_pair.h" class IOThread; @@ -59,8 +59,8 @@ class PrefRegistrySyncable; namespace chrome_browser_net { -typedef dns_prefetch::UrlList UrlList; -typedef dns_prefetch::NameList NameList; +typedef network_hints::UrlList UrlList; +typedef network_hints::NameList NameList; typedef std::map<GURL, UrlInfo> Results; // An observer for testing. diff --git a/chrome/browser/net/predictor_unittest.cc b/chrome/browser/net/predictor_unittest.cc index 4fa7dd9..0a76862 100644 --- a/chrome/browser/net/predictor_unittest.cc +++ b/chrome/browser/net/predictor_unittest.cc @@ -15,7 +15,7 @@ #include "base/values.h" #include "chrome/browser/net/predictor.h" #include "chrome/browser/net/url_info.h" -#include "components/dns_prefetch/common/prefetch_common.h" +#include "components/network_hints/common/network_hints_common.h" #include "content/public/test/test_browser_thread.h" #include "net/base/address_list.h" #include "net/base/load_flags.h" diff --git a/chrome/browser/renderer_host/chrome_render_message_filter.cc b/chrome/browser/renderer_host/chrome_render_message_filter.cc index 78860b5..089354c 100644 --- a/chrome/browser/renderer_host/chrome_render_message_filter.cc +++ b/chrome/browser/renderer_host/chrome_render_message_filter.cc @@ -18,8 +18,8 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/common/render_messages.h" -#include "components/dns_prefetch/common/prefetch_common.h" -#include "components/dns_prefetch/common/prefetch_messages.h" +#include "components/network_hints/common/network_hints_common.h" +#include "components/network_hints/common/network_hints_messages.h" #include "components/web_cache/browser/web_cache_manager.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/render_process_host.h" @@ -106,7 +106,7 @@ void ChromeRenderMessageFilter::OverrideThreadForMessage( } void ChromeRenderMessageFilter::OnDnsPrefetch( - const dns_prefetch::LookupRequest& request) { + const network_hints::LookupRequest& request) { if (predictor_) predictor_->DnsPrefetchList(request.hostname_list); } diff --git a/chrome/browser/renderer_host/chrome_render_message_filter.h b/chrome/browser/renderer_host/chrome_render_message_filter.h index f7e9bc2..76eccb4 100644 --- a/chrome/browser/renderer_host/chrome_render_message_filter.h +++ b/chrome/browser/renderer_host/chrome_render_message_filter.h @@ -21,7 +21,7 @@ namespace chrome_browser_net { class Predictor; } -namespace dns_prefetch { +namespace network_hints { struct LookupRequest; } @@ -59,7 +59,7 @@ class ChromeRenderMessageFilter : public content::BrowserMessageFilter { ~ChromeRenderMessageFilter() override; - void OnDnsPrefetch(const dns_prefetch::LookupRequest& request); + void OnDnsPrefetch(const network_hints::LookupRequest& request); void OnPreconnect(const GURL& url); void OnResourceTypeStats(const blink::WebCache::ResourceTypeStats& stats); void OnUpdatedCacheStats(const blink::WebCache::UsageStats& stats); diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi index 66247fb..d73bfd3 100644 --- a/chrome/chrome_common.gypi +++ b/chrome/chrome_common.gypi @@ -593,7 +593,7 @@ '<(DEPTH)/base/base.gyp:base', '<(DEPTH)/chrome/chrome_resources.gyp:chrome_resources', '<(DEPTH)/chrome/chrome_resources.gyp:chrome_strings', - '<(DEPTH)/components/components.gyp:dns_prefetch_common', + '<(DEPTH)/components/components.gyp:network_hints_common', '<(DEPTH)/components/components.gyp:error_page_common', '<(DEPTH)/crypto/crypto.gyp:crypto', '<(DEPTH)/net/net.gyp:net_resources', diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi index 675083f..ffc463b 100644 --- a/chrome/chrome_renderer.gypi +++ b/chrome/chrome_renderer.gypi @@ -255,7 +255,7 @@ '../components/components.gyp:autofill_content_renderer', '../components/components.gyp:cdm_renderer', '../components/components.gyp:data_reduction_proxy_core_common', - '../components/components.gyp:dns_prefetch_renderer', + '../components/components.gyp:network_hints_renderer', '../components/components.gyp:error_page_renderer', '../components/components.gyp:startup_metric_utils', '../components/components.gyp:password_manager_content_renderer', diff --git a/chrome/renderer/BUILD.gn b/chrome/renderer/BUILD.gn index dce8efd..f1aa9af 100644 --- a/chrome/renderer/BUILD.gn +++ b/chrome/renderer/BUILD.gn @@ -38,7 +38,7 @@ static_library("renderer") { "//components/autofill/content/renderer", "//components/cdm/renderer", "//components/data_reduction_proxy/core/common", - "//components/dns_prefetch/renderer", + "//components/network_hints/renderer", "//components/error_page/renderer", "//components/password_manager/content/renderer", "//components/plugins/renderer", diff --git a/chrome/renderer/DEPS b/chrome/renderer/DEPS index 41a1a916..c81f7f8 100644 --- a/chrome/renderer/DEPS +++ b/chrome/renderer/DEPS @@ -16,7 +16,7 @@ include_rules = [ "+components/plugins/renderer", "+components/printing/common", "+components/printing/renderer", - "+components/dns_prefetch/renderer", + "+components/network_hints/renderer", "+components/signin/core/common", "+components/translate/content/common", "+components/translate/content/renderer", diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc index 7bd91af..aa35794 100644 --- a/chrome/renderer/chrome_content_renderer_client.cc +++ b/chrome/renderer/chrome_content_renderer_client.cc @@ -59,9 +59,9 @@ #include "components/autofill/content/renderer/password_autofill_agent.h" #include "components/autofill/content/renderer/password_generation_agent.h" #include "components/content_settings/core/common/content_settings_pattern.h" -#include "components/dns_prefetch/renderer/prescient_networking_dispatcher.h" #include "components/dom_distiller/core/url_constants.h" #include "components/nacl/renderer/ppb_nacl_private_impl.h" +#include "components/network_hints/renderer/prescient_networking_dispatcher.h" #include "components/password_manager/content/renderer/credential_manager_client.h" #include "components/pdf/renderer/ppb_pdf_impl.h" #include "components/plugins/renderer/mobile_youtube_plugin.h" @@ -310,7 +310,7 @@ void ChromeContentRendererClient::RenderThreadStarted() { #endif prescient_networking_dispatcher_.reset( - new dns_prefetch::PrescientNetworkingDispatcher()); + new network_hints::PrescientNetworkingDispatcher()); #if defined(ENABLE_SPELLCHECK) // ChromeRenderViewTest::SetUp() creates a Spellcheck and injects it using // SetSpellcheck(). Don't overwrite it. diff --git a/chrome/renderer/chrome_content_renderer_client.h b/chrome/renderer/chrome_content_renderer_client.h index 79fd97c4..81e2d55 100644 --- a/chrome/renderer/chrome_content_renderer_client.h +++ b/chrome/renderer/chrome_content_renderer_client.h @@ -34,7 +34,7 @@ class BrowserPluginDelegate; struct WebPluginInfo; } -namespace dns_prefetch { +namespace network_hints { class PrescientNetworkingDispatcher; } @@ -222,7 +222,7 @@ class ChromeContentRendererClient : public content::ContentRendererClient { permissions_policy_delegate_; #endif - scoped_ptr<dns_prefetch::PrescientNetworkingDispatcher> + scoped_ptr<network_hints::PrescientNetworkingDispatcher> prescient_networking_dispatcher_; scoped_ptr<password_manager::CredentialManagerClient> credential_manager_client_; diff --git a/chromecast/browser/DEPS b/chromecast/browser/DEPS index 76b634a..1eefc2e 100644 --- a/chromecast/browser/DEPS +++ b/chromecast/browser/DEPS @@ -4,7 +4,7 @@ include_rules = [ "+cc/base/switches.h", "+chromecast", "+components/crash", - "+components/dns_prefetch/browser", + "+components/network_hints/browser", "+content/public/browser", "+media/base", ] diff --git a/chromecast/browser/cast_content_browser_client.cc b/chromecast/browser/cast_content_browser_client.cc index ba82013..8127cf7 100644 --- a/chromecast/browser/cast_content_browser_client.cc +++ b/chromecast/browser/cast_content_browser_client.cc @@ -24,7 +24,7 @@ #include "chromecast/common/global_descriptors.h" #include "components/crash/app/breakpad_linux.h" #include "components/crash/browser/crash_handler_host_linux.h" -#include "components/dns_prefetch/browser/net_message_filter.h" +#include "components/network_hints/browser/network_hints_message_filter.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/certificate_request_result_type.h" #include "content/public/browser/render_process_host.h" @@ -64,10 +64,10 @@ content::BrowserMainParts* CastContentBrowserClient::CreateBrowserMainParts( void CastContentBrowserClient::RenderProcessWillLaunch( content::RenderProcessHost* host) { - scoped_refptr<content::BrowserMessageFilter> net_message_filter( - new dns_prefetch::NetMessageFilter( + scoped_refptr<content::BrowserMessageFilter> network_hints_message_filter( + new network_hints::NetworkHintsMessageFilter( url_request_context_factory_->host_resolver())); - host->AddFilter(net_message_filter.get()); + host->AddFilter(network_hints_message_filter.get()); #if !defined(OS_ANDROID) scoped_refptr<media::CmaMessageFilterHost> cma_message_filter( new media::CmaMessageFilterHost(host->GetID())); diff --git a/chromecast/chromecast.gyp b/chromecast/chromecast.gyp index 35cbc1c5..df70201 100644 --- a/chromecast/chromecast.gyp +++ b/chromecast/chromecast.gyp @@ -124,8 +124,8 @@ '../components/components.gyp:cdm_renderer', '../components/components.gyp:component_metrics_proto', '../components/components.gyp:crash_component', - '../components/components.gyp:dns_prefetch_browser', - '../components/components.gyp:dns_prefetch_renderer', + '../components/components.gyp:network_hints_browser', + '../components/components.gyp:network_hints_renderer', '../components/components.gyp:metrics', '../components/components.gyp:metrics_gpu', '../components/components.gyp:metrics_net', diff --git a/chromecast/renderer/DEPS b/chromecast/renderer/DEPS index 7e6b6e1..a15941d 100644 --- a/chromecast/renderer/DEPS +++ b/chromecast/renderer/DEPS @@ -2,7 +2,7 @@ include_rules = [ "+chromecast/common", "+chromecast/media", "+components/cdm/renderer", - "+components/dns_prefetch/renderer", + "+components/network_hints/renderer", "+content/public/renderer", "+media/base", "+third_party/WebKit/public/platform", diff --git a/chromecast/renderer/cast_content_renderer_client.cc b/chromecast/renderer/cast_content_renderer_client.cc index bbf456a..49408c8 100644 --- a/chromecast/renderer/cast_content_renderer_client.cc +++ b/chromecast/renderer/cast_content_renderer_client.cc @@ -13,7 +13,7 @@ #include "chromecast/renderer/cast_render_process_observer.h" #include "chromecast/renderer/key_systems_cast.h" #include "chromecast/renderer/media/cma_media_renderer_factory.h" -#include "components/dns_prefetch/renderer/prescient_networking_dispatcher.h" +#include "components/network_hints/renderer/prescient_networking_dispatcher.h" #include "content/public/common/content_switches.h" #include "content/public/renderer/render_frame.h" #include "content/public/renderer/render_view.h" @@ -108,7 +108,7 @@ void CastContentRendererClient::RenderThreadStarted() { cast_observer_.reset(new CastRenderProcessObserver()); prescient_networking_dispatcher_.reset( - new dns_prefetch::PrescientNetworkingDispatcher()); + new network_hints::PrescientNetworkingDispatcher()); } void CastContentRendererClient::RenderViewCreated( diff --git a/chromecast/renderer/cast_content_renderer_client.h b/chromecast/renderer/cast_content_renderer_client.h index 314376d..81be36c 100644 --- a/chromecast/renderer/cast_content_renderer_client.h +++ b/chromecast/renderer/cast_content_renderer_client.h @@ -10,9 +10,9 @@ #include "base/macros.h" #include "content/public/renderer/content_renderer_client.h" -namespace dns_prefetch { +namespace network_hints { class PrescientNetworkingDispatcher; -} // namespace dns_prefetch +} // namespace network_hints namespace chromecast { namespace shell { @@ -37,7 +37,7 @@ class CastContentRendererClient : public content::ContentRendererClient { const base::Closure& closure) override; private: - scoped_ptr<dns_prefetch::PrescientNetworkingDispatcher> + scoped_ptr<network_hints::PrescientNetworkingDispatcher> prescient_networking_dispatcher_; scoped_ptr<CastRenderProcessObserver> cast_observer_; diff --git a/components/OWNERS b/components/OWNERS index 73dd507..e40e825 100644 --- a/components/OWNERS +++ b/components/OWNERS @@ -47,8 +47,8 @@ per-file data_reduction_proxy*=bolian@chromium.org per-file devtools_bridge.gyp=mnaganov@chromium.org per-file devtools_bridge.gyp=serya@chromium.org -per-file dns_prefetch*=jar@chromium.org -per-file dns_prefetch*=ttuttle@chromium.org +per-file network_hints*=jar@chromium.org +per-file network_hints*=ttuttle@chromium.org per-file dom_distiller*=bengr@chromium.org per-file dom_distiller*=cjhopman@chromium.org diff --git a/components/components.gyp b/components/components.gyp index 0972d45..1eb533c 100644 --- a/components/components.gyp +++ b/components/components.gyp @@ -21,7 +21,7 @@ 'cronet.gypi', 'crx_file.gypi', 'data_reduction_proxy.gypi', - 'dns_prefetch.gypi', + 'network_hints.gypi', 'dom_distiller.gypi', 'domain_reliability.gypi', 'enhanced_bookmarks.gypi', diff --git a/components/components_tests.gyp b/components/components_tests.gyp index 5088ba3..3809893 100644 --- a/components/components_tests.gyp +++ b/components/components_tests.gyp @@ -471,8 +471,8 @@ ['OS != "ios"', { 'sources': [ 'autofill/content/renderer/renderer_save_password_progress_logger_unittest.cc', - 'dns_prefetch/renderer/predictor_queue_unittest.cc', - 'dns_prefetch/renderer/renderer_net_predictor_unittest.cc', + 'network_hints/renderer/dns_prefetch_queue_unittest.cc', + 'network_hints/renderer/renderer_dns_prefetch_unittest.cc', 'dom_distiller/content/dom_distiller_viewer_source_unittest.cc', 'dom_distiller/content/web_contents_main_frame_observer_unittest.cc', 'error_page/renderer/net_error_helper_core_unittest.cc', @@ -485,12 +485,12 @@ 'components.gyp:autofill_content_browser', 'components.gyp:autofill_content_renderer', 'components.gyp:autofill_content_test_support', - 'components.gyp:dns_prefetch_renderer', 'components.gyp:dom_distiller_content', 'components.gyp:error_page_renderer', 'components.gyp:history_content_browser', 'components.gyp:keyed_service_content', 'components.gyp:navigation_interception', + 'components.gyp:network_hints_renderer', 'components.gyp:password_manager_content_browser', 'components.gyp:password_manager_content_common', 'components.gyp:power', @@ -1047,7 +1047,7 @@ }], ['OS=="mac"', { 'dependencies': [ - '../content/content_shell_and_tests.gyp:content_shell', # Needed for Content Shell.app's Helper. + '../content/content_shell_and_tests.gyp:content_shell', # Needed for Content Shell.app's Helper. ], }], ], diff --git a/components/dns_prefetch.gypi b/components/dns_prefetch.gypi deleted file mode 100644 index 3328faa..0000000 --- a/components/dns_prefetch.gypi +++ /dev/null @@ -1,70 +0,0 @@ -# Copyright 2014 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -{ - 'targets': [ - { - # GN version: //components/dns_prefetch/common - 'target_name': 'dns_prefetch_common', - 'type': 'static_library', - 'include_dirs': [ - '..', - ], - 'dependencies': [ - '../base/base.gyp:base', - ], - 'sources': [ - 'dns_prefetch/common/prefetch_common.cc', - 'dns_prefetch/common/prefetch_common.h', - 'dns_prefetch/common/prefetch_message_generator.cc', - 'dns_prefetch/common/prefetch_message_generator.h', - 'dns_prefetch/common/prefetch_messages.cc', - 'dns_prefetch/common/prefetch_messages.h', - ], - }, - { - # GN version: //components/dns_prefetch/browser - 'target_name': 'dns_prefetch_browser', - 'type': 'static_library', - 'include_dirs': [ - '..', - ], - 'dependencies': [ - '../content/content.gyp:content_browser', - '../net/net.gyp:net', - ], - 'sources': [ - 'dns_prefetch/browser/net_message_filter.cc', - 'dns_prefetch/browser/net_message_filter.h', - ], - }, - ], - 'conditions': [ - ['OS!="ios"', { - 'targets': [ - { - # GN version: //components/dns_prefetch/renderer - 'target_name': 'dns_prefetch_renderer', - 'type': 'static_library', - 'include_dirs': [ - '..', - ], - 'dependencies': [ - 'dns_prefetch_common', - '../content/content.gyp:content_renderer', - '../third_party/WebKit/public/blink.gyp:blink', - ], - 'sources': [ - 'dns_prefetch/renderer/predictor_queue.cc', - 'dns_prefetch/renderer/predictor_queue.h', - 'dns_prefetch/renderer/prescient_networking_dispatcher.cc', - 'dns_prefetch/renderer/prescient_networking_dispatcher.h', - 'dns_prefetch/renderer/renderer_net_predictor.cc', - 'dns_prefetch/renderer/renderer_net_predictor.h', - ], - }, - ], - }], - ], -} diff --git a/components/dns_prefetch/common/BUILD.gn b/components/dns_prefetch/common/BUILD.gn deleted file mode 100644 index 82a02ac..0000000 --- a/components/dns_prefetch/common/BUILD.gn +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2014 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# GYP version: components/dns_prefetch.gypi:predictor -source_set("common") { - sources = [ - "prefetch_common.cc", - "prefetch_common.h", - "prefetch_message_generator.cc", - "prefetch_message_generator.h", - "prefetch_messages.cc", - "prefetch_messages.h", - ] - - deps = [ - "//base", - ] -} diff --git a/components/dns_prefetch/common/prefetch_messages.cc b/components/dns_prefetch/common/prefetch_messages.cc deleted file mode 100644 index 315ed92..0000000 --- a/components/dns_prefetch/common/prefetch_messages.cc +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "components/dns_prefetch/common/prefetch_messages.h" - -#include "base/strings/string_number_conversions.h" -#include "components/dns_prefetch/common/prefetch_common.h" - -namespace IPC { - -void ParamTraits<dns_prefetch::LookupRequest>::Write( - Message* m, const dns_prefetch::LookupRequest& request) { - IPC::WriteParam(m, request.hostname_list); -} - -bool ParamTraits<dns_prefetch::LookupRequest>::Read( - const Message* m, - PickleIterator* iter, - dns_prefetch::LookupRequest* request) { - // Verify the hostname limits after deserialization success. - if (IPC::ReadParam(m, iter, &request->hostname_list)) { - dns_prefetch::NameList& hostnames = request->hostname_list; - if (hostnames.size() > dns_prefetch::kMaxDnsHostnamesPerRequest) - return false; - - for (const auto& hostname : hostnames) { - if (hostname.length() > dns_prefetch::kMaxDnsHostnameLength) - return false; - } - } - return true; -} - -void ParamTraits<dns_prefetch::LookupRequest>::Log( - const dns_prefetch::LookupRequest& p, std::string* l) { - l->append("<dns_prefetch::LookupRequest: "); - l->append(base::SizeTToString(p.hostname_list.size())); - l->append(" hostnames>"); -} - -} // namespace IPC diff --git a/components/network_hints.gypi b/components/network_hints.gypi new file mode 100644 index 0000000..b6944f1 --- /dev/null +++ b/components/network_hints.gypi @@ -0,0 +1,70 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +{ + 'targets': [ + { + # GN version: //components/network_hints/common + 'target_name': 'network_hints_common', + 'type': 'static_library', + 'include_dirs': [ + '..', + ], + 'dependencies': [ + '../base/base.gyp:base', + ], + 'sources': [ + 'network_hints/common/network_hints_common.cc', + 'network_hints/common/network_hints_common.h', + 'network_hints/common/network_hints_message_generator.cc', + 'network_hints/common/network_hints_message_generator.h', + 'network_hints/common/network_hints_messages.cc', + 'network_hints/common/network_hints_messages.h', + ], + }, + { + # GN version: //components/network_hints/browser + 'target_name': 'network_hints_browser', + 'type': 'static_library', + 'include_dirs': [ + '..', + ], + 'dependencies': [ + '../content/content.gyp:content_browser', + '../net/net.gyp:net', + ], + 'sources': [ + 'network_hints/browser/network_hints_message_filter.cc', + 'network_hints/browser/network_hints_message_filter.h', + ], + }, + ], + 'conditions': [ + ['OS!="ios"', { + 'targets': [ + { + # GN version: //components/network_hints/renderer + 'target_name': 'network_hints_renderer', + 'type': 'static_library', + 'include_dirs': [ + '..', + ], + 'dependencies': [ + 'network_hints_common', + '../content/content.gyp:content_renderer', + '../third_party/WebKit/public/blink.gyp:blink', + ], + 'sources': [ + 'network_hints/renderer/dns_prefetch_queue.cc', + 'network_hints/renderer/dns_prefetch_queue.h', + 'network_hints/renderer/prescient_networking_dispatcher.cc', + 'network_hints/renderer/prescient_networking_dispatcher.h', + 'network_hints/renderer/renderer_dns_prefetch.cc', + 'network_hints/renderer/renderer_dns_prefetch.h', + ], + }, + ], + }], + ], +} diff --git a/components/dns_prefetch/OWNERS b/components/network_hints/OWNERS index 1535646..1535646 100644 --- a/components/dns_prefetch/OWNERS +++ b/components/network_hints/OWNERS diff --git a/components/dns_prefetch/browser/BUILD.gn b/components/network_hints/browser/BUILD.gn index f6cdd83..aafe3eb 100644 --- a/components/dns_prefetch/browser/BUILD.gn +++ b/components/network_hints/browser/BUILD.gn @@ -2,11 +2,11 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -# GYP version: components/dns_prefetch.gypi:dns_prefetch_browser +# GYP version: components/network_hints.gypi:network_hints_browser source_set("browser") { sources = [ - "net_message_filter.cc", - "net_message_filter.h", + "network_hints_message_filter.cc", + "network_hints_message_filter.h", ] public_deps = [ diff --git a/components/dns_prefetch/browser/DEPS b/components/network_hints/browser/DEPS index 9883d79..9883d79 100644 --- a/components/dns_prefetch/browser/DEPS +++ b/components/network_hints/browser/DEPS diff --git a/components/dns_prefetch/browser/net_message_filter.cc b/components/network_hints/browser/network_hints_message_filter.cc index 268dc2e..5541747 100644 --- a/components/dns_prefetch/browser/net_message_filter.cc +++ b/components/network_hints/browser/network_hints_message_filter.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/dns_prefetch/browser/net_message_filter.h" +#include "components/network_hints/browser/network_hints_message_filter.h" #include "base/logging.h" -#include "components/dns_prefetch/common/prefetch_common.h" -#include "components/dns_prefetch/common/prefetch_messages.h" +#include "components/network_hints/common/network_hints_common.h" +#include "components/network_hints/common/network_hints_messages.h" #include "ipc/ipc_message_macros.h" #include "net/base/address_list.h" #include "net/base/net_errors.h" @@ -14,7 +14,7 @@ #include "net/dns/single_request_host_resolver.h" #include "url/gurl.h" -namespace dns_prefetch { +namespace network_hints { namespace { @@ -62,25 +62,27 @@ class DnsLookupRequest { } // namespace -NetMessageFilter::NetMessageFilter(net::HostResolver* host_resolver) +NetworkHintsMessageFilter::NetworkHintsMessageFilter( + net::HostResolver* host_resolver) : content::BrowserMessageFilter(DnsPrefetchMsgStart), host_resolver_(host_resolver) { DCHECK(host_resolver_); } -NetMessageFilter::~NetMessageFilter() { +NetworkHintsMessageFilter::~NetworkHintsMessageFilter() { } -bool NetMessageFilter::OnMessageReceived(const IPC::Message& message) { +bool NetworkHintsMessageFilter::OnMessageReceived(const IPC::Message& message) { bool handled = true; - IPC_BEGIN_MESSAGE_MAP(NetMessageFilter, message) + IPC_BEGIN_MESSAGE_MAP(NetworkHintsMessageFilter, message) IPC_MESSAGE_HANDLER(DnsPrefetchMsg_RequestPrefetch, OnDnsPrefetch) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; } -void NetMessageFilter::OnDnsPrefetch(const LookupRequest& lookup_request) { +void NetworkHintsMessageFilter::OnDnsPrefetch( + const LookupRequest& lookup_request) { DCHECK(host_resolver_); for (const std::string& hostname : lookup_request.hostname_list) { DnsLookupRequest* request = new DnsLookupRequest(host_resolver_, hostname); @@ -90,4 +92,4 @@ void NetMessageFilter::OnDnsPrefetch(const LookupRequest& lookup_request) { } } -} // namespace dns_prefetch +} // namespace network_hints diff --git a/components/dns_prefetch/browser/net_message_filter.h b/components/network_hints/browser/network_hints_message_filter.h index 610f1ab..f30216e 100644 --- a/components/dns_prefetch/browser/net_message_filter.h +++ b/components/network_hints/browser/network_hints_message_filter.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef COMPONENTS_DNS_PREFETCH_BROWSER_NET_MESSAGE_FILTER_H_ -#define COMPONENTS_DNS_PREFETCH_BROWSER_NET_MESSAGE_FILTER_H_ +#ifndef COMPONENTS_NETWORK_HINTS_BROWSER_NETWORK_HINTS_MESSAGE_FILTER_H_ +#define COMPONENTS_NETWORK_HINTS_BROWSER_NETWORK_HINTS_MESSAGE_FILTER_H_ #include "base/macros.h" #include "content/public/browser/browser_message_filter.h" @@ -12,29 +12,29 @@ namespace net { class HostResolver; } -namespace dns_prefetch { +namespace network_hints { struct LookupRequest; // Simple browser-side handler for DNS prefetch requests. // Passes prefetch requests to the provided net::HostResolver. // Each renderer process requires its own filter. -class NetMessageFilter : public content::BrowserMessageFilter { +class NetworkHintsMessageFilter : public content::BrowserMessageFilter { public: - explicit NetMessageFilter(net::HostResolver* host_resolver); + explicit NetworkHintsMessageFilter(net::HostResolver* host_resolver); // content::BrowserMessageFilter implementation: bool OnMessageReceived(const IPC::Message& message) override; private: - ~NetMessageFilter() override; + ~NetworkHintsMessageFilter() override; void OnDnsPrefetch(const LookupRequest& lookup_request); net::HostResolver* host_resolver_; - DISALLOW_COPY_AND_ASSIGN(NetMessageFilter); + DISALLOW_COPY_AND_ASSIGN(NetworkHintsMessageFilter); }; -} // namespace dns_prefetch +} // namespace network_hints -#endif // COMPONENTS_DNS_PREFETCH_BROWSER_NET_MESSAGE_FILTER_H_ +#endif // COMPONENTS_NETWORK_HINTS_BROWSER_NETWORK_HINTS_MESSAGE_FILTER_H_ diff --git a/components/network_hints/common/BUILD.gn b/components/network_hints/common/BUILD.gn new file mode 100644 index 0000000..1e06117 --- /dev/null +++ b/components/network_hints/common/BUILD.gn @@ -0,0 +1,19 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# GYP version: components/network_hints.gypi:predictor +source_set("common") { + sources = [ + "network_hints_common.cc", + "network_hints_common.h", + "network_hints_message_generator.cc", + "network_hints_message_generator.h", + "network_hints_messages.cc", + "network_hints_messages.h", + ] + + deps = [ + "//base", + ] +} diff --git a/components/dns_prefetch/common/DEPS b/components/network_hints/common/DEPS index 1c40d98..1c40d98 100644 --- a/components/dns_prefetch/common/DEPS +++ b/components/network_hints/common/DEPS diff --git a/components/dns_prefetch/common/prefetch_common.cc b/components/network_hints/common/network_hints_common.cc index 04d5ff2..c6d64ae 100644 --- a/components/dns_prefetch/common/prefetch_common.cc +++ b/components/network_hints/common/network_hints_common.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/dns_prefetch/common/prefetch_common.h" +#include "components/network_hints/common/network_hints_common.h" -namespace dns_prefetch { +namespace network_hints { const size_t kMaxDnsHostnamesPerRequest = 30; const size_t kMaxDnsHostnameLength = 255; @@ -15,4 +15,4 @@ LookupRequest::LookupRequest() { LookupRequest::~LookupRequest() { } -} // namespace dns_prefetch +} // namespace network_hints diff --git a/components/dns_prefetch/common/prefetch_common.h b/components/network_hints/common/network_hints_common.h index 84b2a0c..701b003 100644 --- a/components/dns_prefetch/common/prefetch_common.h +++ b/components/network_hints/common/network_hints_common.h @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef COMPONENTS_DNS_PREFETCH_COMMON_PREFETCH_COMMON_H_ -#define COMPONENTS_DNS_PREFETCH_COMMON_PREFETCH_COMMON_H_ +#ifndef COMPONENTS_NETWORK_HINTS_COMMON_NETWORK_HINTS_COMMON_H_ +#define COMPONENTS_NETWORK_HINTS_COMMON_NETWORK_HINTS_COMMON_H_ #include <string> #include <vector> #include "url/gurl.h" -namespace dns_prefetch { +namespace network_hints { // IPC messages are passed from the renderer to the browser in the form of // Namelist instances. @@ -36,6 +36,6 @@ extern const size_t kMaxDnsHostnamesPerRequest; // The maximum length for a given DNS hostname to resolve. extern const size_t kMaxDnsHostnameLength; -} +} // namespace network_hints -#endif // COMPONENTS_DNS_PREFETCH_COMMON_PREFETCH_COMMON_H_ +#endif // COMPONENTS_NETWORK_HINTS_COMMON_NETWORK_HINTS_COMMON_H_ diff --git a/components/dns_prefetch/common/prefetch_message_generator.cc b/components/network_hints/common/network_hints_message_generator.cc index 81b93f0..f315e98 100644 --- a/components/dns_prefetch/common/prefetch_message_generator.cc +++ b/components/network_hints/common/network_hints_message_generator.cc @@ -4,30 +4,30 @@ // Get basic type definitions. #define IPC_MESSAGE_IMPL -#include "components/dns_prefetch/common/prefetch_message_generator.h" +#include "components/network_hints/common/network_hints_message_generator.h" // Generate constructors. #include "ipc/struct_constructor_macros.h" -#include "components/dns_prefetch/common/prefetch_message_generator.h" +#include "components/network_hints/common/network_hints_message_generator.h" // Generate destructors. #include "ipc/struct_destructor_macros.h" -#include "components/dns_prefetch/common/prefetch_message_generator.h" +#include "components/network_hints/common/network_hints_message_generator.h" // Generate param traits write methods. #include "ipc/param_traits_write_macros.h" namespace IPC { -#include "components/dns_prefetch/common/prefetch_message_generator.h" +#include "components/network_hints/common/network_hints_message_generator.h" } // namespace IPC // Generate param traits read methods. #include "ipc/param_traits_read_macros.h" namespace IPC { -#include "components/dns_prefetch/common/prefetch_message_generator.h" +#include "components/network_hints/common/network_hints_message_generator.h" } // namespace IPC // Generate param traits log methods. #include "ipc/param_traits_log_macros.h" namespace IPC { -#include "components/dns_prefetch/common/prefetch_message_generator.h" +#include "components/network_hints/common/network_hints_message_generator.h" } // namespace IPC diff --git a/components/dns_prefetch/common/prefetch_message_generator.h b/components/network_hints/common/network_hints_message_generator.h index 92240c4..246cd4b 100644 --- a/components/dns_prefetch/common/prefetch_message_generator.h +++ b/components/network_hints/common/network_hints_message_generator.h @@ -4,4 +4,4 @@ // Multiply-included file, no traditional include guard. -#include "components/dns_prefetch/common/prefetch_messages.h" +#include "components/network_hints/common/network_hints_messages.h" diff --git a/components/network_hints/common/network_hints_messages.cc b/components/network_hints/common/network_hints_messages.cc new file mode 100644 index 0000000..e97e1a2 --- /dev/null +++ b/components/network_hints/common/network_hints_messages.cc @@ -0,0 +1,42 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/network_hints/common/network_hints_messages.h" + +#include "base/strings/string_number_conversions.h" +#include "components/network_hints/common/network_hints_common.h" + +namespace IPC { + +void ParamTraits<network_hints::LookupRequest>::Write( + Message* m, const network_hints::LookupRequest& request) { + IPC::WriteParam(m, request.hostname_list); +} + +bool ParamTraits<network_hints::LookupRequest>::Read( + const Message* m, + PickleIterator* iter, + network_hints::LookupRequest* request) { + // Verify the hostname limits after deserialization success. + if (IPC::ReadParam(m, iter, &request->hostname_list)) { + network_hints::NameList& hostnames = request->hostname_list; + if (hostnames.size() > network_hints::kMaxDnsHostnamesPerRequest) + return false; + + for (const auto& hostname : hostnames) { + if (hostname.length() > network_hints::kMaxDnsHostnameLength) + return false; + } + } + return true; +} + +void ParamTraits<network_hints::LookupRequest>::Log( + const network_hints::LookupRequest& p, std::string* l) { + l->append("<network_hints::LookupRequest: "); + l->append(base::SizeTToString(p.hostname_list.size())); + l->append(" hostnames>"); +} + +} // namespace IPC diff --git a/components/dns_prefetch/common/prefetch_messages.h b/components/network_hints/common/network_hints_messages.h index d12ac74..9c52c3a 100644 --- a/components/dns_prefetch/common/prefetch_messages.h +++ b/components/network_hints/common/network_hints_messages.h @@ -6,19 +6,19 @@ #include <string> #include <vector> -#include "components/dns_prefetch/common/prefetch_common.h" +#include "components/network_hints/common/network_hints_common.h" #include "ipc/ipc_message_macros.h" #include "ipc/ipc_message_utils.h" // Singly-included section for custom IPC traits. -#ifndef COMPONENTS_DNS_PREFETCH_COMMON_PREFETCH_MESSAGES_H_ -#define COMPONENTS_DNS_PREFETCH_COMMON_PREFETCH_MESSAGES_H_ +#ifndef COMPONENTS_NETWORK_HINTS_COMMON_NETWORK_HINTS_MESSAGES_H_ +#define COMPONENTS_NETWORK_HINTS_COMMON_NETWORK_HINTS_MESSAGES_H_ namespace IPC { template <> -struct ParamTraits<dns_prefetch::LookupRequest> { - typedef dns_prefetch::LookupRequest param_type; +struct ParamTraits<network_hints::LookupRequest> { + typedef network_hints::LookupRequest param_type; static void Write(Message* m, const param_type& p); static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); @@ -26,7 +26,7 @@ struct ParamTraits<dns_prefetch::LookupRequest> { } // namespace IPC -#endif // COMPONENTS_DNS_PREFETCH_COMMON_PREFETCH_MESSAGES_H_ +#endif // COMPONENTS_NETWORK_HINTS_COMMON_NETWORK_HINTS_MESSAGES_H_ #define IPC_MESSAGE_START DnsPrefetchMsgStart @@ -37,4 +37,4 @@ struct ParamTraits<dns_prefetch::LookupRequest> { // Request for a DNS prefetch of the names in the array. // NameList is typedef'ed std::vector<std::string> IPC_MESSAGE_CONTROL1(DnsPrefetchMsg_RequestPrefetch, - dns_prefetch::LookupRequest) + network_hints::LookupRequest) diff --git a/components/dns_prefetch/renderer/BUILD.gn b/components/network_hints/renderer/BUILD.gn index cc7350d..8c56754 100644 --- a/components/dns_prefetch/renderer/BUILD.gn +++ b/components/network_hints/renderer/BUILD.gn @@ -2,19 +2,19 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -# GYP version: components/dns_prefetch.gypi:predictor_renderer +# GYP version: components/network_hints.gypi:predictor_renderer source_set("renderer") { sources = [ - "predictor_queue.cc", - "predictor_queue.h", + "dns_prefetch_queue.cc", + "dns_prefetch_queue.h", "prescient_networking_dispatcher.cc", "prescient_networking_dispatcher.h", - "renderer_net_predictor.cc", - "renderer_net_predictor.h", + "renderer_dns_prefetch.cc", + "renderer_dns_prefetch.h", ] public_deps = [ - "//components/dns_prefetch/common", + "//components/network_hints/common", "//content/public/renderer", "//third_party/WebKit/public:blink", ] diff --git a/components/dns_prefetch/renderer/DEPS b/components/network_hints/renderer/DEPS index 5a47d5f..d6ea0c4 100644 --- a/components/dns_prefetch/renderer/DEPS +++ b/components/network_hints/renderer/DEPS @@ -1,5 +1,5 @@ include_rules = [ - "+components/dns_prefetch/common", + "+components/network_hints/common", "+content/public/renderer", "+third_party/WebKit/public", ] diff --git a/components/dns_prefetch/renderer/predictor_queue.cc b/components/network_hints/renderer/dns_prefetch_queue.cc index 1691108..8328df9 100644 --- a/components/dns_prefetch/renderer/predictor_queue.cc +++ b/components/network_hints/renderer/dns_prefetch_queue.cc @@ -4,12 +4,12 @@ // See header file for description of DnsQueue class -#include "components/dns_prefetch/renderer/predictor_queue.h" +#include "components/network_hints/renderer/dns_prefetch_queue.h" #include "base/logging.h" #include "base/metrics/stats_counters.h" -namespace dns_prefetch { +namespace network_hints { DnsQueue::DnsQueue(BufferSize size) : buffer_(new char[size + 2]), @@ -153,4 +153,4 @@ bool DnsQueue::Validate() { ((0 == size_) == (readable_ == writeable_)); } -} // namespace dns_prefetch +} // namespace network_hints diff --git a/components/dns_prefetch/renderer/predictor_queue.h b/components/network_hints/renderer/dns_prefetch_queue.h index cb0c17a..72b4fad 100644 --- a/components/dns_prefetch/renderer/predictor_queue.h +++ b/components/network_hints/renderer/dns_prefetch_queue.h @@ -21,16 +21,18 @@ // rendering, the supplier is the renderer (typically), and the consumer // is a thread that sends messages to an async DNS resolver. -#ifndef COMPONENTS_DNS_PREFETCH_RENDERER_PREDICTOR_QUEUE_H__ -#define COMPONENTS_DNS_PREFETCH_RENDERER_PREDICTOR_QUEUE_H__ +#ifndef COMPONENTS_NETWORK_HINTS_RENDERER_DNS_PREFETCH_QUEUE_H__ +#define COMPONENTS_NETWORK_HINTS_RENDERER_DNS_PREFETCH_QUEUE_H__ #include <string> #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" -namespace dns_prefetch { +namespace network_hints { +// A queue of DNS lookup requests for internal use within the network_hints +// component. class DnsQueue { public: // BufferSize is a signed type used for indexing into a buffer. @@ -86,6 +88,6 @@ class DnsQueue { DISALLOW_COPY_AND_ASSIGN(DnsQueue); }; // class DnsQueue -} // namespace dns_prefetch +} // namespace network_hints -#endif // COMPONENTS_DNS_PREFETCH_RENDERER_PREDICTOR_QUEUE_H__ +#endif // COMPONENTS_NETWORK_HINTS_RENDERER_DNS_PREFETCH_QUEUE_H__ diff --git a/components/dns_prefetch/renderer/predictor_queue_unittest.cc b/components/network_hints/renderer/dns_prefetch_queue_unittest.cc index af2ea04..cb808c1 100644 --- a/components/dns_prefetch/renderer/predictor_queue_unittest.cc +++ b/components/network_hints/renderer/dns_prefetch_queue_unittest.cc @@ -4,12 +4,12 @@ #include <sstream> -#include "components/dns_prefetch/renderer/predictor_queue.h" +#include "components/network_hints/renderer/dns_prefetch_queue.h" #include "testing/gtest/include/gtest/gtest.h" // Single threaded tests of DnsQueue functionality. -namespace dns_prefetch { +namespace network_hints { class DnsQueueTest : public testing::Test { }; @@ -259,4 +259,4 @@ TEST(DnsQueueTest, WrapOnVariousSubstrings) { EXPECT_FALSE(tester.Pop()); } -}; // namespace dns_prefetch +}; // namespace network_hints diff --git a/components/dns_prefetch/renderer/prescient_networking_dispatcher.cc b/components/network_hints/renderer/prescient_networking_dispatcher.cc index 6ce8b66..ee02f019 100644 --- a/components/dns_prefetch/renderer/prescient_networking_dispatcher.cc +++ b/components/network_hints/renderer/prescient_networking_dispatcher.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/dns_prefetch/renderer/prescient_networking_dispatcher.h" +#include "components/network_hints/renderer/prescient_networking_dispatcher.h" #include "base/logging.h" -namespace dns_prefetch { +namespace network_hints { PrescientNetworkingDispatcher::PrescientNetworkingDispatcher() { } @@ -21,7 +21,7 @@ void PrescientNetworkingDispatcher::prefetchDNS( return; std::string hostname_utf8 = hostname.utf8(); - net_predictor_.Resolve(hostname_utf8.data(), hostname_utf8.length()); + dns_prefetch_.Resolve(hostname_utf8.data(), hostname_utf8.length()); } -} // namespace dns_prefetch +} // namespace network_hints diff --git a/components/dns_prefetch/renderer/prescient_networking_dispatcher.h b/components/network_hints/renderer/prescient_networking_dispatcher.h index fbb383c..9b10739 100644 --- a/components/dns_prefetch/renderer/prescient_networking_dispatcher.h +++ b/components/network_hints/renderer/prescient_networking_dispatcher.h @@ -2,15 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef COMPONENTS_DNS_PREFETCH_RENDERER_PRESCIENT_NETWORKING_DISPATCHER_H_ -#define COMPONENTS_DNS_PREFETCH_RENDERER_PRESCIENT_NETWORKING_DISPATCHER_H_ +#ifndef COMPONENTS_NETWORK_HINTS_RENDERER_PRESCIENT_NETWORKING_DISPATCHER_H_ +#define COMPONENTS_NETWORK_HINTS_RENDERER_PRESCIENT_NETWORKING_DISPATCHER_H_ #include "base/macros.h" -#include "components/dns_prefetch/renderer/renderer_net_predictor.h" +#include "components/network_hints/renderer/renderer_dns_prefetch.h" #include "third_party/WebKit/public/platform/WebPrescientNetworking.h" -namespace dns_prefetch { +namespace network_hints { +// The main entry point from blink for sending DNS prefetch requests to the +// network stack. class PrescientNetworkingDispatcher : public blink::WebPrescientNetworking { public: PrescientNetworkingDispatcher(); @@ -19,11 +21,11 @@ class PrescientNetworkingDispatcher : public blink::WebPrescientNetworking { void prefetchDNS(const blink::WebString& hostname) override; private: - dns_prefetch::RendererNetPredictor net_predictor_; + network_hints::RendererDnsPrefetch dns_prefetch_; DISALLOW_COPY_AND_ASSIGN(PrescientNetworkingDispatcher); }; -} // namespace dns_prefetch +} // namespace network_hints -#endif // COMPONENTS_DNS_PREFETCH_RENDERER_PRESCIENT_NETWORKING_DISPATCHER_H_ +#endif // COMPONENTS_NETWORK_HINTS_RENDERER_PRESCIENT_NETWORKING_DISPATCHER_H_ diff --git a/components/dns_prefetch/renderer/renderer_net_predictor.cc b/components/network_hints/renderer/renderer_dns_prefetch.cc index 273e3e1..7098037 100644 --- a/components/dns_prefetch/renderer/renderer_net_predictor.cc +++ b/components/network_hints/renderer/renderer_dns_prefetch.cc @@ -2,34 +2,34 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// See header file for description of RendererNetPredictor class +// See header file for description of RendererDnsPrefetch class -#include "components/dns_prefetch/renderer/renderer_net_predictor.h" +#include "components/network_hints/renderer/renderer_dns_prefetch.h" #include <ctype.h> #include "base/bind.h" #include "base/logging.h" #include "base/message_loop/message_loop.h" -#include "components/dns_prefetch/common/prefetch_common.h" -#include "components/dns_prefetch/common/prefetch_messages.h" -#include "components/dns_prefetch/renderer/predictor_queue.h" +#include "components/network_hints/common/network_hints_common.h" +#include "components/network_hints/common/network_hints_messages.h" +#include "components/network_hints/renderer/dns_prefetch_queue.h" #include "content/public/renderer/render_thread.h" using content::RenderThread; -namespace dns_prefetch { +namespace network_hints { -RendererNetPredictor::RendererNetPredictor() +RendererDnsPrefetch::RendererDnsPrefetch() : c_string_queue_(1000), weak_factory_(this) { Reset(); } -RendererNetPredictor::~RendererNetPredictor() { +RendererDnsPrefetch::~RendererDnsPrefetch() { } -void RendererNetPredictor::Reset() { +void RendererDnsPrefetch::Reset() { domain_map_.clear(); c_string_queue_.Clear(); buffer_full_discard_count_ = 0; @@ -38,7 +38,7 @@ void RendererNetPredictor::Reset() { } // Push names into queue quickly! -void RendererNetPredictor::Resolve(const char* name, size_t length) { +void RendererDnsPrefetch::Resolve(const char* name, size_t length) { if (!length) return; // Don't store empty strings in buffer. if (is_numeric_ip(name, length)) @@ -53,7 +53,7 @@ void RendererNetPredictor::Resolve(const char* name, size_t length) { return; // Overkill safety net: Don't send too many InvokeLater's. weak_factory_.InvalidateWeakPtrs(); RenderThread::Get()->GetTaskRunner()->PostDelayedTask( - FROM_HERE, base::Bind(&RendererNetPredictor::SubmitHostnames, + FROM_HERE, base::Bind(&RendererDnsPrefetch::SubmitHostnames, weak_factory_.GetWeakPtr()), base::TimeDelta::FromMilliseconds(10)); } @@ -68,7 +68,7 @@ void RendererNetPredictor::Resolve(const char* name, size_t length) { // Extract data from the Queue, and then send it off the the Browser process // to be resolved. -void RendererNetPredictor::SubmitHostnames() { +void RendererDnsPrefetch::SubmitHostnames() { // Get all names out of the C_string_queue (into our map) ExtractBufferedNames(); // TBD: IT could be that we should only extract about as many names as we are @@ -88,7 +88,7 @@ void RendererNetPredictor::SubmitHostnames() { if (new_name_count_ > 0 || 0 < c_string_queue_.Size()) { weak_factory_.InvalidateWeakPtrs(); RenderThread::Get()->GetTaskRunner()->PostDelayedTask( - FROM_HERE, base::Bind(&RendererNetPredictor::SubmitHostnames, + FROM_HERE, base::Bind(&RendererDnsPrefetch::SubmitHostnames, weak_factory_.GetWeakPtr()), base::TimeDelta::FromMilliseconds(10)); } else { @@ -98,7 +98,7 @@ void RendererNetPredictor::SubmitHostnames() { } // Pull some hostnames from the queue, and add them to our map. -void RendererNetPredictor::ExtractBufferedNames(size_t size_goal) { +void RendererDnsPrefetch::ExtractBufferedNames(size_t size_goal) { size_t count(0); // Number of entries to find (0 means find all). if (size_goal > 0) { if (size_goal <= domain_map_.size()) @@ -126,7 +126,7 @@ void RendererNetPredictor::ExtractBufferedNames(size_t size_goal) { } } -void RendererNetPredictor::DnsPrefetchNames(size_t max_count) { +void RendererDnsPrefetch::DnsPrefetchNames(size_t max_count) { // We are on the renderer thread, and just need to send things to the browser. NameList names; for (DomainUseMap::iterator it = domain_map_.begin(); @@ -144,7 +144,7 @@ void RendererNetPredictor::DnsPrefetchNames(size_t max_count) { DCHECK_GE(new_name_count_, names.size()); new_name_count_ -= names.size(); - dns_prefetch::LookupRequest request; + network_hints::LookupRequest request; request.hostname_list = names; RenderThread::Get()->Send(new DnsPrefetchMsg_RequestPrefetch(request)); } @@ -152,7 +152,7 @@ void RendererNetPredictor::DnsPrefetchNames(size_t max_count) { // is_numeric_ip() checks to see if all characters in name are either numeric, // or dots. Such a name will not actually be passed to DNS, as it is an IP // address. -bool RendererNetPredictor::is_numeric_ip(const char* name, size_t length) { +bool RendererDnsPrefetch::is_numeric_ip(const char* name, size_t length) { // Scan for a character outside our lookup list. while (length-- > 0) { if (!isdigit(*name) && '.' != *name) diff --git a/components/dns_prefetch/renderer/renderer_net_predictor.h b/components/network_hints/renderer/renderer_dns_prefetch.h index 74a148e..9ee4f61 100644 --- a/components/dns_prefetch/renderer/renderer_net_predictor.h +++ b/components/network_hints/renderer/renderer_dns_prefetch.h @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// A RendererNetPredictor instance is maintained for each RenderThread. +// A RendererDnsPrefetch instance is maintained for each RenderThread. // URL strings are typically added to the embedded queue during rendering. // The first addition to the queue (transitioning from empty to having // some names) causes a processing task to be added to the Renderer Thread. @@ -18,22 +18,24 @@ // sent names. If the entire queue is processed, then the list of "sent names" // is cleared so that future gatherings might again pass along the same names. -#ifndef COMPONENTS_DNS_PREFETCH_RENDERER_RENDERER_NET_PREDICTOR_H_ -#define COMPONENTS_DNS_PREFETCH_RENDERER_RENDERER_NET_PREDICTOR_H_ +#ifndef COMPONENTS_NETWORK_HINTS_RENDERER_RENDERER_DNS_PREFETCH_H_ +#define COMPONENTS_NETWORK_HINTS_RENDERER_RENDERER_DNS_PREFETCH_H_ #include <map> #include <string> #include "base/basictypes.h" #include "base/memory/weak_ptr.h" -#include "components/dns_prefetch/renderer/predictor_queue.h" +#include "components/network_hints/renderer/dns_prefetch_queue.h" -namespace dns_prefetch { +namespace network_hints { -class RendererNetPredictor { +// An internal interface to the network_hints component for efficiently sending +// DNS prefetch requests to the net stack. +class RendererDnsPrefetch { public: - RendererNetPredictor(); - ~RendererNetPredictor(); + RendererDnsPrefetch(); + ~RendererDnsPrefetch(); // Push a name into the queue to be resolved. void Resolve(const char* name, size_t length); @@ -97,11 +99,11 @@ class RendererNetPredictor { int buffer_full_discard_count_; int numeric_ip_discard_count_; - base::WeakPtrFactory<RendererNetPredictor> weak_factory_; + base::WeakPtrFactory<RendererDnsPrefetch> weak_factory_; - DISALLOW_COPY_AND_ASSIGN(RendererNetPredictor); -}; // class RendererNetPredictor + DISALLOW_COPY_AND_ASSIGN(RendererDnsPrefetch); +}; // class RendererDnsPrefetch -} // namespace dns_prefetch +} // namespace network_hints -#endif // COMPONENTS_DNS_PREFETCH_RENDERER_RENDERER_NET_PREDICTOR_H_ +#endif // COMPONENTS_NETWORK_HINTS_RENDERER_RENDERER_DNS_PREFETCH_H_ diff --git a/components/dns_prefetch/renderer/renderer_net_predictor_unittest.cc b/components/network_hints/renderer/renderer_dns_prefetch_unittest.cc index 03a4f2e..588383c 100644 --- a/components/dns_prefetch/renderer/renderer_net_predictor_unittest.cc +++ b/components/network_hints/renderer/renderer_dns_prefetch_unittest.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Single threaded tests of RendererNetPredictor functionality. +// Single threaded tests of RendererDnsPrefetch functionality. -#include "components/dns_prefetch/renderer/renderer_net_predictor.h" +#include "components/network_hints/renderer/renderer_dns_prefetch.h" #include <algorithm> #include "testing/gtest/include/gtest/gtest.h" -namespace dns_prefetch { +namespace network_hints { class RenderDnsMasterTest : public testing::Test { }; @@ -21,8 +21,8 @@ TEST(RenderDnsMasterTest, NumericIpDiscardCheck) { // Combination of digits plus dots. const std::string N1("1.3."), N2("5.5.7.12"); -#define TESTNAME(string) RendererNetPredictor::is_numeric_ip((string.data()), \ - (string).size()) +#define TESTNAME(string) RendererDnsPrefetch::is_numeric_ip((string.data()), \ + (string).size()) EXPECT_TRUE(TESTNAME(N1)); EXPECT_TRUE(TESTNAME(N2)); @@ -34,4 +34,4 @@ TEST(RenderDnsMasterTest, NumericIpDiscardCheck) { #undef TESTNAME } -} // namespace dns_prefetch +} // namespace network_hints diff --git a/tools/ipc_fuzzer/message_lib/DEPS b/tools/ipc_fuzzer/message_lib/DEPS index aa53949..98c66d6 100644 --- a/tools/ipc_fuzzer/message_lib/DEPS +++ b/tools/ipc_fuzzer/message_lib/DEPS @@ -3,6 +3,7 @@ include_rules = [ "+components/autofill/content/common", "+components/dns_prefetch/common", "+components/nacl/common", + "+components/network_hints/common", "+components/password_manager/content/common", "+components/pdf/common", "+components/tracing", diff --git a/tools/ipc_fuzzer/message_lib/all_messages.h b/tools/ipc_fuzzer/message_lib/all_messages.h index b8d86d1..1cd3216 100644 --- a/tools/ipc_fuzzer/message_lib/all_messages.h +++ b/tools/ipc_fuzzer/message_lib/all_messages.h @@ -15,8 +15,8 @@ #include "chrome/common/all_messages.h" #include "components/autofill/content/common/autofill_message_generator.h" -#include "components/dns_prefetch/common/prefetch_message_generator.h" #include "components/nacl/common/nacl_host_messages.h" +#include "components/network_hints/common/network_hints_message_generator.h" #include "components/password_manager/content/common/credential_manager_message_generator.h" #include "components/pdf/common/pdf_message_generator.h" #include "components/tracing/tracing_messages.h" |