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

Unified Diff: components/dns_prefetch/common/prefetch_messages.cc

Issue 644123002: Componentize renderer side of DNS prefetching. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: trybot fixes: 1) hide gyp target from ios 2) UintToString --> SizeTToString Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/dns_prefetch/common/prefetch_messages.h ('k') | components/dns_prefetch/renderer/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/dns_prefetch/common/prefetch_messages.cc
diff --git a/components/dns_prefetch/common/prefetch_messages.cc b/components/dns_prefetch/common/prefetch_messages.cc
new file mode 100644
index 0000000000000000000000000000000000000000..315ed92c6339917bfbc2365f03f8b1c47f68648c
--- /dev/null
+++ b/components/dns_prefetch/common/prefetch_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/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
« no previous file with comments | « components/dns_prefetch/common/prefetch_messages.h ('k') | components/dns_prefetch/renderer/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698