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

Side by Side 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: Adds IPC::ParamTraits<LookupRequest> for validation 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/dns_prefetch/common/prefetch_messages.h"
6
7 #include "base/strings/string_number_conversions.h"
8 #include "components/dns_prefetch/common/prefetch_common.h"
9
10 namespace IPC {
11
12 void ParamTraits<dns_prefetch::LookupRequest>::Write(
13 Message* m, const dns_prefetch::LookupRequest& request) {
14 IPC::WriteParam(m, request.hostname_list);
15 }
16
17 bool ParamTraits<dns_prefetch::LookupRequest>::Read(
18 const Message* m,
19 PickleIterator* iter,
20 dns_prefetch::LookupRequest* request) {
21 // Verify the hostname limits after deserialization success.
22 if (IPC::ReadParam(m, iter, &request->hostname_list)) {
23 dns_prefetch::NameList& hostnames = request->hostname_list;
24 if (hostnames.size() > dns_prefetch::kMaxDnsHostnamesPerRequest)
25 return false;
26
27 for (dns_prefetch::NameList::const_iterator it = hostnames.begin();
Nico 2014/10/30 00:03:05 if you want, you can write for (const auot& hos
gunsch 2014/10/30 00:32:50 Done.
28 it < hostnames.end();
29 ++it) {
30 if (it->length() > dns_prefetch::kMaxDnsHostnameLength)
31 return false;
32 }
33 }
34 return true;
35 }
36
37 void ParamTraits<dns_prefetch::LookupRequest>::Log(
38 const dns_prefetch::LookupRequest& p, std::string* l) {
39 l->append("<dns_prefetch::LookupRequest: ");
40 l->append(base::UintToString(p.hostname_list.size()));
41 l->append(" hostnames>");
42 }
43
44 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698