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

Side by Side Diff: chrome/common/safe_browsing/protobuf_message_param_traits.h

Issue 1659003003: IPC::Message -> base::Pickle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: one more mac fix Created 4 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_COMMON_SAFE_BROWSING_PROTOBUF_MESSAGE_PARAM_TRAITS_H_ 5 #ifndef CHROME_COMMON_SAFE_BROWSING_PROTOBUF_MESSAGE_PARAM_TRAITS_H_
6 #define CHROME_COMMON_SAFE_BROWSING_PROTOBUF_MESSAGE_PARAM_TRAITS_H_ 6 #define CHROME_COMMON_SAFE_BROWSING_PROTOBUF_MESSAGE_PARAM_TRAITS_H_
7 7
8 #include <limits.h> 8 #include <limits.h>
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/pickle.h" 12 #include "base/pickle.h"
13 #include "ipc/ipc_message.h" 13 #include "ipc/ipc_message.h"
14 #include "ipc/ipc_param_traits.h" 14 #include "ipc/ipc_param_traits.h"
15 #include "third_party/protobuf/src/google/protobuf/repeated_field.h" 15 #include "third_party/protobuf/src/google/protobuf/repeated_field.h"
16 16
17 namespace IPC { 17 namespace IPC {
18 18
19 template <class Element> 19 template <class Element>
20 struct ParamTraits<google::protobuf::RepeatedPtrField<Element>> { 20 struct ParamTraits<google::protobuf::RepeatedPtrField<Element>> {
21 typedef google::protobuf::RepeatedPtrField<Element> param_type; 21 typedef google::protobuf::RepeatedPtrField<Element> param_type;
22 22
23 static void Write(Message* m, const param_type& p) { 23 static void Write(base::Pickle* m, const param_type& p) {
24 WriteParam(m, p.size()); 24 WriteParam(m, p.size());
25 for (const auto& element : p) 25 for (const auto& element : p)
26 WriteParam(m, element); 26 WriteParam(m, element);
27 } 27 }
28 28
29 static bool Read(const Message* m, 29 static bool Read(const base::Pickle* m,
30 base::PickleIterator* iter, 30 base::PickleIterator* iter,
31 param_type* p) { 31 param_type* p) {
32 int size; 32 int size;
33 if (!iter->ReadLength(&size) || size < 0) 33 if (!iter->ReadLength(&size) || size < 0)
34 return false; 34 return false;
35 if (INT_MAX / static_cast<int>(sizeof(void*)) <= size) 35 if (INT_MAX / static_cast<int>(sizeof(void*)) <= size)
36 return false; 36 return false;
37 p->Clear(); 37 p->Clear();
38 p->Reserve(size); 38 p->Reserve(size);
39 while (size--) { 39 while (size--) {
(...skipping 11 matching lines...) Expand all
51 else 51 else
52 logged_first = true; 52 logged_first = true;
53 LogParam(element, l); 53 LogParam(element, l);
54 } 54 }
55 } 55 }
56 }; 56 };
57 57
58 } // namespace IPC 58 } // namespace IPC
59 59
60 #endif // CHROME_COMMON_SAFE_BROWSING_PROTOBUF_MESSAGE_PARAM_TRAITS_H_ 60 #endif // CHROME_COMMON_SAFE_BROWSING_PROTOBUF_MESSAGE_PARAM_TRAITS_H_
OLDNEW
« no previous file with comments | « chrome/common/safe_browsing/ipc_protobuf_message_macros.h ('k') | chrome/common/safe_browsing/protobuf_message_read_macros.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698