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 /components/network_hints/common | |
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}
Diffstat (limited to 'components/network_hints/common')
8 files changed, 203 insertions, 0 deletions
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/network_hints/common/DEPS b/components/network_hints/common/DEPS new file mode 100644 index 0000000..1c40d98 --- /dev/null +++ b/components/network_hints/common/DEPS @@ -0,0 +1,3 @@ +include_rules = [ + "+ipc", +] diff --git a/components/network_hints/common/network_hints_common.cc b/components/network_hints/common/network_hints_common.cc new file mode 100644 index 0000000..c6d64ae --- /dev/null +++ b/components/network_hints/common/network_hints_common.cc @@ -0,0 +1,18 @@ +// 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_common.h" + +namespace network_hints { + +const size_t kMaxDnsHostnamesPerRequest = 30; +const size_t kMaxDnsHostnameLength = 255; + +LookupRequest::LookupRequest() { +} + +LookupRequest::~LookupRequest() { +} + +} // namespace network_hints diff --git a/components/network_hints/common/network_hints_common.h b/components/network_hints/common/network_hints_common.h new file mode 100644 index 0000000..701b003 --- /dev/null +++ b/components/network_hints/common/network_hints_common.h @@ -0,0 +1,41 @@ +// Copyright (c) 2006-2008 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. + +#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 network_hints { + +// IPC messages are passed from the renderer to the browser in the form of +// Namelist instances. +// Each element of this vector is a hostname that needs to be looked up. +// The hostnames should never be empty strings. +typedef std::vector<std::string> NameList; +// TODO(jar): We still need to switch to passing scheme/host/port in UrlList, +// instead of NameList, from renderer (where content of pages are scanned for +// links) to browser (where we perform predictive actions). +typedef std::vector<GURL> UrlList; + +struct LookupRequest { + LookupRequest(); + ~LookupRequest(); + + NameList hostname_list; +}; + +// The maximum number of hostnames submitted to the browser DNS resolver per +// IPC call. +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_NETWORK_HINTS_COMMON_NETWORK_HINTS_COMMON_H_ diff --git a/components/network_hints/common/network_hints_message_generator.cc b/components/network_hints/common/network_hints_message_generator.cc new file mode 100644 index 0000000..f315e98 --- /dev/null +++ b/components/network_hints/common/network_hints_message_generator.cc @@ -0,0 +1,33 @@ +// 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. + +// Get basic type definitions. +#define IPC_MESSAGE_IMPL +#include "components/network_hints/common/network_hints_message_generator.h" + +// Generate constructors. +#include "ipc/struct_constructor_macros.h" +#include "components/network_hints/common/network_hints_message_generator.h" + +// Generate destructors. +#include "ipc/struct_destructor_macros.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/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/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/network_hints/common/network_hints_message_generator.h" +} // namespace IPC diff --git a/components/network_hints/common/network_hints_message_generator.h b/components/network_hints/common/network_hints_message_generator.h new file mode 100644 index 0000000..246cd4b --- /dev/null +++ b/components/network_hints/common/network_hints_message_generator.h @@ -0,0 +1,7 @@ +// 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. + +// Multiply-included file, no traditional include guard. + +#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/network_hints/common/network_hints_messages.h b/components/network_hints/common/network_hints_messages.h new file mode 100644 index 0000000..9c52c3a --- /dev/null +++ b/components/network_hints/common/network_hints_messages.h @@ -0,0 +1,40 @@ +// 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. + +// Multiply-included file, no traditional include guard. +#include <string> +#include <vector> + +#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_NETWORK_HINTS_COMMON_NETWORK_HINTS_MESSAGES_H_ +#define COMPONENTS_NETWORK_HINTS_COMMON_NETWORK_HINTS_MESSAGES_H_ + +namespace IPC { + +template <> +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); +}; + +} // namespace IPC + +#endif // COMPONENTS_NETWORK_HINTS_COMMON_NETWORK_HINTS_MESSAGES_H_ + +#define IPC_MESSAGE_START DnsPrefetchMsgStart + +//----------------------------------------------------------------------------- +// Host messages +// These are messages sent from the renderer process to the browser process. + +// Request for a DNS prefetch of the names in the array. +// NameList is typedef'ed std::vector<std::string> +IPC_MESSAGE_CONTROL1(DnsPrefetchMsg_RequestPrefetch, + network_hints::LookupRequest) |