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

Side by Side Diff: content/child/npapi/npruntime_util.cc

Issue 1154283003: Change most uses of Pickle to base::Pickle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #include "content/child/npapi/npruntime_util.h" 5 #include "content/child/npapi/npruntime_util.h"
6 6
7 #include "base/pickle.h" 7 #include "base/pickle.h"
8 #include "third_party/WebKit/public/web/WebBindings.h" 8 #include "third_party/WebKit/public/web/WebBindings.h"
9 9
10 using blink::WebBindings; 10 using blink::WebBindings;
11 11
12 namespace content { 12 namespace content {
13 13
14 bool SerializeNPIdentifier(NPIdentifier identifier, Pickle* pickle) { 14 bool SerializeNPIdentifier(NPIdentifier identifier, base::Pickle* pickle) {
15 const NPUTF8* string; 15 const NPUTF8* string;
16 int32_t number; 16 int32_t number;
17 bool is_string; 17 bool is_string;
18 WebBindings::extractIdentifierData(identifier, string, number, is_string); 18 WebBindings::extractIdentifierData(identifier, string, number, is_string);
19 19
20 if (!pickle->WriteBool(is_string)) 20 if (!pickle->WriteBool(is_string))
21 return false; 21 return false;
22 if (is_string) { 22 if (is_string) {
23 // Write the null byte for efficiency on the other end. 23 // Write the null byte for efficiency on the other end.
24 return pickle->WriteData(string, strlen(string) + 1); 24 return pickle->WriteData(string, strlen(string) + 1);
25 } 25 }
26 return pickle->WriteInt(number); 26 return pickle->WriteInt(number);
27 } 27 }
28 28
29 bool DeserializeNPIdentifier(PickleIterator* pickle_iter, 29 bool DeserializeNPIdentifier(base::PickleIterator* pickle_iter,
30 NPIdentifier* identifier) { 30 NPIdentifier* identifier) {
31 bool is_string; 31 bool is_string;
32 if (!pickle_iter->ReadBool(&is_string)) 32 if (!pickle_iter->ReadBool(&is_string))
33 return false; 33 return false;
34 34
35 if (is_string) { 35 if (is_string) {
36 const char* data; 36 const char* data;
37 int data_len; 37 int data_len;
38 if (!pickle_iter->ReadData(&data, &data_len)) 38 if (!pickle_iter->ReadData(&data, &data_len))
39 return false; 39 return false;
40 DCHECK_EQ((static_cast<size_t>(data_len)), strlen(data) + 1); 40 DCHECK_EQ((static_cast<size_t>(data_len)), strlen(data) + 1);
41 *identifier = WebBindings::getStringIdentifier(data); 41 *identifier = WebBindings::getStringIdentifier(data);
42 } else { 42 } else {
43 int number; 43 int number;
44 if (!pickle_iter->ReadInt(&number)) 44 if (!pickle_iter->ReadInt(&number))
45 return false; 45 return false;
46 *identifier = WebBindings::getIntIdentifier(number); 46 *identifier = WebBindings::getIntIdentifier(number);
47 } 47 }
48 return true; 48 return true;
49 } 49 }
50 50
51 } // namespace content 51 } // namespace content
OLDNEW
« no previous file with comments | « content/child/notifications/notification_dispatcher.cc ('k') | content/child/plugin_param_traits.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698