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

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: rebase Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
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..ec4f1d5ad67bd67449f2fe06ea68f5e295202bb7
--- /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)
palmer 2014/10/31 18:46:23 There's more to a hostname's validity than its len
+ 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::UintToString(p.hostname_list.size()));
+ l->append(" hostnames>");
+}
+
+} // namespace IPC

Powered by Google App Engine
This is Rietveld 408576698