OLD | NEW |
| (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/network_hints/common/network_hints_messages.h" | |
6 | |
7 #include "base/strings/string_number_conversions.h" | |
8 #include "components/network_hints/common/network_hints_common.h" | |
9 | |
10 namespace IPC { | |
11 | |
12 void ParamTraits<network_hints::LookupRequest>::Write( | |
13 base::Pickle* m, | |
14 const network_hints::LookupRequest& request) { | |
15 IPC::WriteParam(m, request.hostname_list); | |
16 } | |
17 | |
18 bool ParamTraits<network_hints::LookupRequest>::Read( | |
19 const base::Pickle* m, | |
20 base::PickleIterator* iter, | |
21 network_hints::LookupRequest* request) { | |
22 // Verify the hostname limits after deserialization success. | |
23 if (IPC::ReadParam(m, iter, &request->hostname_list)) { | |
24 network_hints::NameList& hostnames = request->hostname_list; | |
25 if (hostnames.size() > network_hints::kMaxDnsHostnamesPerRequest) | |
26 return false; | |
27 | |
28 for (const auto& hostname : hostnames) { | |
29 if (hostname.length() > network_hints::kMaxDnsHostnameLength) | |
30 return false; | |
31 } | |
32 } | |
33 return true; | |
34 } | |
35 | |
36 void ParamTraits<network_hints::LookupRequest>::Log( | |
37 const network_hints::LookupRequest& p, std::string* l) { | |
38 l->append("<network_hints::LookupRequest: "); | |
39 l->append(base::SizeTToString(p.hostname_list.size())); | |
40 l->append(" hostnames>"); | |
41 } | |
42 | |
43 } // namespace IPC | |
OLD | NEW |