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

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: fix owners 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
« no previous file with comments | « ipc/ipc_message_utils.h ('k') | ipc/mach_port_mac.h » ('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) 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 GetParamSize(sizer, p.fd >= 0);
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 uint32_t dummy = 0;
700 GetParamSize(sizer, dummy);
701 }
702
690 void ParamTraits<base::SharedMemoryHandle>::Write(base::Pickle* m, 703 void ParamTraits<base::SharedMemoryHandle>::Write(base::Pickle* m,
691 const param_type& p) { 704 const param_type& p) {
692 MachPortMac mach_port_mac(p.GetMemoryObject()); 705 MachPortMac mach_port_mac(p.GetMemoryObject());
693 ParamTraits<MachPortMac>::Write(m, mach_port_mac); 706 ParamTraits<MachPortMac>::Write(m, mach_port_mac);
694 size_t size = 0; 707 size_t size = 0;
695 bool result = p.GetSize(&size); 708 bool result = p.GetSize(&size);
696 DCHECK(result); 709 DCHECK(result);
697 ParamTraits<uint32_t>::Write(m, static_cast<uint32_t>(size)); 710 ParamTraits<uint32_t>::Write(m, static_cast<uint32_t>(size));
698 711
699 // If the caller intended to pass ownership to the IPC stack, release a 712 // If the caller intended to pass ownership to the IPC stack, release a
(...skipping 19 matching lines...) Expand all
719 return true; 732 return true;
720 } 733 }
721 734
722 void ParamTraits<base::SharedMemoryHandle>::Log(const param_type& p, 735 void ParamTraits<base::SharedMemoryHandle>::Log(const param_type& p,
723 std::string* l) { 736 std::string* l) {
724 l->append("Mach port: "); 737 l->append("Mach port: ");
725 LogParam(p.GetMemoryObject(), l); 738 LogParam(p.GetMemoryObject(), l);
726 } 739 }
727 740
728 #elif defined(OS_WIN) 741 #elif defined(OS_WIN)
742 void ParamTraits<base::SharedMemoryHandle>::GetSize(base::PickleSizer* s,
743 const param_type& p) {
744 GetParamSize(s, p.NeedsBrokering());
745 if (p.NeedsBrokering()) {
746 GetParamSize(s, p.GetHandle());
747 } else {
748 GetParamSize(s, HandleToLong(p.GetHandle()));
749 }
750 }
751
729 void ParamTraits<base::SharedMemoryHandle>::Write(base::Pickle* m, 752 void ParamTraits<base::SharedMemoryHandle>::Write(base::Pickle* m,
730 const param_type& p) { 753 const param_type& p) {
731 m->WriteBool(p.NeedsBrokering()); 754 m->WriteBool(p.NeedsBrokering());
732 755
733 if (p.NeedsBrokering()) { 756 if (p.NeedsBrokering()) {
734 HandleWin handle_win(p.GetHandle(), HandleWin::DUPLICATE); 757 HandleWin handle_win(p.GetHandle(), HandleWin::DUPLICATE);
735 ParamTraits<HandleWin>::Write(m, handle_win); 758 ParamTraits<HandleWin>::Write(m, handle_win);
736 759
737 // If the caller intended to pass ownership to the IPC stack, release a 760 // If the caller intended to pass ownership to the IPC stack, release a
738 // reference. 761 // reference.
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 return result; 1197 return result;
1175 } 1198 }
1176 1199
1177 void ParamTraits<MSG>::Log(const param_type& p, std::string* l) { 1200 void ParamTraits<MSG>::Log(const param_type& p, std::string* l) {
1178 l->append("<MSG>"); 1201 l->append("<MSG>");
1179 } 1202 }
1180 1203
1181 #endif // OS_WIN 1204 #endif // OS_WIN
1182 1205
1183 } // namespace IPC 1206 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/ipc_message_utils.h ('k') | ipc/mach_port_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698