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

Side by Side Diff: ppapi/proxy/raw_var_data.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
« no previous file with comments | « ppapi/proxy/ppapi_param_traits.cc ('k') | ppapi/proxy/raw_var_data_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ppapi/proxy/raw_var_data.h" 5 #include "ppapi/proxy/raw_var_data.h"
6 6
7 #include <stack> 7 #include <stack>
8 8
9 #include "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 // Write the size, followed by each node in the graph. 178 // Write the size, followed by each node in the graph.
179 m->WriteUInt32(static_cast<uint32_t>(data_.size())); 179 m->WriteUInt32(static_cast<uint32_t>(data_.size()));
180 for (size_t i = 0; i < data_.size(); ++i) { 180 for (size_t i = 0; i < data_.size(); ++i) {
181 m->WriteInt(data_[i]->Type()); 181 m->WriteInt(data_[i]->Type());
182 data_[i]->Write(m, handle_writer); 182 data_[i]->Write(m, handle_writer);
183 } 183 }
184 } 184 }
185 185
186 // static 186 // static
187 scoped_ptr<RawVarDataGraph> RawVarDataGraph::Read(const IPC::Message* m, 187 scoped_ptr<RawVarDataGraph> RawVarDataGraph::Read(const IPC::Message* m,
188 PickleIterator* iter) { 188 base::PickleIterator* iter) {
189 scoped_ptr<RawVarDataGraph> result(new RawVarDataGraph); 189 scoped_ptr<RawVarDataGraph> result(new RawVarDataGraph);
190 uint32_t size = 0; 190 uint32_t size = 0;
191 if (!iter->ReadUInt32(&size)) 191 if (!iter->ReadUInt32(&size))
192 return scoped_ptr<RawVarDataGraph>(); 192 return scoped_ptr<RawVarDataGraph>();
193 for (uint32_t i = 0; i < size; ++i) { 193 for (uint32_t i = 0; i < size; ++i) {
194 int32_t type; 194 int32_t type;
195 if (!iter->ReadInt(&type)) 195 if (!iter->ReadInt(&type))
196 return scoped_ptr<RawVarDataGraph>(); 196 return scoped_ptr<RawVarDataGraph>();
197 PP_VarType var_type = static_cast<PP_VarType>(type); 197 PP_VarType var_type = static_cast<PP_VarType>(type);
198 result->data_.push_back(RawVarData::Create(var_type)); 198 result->data_.push_back(RawVarData::Create(var_type));
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 m->WriteInt64(var_.value.as_id); 305 m->WriteInt64(var_.value.as_id);
306 break; 306 break;
307 default: 307 default:
308 NOTREACHED(); 308 NOTREACHED();
309 break; 309 break;
310 } 310 }
311 } 311 }
312 312
313 bool BasicRawVarData::Read(PP_VarType type, 313 bool BasicRawVarData::Read(PP_VarType type,
314 const IPC::Message* m, 314 const IPC::Message* m,
315 PickleIterator* iter) { 315 base::PickleIterator* iter) {
316 PP_Var result; 316 PP_Var result;
317 result.type = type; 317 result.type = type;
318 switch (type) { 318 switch (type) {
319 case PP_VARTYPE_UNDEFINED: 319 case PP_VARTYPE_UNDEFINED:
320 case PP_VARTYPE_NULL: 320 case PP_VARTYPE_NULL:
321 // These don't have any data associated with them other than the type we 321 // These don't have any data associated with them other than the type we
322 // just deserialized. 322 // just deserialized.
323 break; 323 break;
324 case PP_VARTYPE_BOOL: { 324 case PP_VARTYPE_BOOL: {
325 bool bool_value; 325 bool bool_value;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 const std::vector<PP_Var>& graph) { 377 const std::vector<PP_Var>& graph) {
378 } 378 }
379 379
380 void StringRawVarData::Write(IPC::Message* m, 380 void StringRawVarData::Write(IPC::Message* m,
381 const HandleWriter& handle_writer) { 381 const HandleWriter& handle_writer) {
382 m->WriteString(data_); 382 m->WriteString(data_);
383 } 383 }
384 384
385 bool StringRawVarData::Read(PP_VarType type, 385 bool StringRawVarData::Read(PP_VarType type,
386 const IPC::Message* m, 386 const IPC::Message* m,
387 PickleIterator* iter) { 387 base::PickleIterator* iter) {
388 if (!iter->ReadString(&data_)) 388 if (!iter->ReadString(&data_))
389 return false; 389 return false;
390 return true; 390 return true;
391 } 391 }
392 392
393 // ArrayBufferRawVarData ------------------------------------------------------- 393 // ArrayBufferRawVarData -------------------------------------------------------
394 ArrayBufferRawVarData::ArrayBufferRawVarData() { 394 ArrayBufferRawVarData::ArrayBufferRawVarData() {
395 } 395 }
396 396
397 ArrayBufferRawVarData::~ArrayBufferRawVarData() { 397 ArrayBufferRawVarData::~ArrayBufferRawVarData() {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 handle_writer.Run(m, plugin_shm_handle_); 494 handle_writer.Run(m, plugin_shm_handle_);
495 break; 495 break;
496 case ARRAY_BUFFER_NO_SHMEM: 496 case ARRAY_BUFFER_NO_SHMEM:
497 m->WriteString(data_); 497 m->WriteString(data_);
498 break; 498 break;
499 } 499 }
500 } 500 }
501 501
502 bool ArrayBufferRawVarData::Read(PP_VarType type, 502 bool ArrayBufferRawVarData::Read(PP_VarType type,
503 const IPC::Message* m, 503 const IPC::Message* m,
504 PickleIterator* iter) { 504 base::PickleIterator* iter) {
505 int shmem_type; 505 int shmem_type;
506 if (!iter->ReadInt(&shmem_type)) 506 if (!iter->ReadInt(&shmem_type))
507 return false; 507 return false;
508 type_ = static_cast<ShmemType>(shmem_type); 508 type_ = static_cast<ShmemType>(shmem_type);
509 switch (type_) { 509 switch (type_) {
510 case ARRAY_BUFFER_SHMEM_HOST: 510 case ARRAY_BUFFER_SHMEM_HOST:
511 if (!iter->ReadInt(&host_shm_handle_id_)) 511 if (!iter->ReadInt(&host_shm_handle_id_))
512 return false; 512 return false;
513 break; 513 break;
514 case ARRAY_BUFFER_SHMEM_PLUGIN: 514 case ARRAY_BUFFER_SHMEM_PLUGIN:
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 575
576 void ArrayRawVarData::Write(IPC::Message* m, 576 void ArrayRawVarData::Write(IPC::Message* m,
577 const HandleWriter& handle_writer) { 577 const HandleWriter& handle_writer) {
578 m->WriteUInt32(static_cast<uint32_t>(children_.size())); 578 m->WriteUInt32(static_cast<uint32_t>(children_.size()));
579 for (size_t i = 0; i < children_.size(); ++i) 579 for (size_t i = 0; i < children_.size(); ++i)
580 m->WriteUInt32(static_cast<uint32_t>(children_[i])); 580 m->WriteUInt32(static_cast<uint32_t>(children_[i]));
581 } 581 }
582 582
583 bool ArrayRawVarData::Read(PP_VarType type, 583 bool ArrayRawVarData::Read(PP_VarType type,
584 const IPC::Message* m, 584 const IPC::Message* m,
585 PickleIterator* iter) { 585 base::PickleIterator* iter) {
586 uint32_t size; 586 uint32_t size;
587 if (!iter->ReadUInt32(&size)) 587 if (!iter->ReadUInt32(&size))
588 return false; 588 return false;
589 for (uint32_t i = 0; i < size; ++i) { 589 for (uint32_t i = 0; i < size; ++i) {
590 uint32_t index; 590 uint32_t index;
591 if (!iter->ReadUInt32(&index)) 591 if (!iter->ReadUInt32(&index))
592 return false; 592 return false;
593 children_.push_back(index); 593 children_.push_back(index);
594 } 594 }
595 return true; 595 return true;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 const HandleWriter& handle_writer) { 641 const HandleWriter& handle_writer) {
642 m->WriteUInt32(static_cast<uint32_t>(children_.size())); 642 m->WriteUInt32(static_cast<uint32_t>(children_.size()));
643 for (size_t i = 0; i < children_.size(); ++i) { 643 for (size_t i = 0; i < children_.size(); ++i) {
644 m->WriteString(children_[i].first); 644 m->WriteString(children_[i].first);
645 m->WriteUInt32(static_cast<uint32_t>(children_[i].second)); 645 m->WriteUInt32(static_cast<uint32_t>(children_[i].second));
646 } 646 }
647 } 647 }
648 648
649 bool DictionaryRawVarData::Read(PP_VarType type, 649 bool DictionaryRawVarData::Read(PP_VarType type,
650 const IPC::Message* m, 650 const IPC::Message* m,
651 PickleIterator* iter) { 651 base::PickleIterator* iter) {
652 uint32_t size; 652 uint32_t size;
653 if (!iter->ReadUInt32(&size)) 653 if (!iter->ReadUInt32(&size))
654 return false; 654 return false;
655 for (uint32_t i = 0; i < size; ++i) { 655 for (uint32_t i = 0; i < size; ++i) {
656 std::string key; 656 std::string key;
657 uint32_t value; 657 uint32_t value;
658 if (!iter->ReadString(&key)) 658 if (!iter->ReadString(&key))
659 return false; 659 return false;
660 if (!iter->ReadUInt32(&value)) 660 if (!iter->ReadUInt32(&value))
661 return false; 661 return false;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 m->WriteInt(static_cast<int>(pp_resource_)); 718 m->WriteInt(static_cast<int>(pp_resource_));
719 m->WriteInt(pending_renderer_host_id_); 719 m->WriteInt(pending_renderer_host_id_);
720 m->WriteInt(pending_browser_host_id_); 720 m->WriteInt(pending_browser_host_id_);
721 m->WriteBool(creation_message_); 721 m->WriteBool(creation_message_);
722 if (creation_message_) 722 if (creation_message_)
723 IPC::ParamTraits<IPC::Message>::Write(m, *creation_message_); 723 IPC::ParamTraits<IPC::Message>::Write(m, *creation_message_);
724 } 724 }
725 725
726 bool ResourceRawVarData::Read(PP_VarType type, 726 bool ResourceRawVarData::Read(PP_VarType type,
727 const IPC::Message* m, 727 const IPC::Message* m,
728 PickleIterator* iter) { 728 base::PickleIterator* iter) {
729 int value; 729 int value;
730 if (!iter->ReadInt(&value)) 730 if (!iter->ReadInt(&value))
731 return false; 731 return false;
732 pp_resource_ = static_cast<PP_Resource>(value); 732 pp_resource_ = static_cast<PP_Resource>(value);
733 if (!iter->ReadInt(&pending_renderer_host_id_)) 733 if (!iter->ReadInt(&pending_renderer_host_id_))
734 return false; 734 return false;
735 if (!iter->ReadInt(&pending_browser_host_id_)) 735 if (!iter->ReadInt(&pending_browser_host_id_))
736 return false; 736 return false;
737 bool has_creation_message; 737 bool has_creation_message;
738 if (!iter->ReadBool(&has_creation_message)) 738 if (!iter->ReadBool(&has_creation_message))
739 return false; 739 return false;
740 if (has_creation_message) { 740 if (has_creation_message) {
741 creation_message_.reset(new IPC::Message()); 741 creation_message_.reset(new IPC::Message());
742 if (!IPC::ParamTraits<IPC::Message>::Read(m, iter, creation_message_.get())) 742 if (!IPC::ParamTraits<IPC::Message>::Read(m, iter, creation_message_.get()))
743 return false; 743 return false;
744 } else { 744 } else {
745 creation_message_.reset(); 745 creation_message_.reset();
746 } 746 }
747 return true; 747 return true;
748 } 748 }
749 749
750 } // namespace proxy 750 } // namespace proxy
751 } // namespace ppapi 751 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppapi_param_traits.cc ('k') | ppapi/proxy/raw_var_data_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698