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

Side by Side Diff: ipc/ipc_message_utils.cc

Issue 1966983003: Generate param traits size methods for IPC files in content/ (and traits it depends on). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ipc/ipc_message_utils.h" 5 #include "ipc/ipc_message_utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 } 628 }
629 629
630 void ParamTraits<base::DictionaryValue>::Log(const param_type& p, 630 void ParamTraits<base::DictionaryValue>::Log(const param_type& p,
631 std::string* l) { 631 std::string* l) {
632 std::string json; 632 std::string json;
633 base::JSONWriter::Write(p, &json); 633 base::JSONWriter::Write(p, &json);
634 l->append(json); 634 l->append(json);
635 } 635 }
636 636
637 #if defined(OS_POSIX) 637 #if defined(OS_POSIX)
638 void ParamTraits<base::FileDescriptor>::GetSize(base::PickleSizer* sizer,
639 const param_type& p) {
640 sizer->AddBool();
641 sizer->AddAttachment();
642 }
643
638 void ParamTraits<base::FileDescriptor>::Write(base::Pickle* m, 644 void ParamTraits<base::FileDescriptor>::Write(base::Pickle* m,
639 const param_type& p) { 645 const param_type& p) {
640 const bool valid = p.fd >= 0; 646 const bool valid = p.fd >= 0;
641 WriteParam(m, valid); 647 WriteParam(m, valid);
642 648
643 if (!valid) 649 if (!valid)
644 return; 650 return;
645 651
646 if (p.auto_close) { 652 if (p.auto_close) {
647 if (!m->WriteAttachment( 653 if (!m->WriteAttachment(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 std::string* l) { 686 std::string* l) {
681 if (p.auto_close) { 687 if (p.auto_close) {
682 l->append(base::StringPrintf("FD(%d auto-close)", p.fd)); 688 l->append(base::StringPrintf("FD(%d auto-close)", p.fd));
683 } else { 689 } else {
684 l->append(base::StringPrintf("FD(%d)", p.fd)); 690 l->append(base::StringPrintf("FD(%d)", p.fd));
685 } 691 }
686 } 692 }
687 #endif // defined(OS_POSIX) 693 #endif // defined(OS_POSIX)
688 694
689 #if defined(OS_MACOSX) && !defined(OS_IOS) 695 #if defined(OS_MACOSX) && !defined(OS_IOS)
696 void ParamTraits<base::SharedMemoryHandle>::GetSize(base::PickleSizer* sizer,
697 const param_type& p) {
698 GetParamSize(sizer, p.GetMemoryObject());
699 sizer->AddUInt32();
700 }
701
690 void ParamTraits<base::SharedMemoryHandle>::Write(base::Pickle* m, 702 void ParamTraits<base::SharedMemoryHandle>::Write(base::Pickle* m,
691 const param_type& p) { 703 const param_type& p) {
692 MachPortMac mach_port_mac(p.GetMemoryObject()); 704 MachPortMac mach_port_mac(p.GetMemoryObject());
693 ParamTraits<MachPortMac>::Write(m, mach_port_mac); 705 ParamTraits<MachPortMac>::Write(m, mach_port_mac);
694 size_t size = 0; 706 size_t size = 0;
695 bool result = p.GetSize(&size); 707 bool result = p.GetSize(&size);
696 DCHECK(result); 708 DCHECK(result);
697 ParamTraits<uint32_t>::Write(m, static_cast<uint32_t>(size)); 709 ParamTraits<uint32_t>::Write(m, static_cast<uint32_t>(size));
698 710
699 // If the caller intended to pass ownership to the IPC stack, release a 711 // If the caller intended to pass ownership to the IPC stack, release a
(...skipping 19 matching lines...) Expand all
719 return true; 731 return true;
720 } 732 }
721 733
722 void ParamTraits<base::SharedMemoryHandle>::Log(const param_type& p, 734 void ParamTraits<base::SharedMemoryHandle>::Log(const param_type& p,
723 std::string* l) { 735 std::string* l) {
724 l->append("Mach port: "); 736 l->append("Mach port: ");
725 LogParam(p.GetMemoryObject(), l); 737 LogParam(p.GetMemoryObject(), l);
726 } 738 }
727 739
728 #elif defined(OS_WIN) 740 #elif defined(OS_WIN)
741 void ParamTraits<base::SharedMemoryHandle>::GetSize(base::PickleSizer* s,
742 const param_type& p) {
743 s->AddBool();
744 if (p.NeedsBrokering()) {
745 GetParamSize(s, p.GetHandle());
746 } else {
747 s->AddInt();
748 }
749 }
750
729 void ParamTraits<base::SharedMemoryHandle>::Write(base::Pickle* m, 751 void ParamTraits<base::SharedMemoryHandle>::Write(base::Pickle* m,
730 const param_type& p) { 752 const param_type& p) {
731 m->WriteBool(p.NeedsBrokering()); 753 m->WriteBool(p.NeedsBrokering());
732 754
733 if (p.NeedsBrokering()) { 755 if (p.NeedsBrokering()) {
734 HandleWin handle_win(p.GetHandle(), HandleWin::DUPLICATE); 756 HandleWin handle_win(p.GetHandle(), HandleWin::DUPLICATE);
735 ParamTraits<HandleWin>::Write(m, handle_win); 757 ParamTraits<HandleWin>::Write(m, handle_win);
736 758
737 // If the caller intended to pass ownership to the IPC stack, release a 759 // If the caller intended to pass ownership to the IPC stack, release a
738 // reference. 760 // reference.
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 return result; 1196 return result;
1175 } 1197 }
1176 1198
1177 void ParamTraits<MSG>::Log(const param_type& p, std::string* l) { 1199 void ParamTraits<MSG>::Log(const param_type& p, std::string* l) {
1178 l->append("<MSG>"); 1200 l->append("<MSG>");
1179 } 1201 }
1180 1202
1181 #endif // OS_WIN 1203 #endif // OS_WIN
1182 1204
1183 } // namespace IPC 1205 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698