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

Side by Side Diff: ipc/ipc_message_utils.h

Issue 11275223: net: Change type of UploadData::elements from std::vector to ScopedVector (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome_frame/urlmon_url_request.cc ('k') | net/base/upload_data.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 #ifndef IPC_IPC_MESSAGE_UTILS_H_ 5 #ifndef IPC_IPC_MESSAGE_UTILS_H_
6 #define IPC_IPC_MESSAGE_UTILS_H_ 6 #define IPC_IPC_MESSAGE_UTILS_H_
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/format_macros.h" 14 #include "base/format_macros.h"
15 #include "base/memory/scoped_vector.h"
15 #include "base/platform_file.h" 16 #include "base/platform_file.h"
16 #include "base/string16.h" 17 #include "base/string16.h"
17 #include "base/stringprintf.h" 18 #include "base/stringprintf.h"
18 #include "base/string_util.h" 19 #include "base/string_util.h"
19 #include "base/tuple.h" 20 #include "base/tuple.h"
20 #include "ipc/ipc_message_start.h" 21 #include "ipc/ipc_message_start.h"
21 #include "ipc/ipc_param_traits.h" 22 #include "ipc/ipc_param_traits.h"
22 #include "ipc/ipc_sync_message.h" 23 #include "ipc/ipc_sync_message.h"
23 24
24 #if defined(COMPILER_GCC) 25 #if defined(COMPILER_GCC)
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 LogParam(p.b, l); 627 LogParam(p.b, l);
627 l->append(", "); 628 l->append(", ");
628 LogParam(p.c, l); 629 LogParam(p.c, l);
629 l->append(", "); 630 l->append(", ");
630 LogParam(p.d, l); 631 LogParam(p.d, l);
631 l->append(", "); 632 l->append(", ");
632 LogParam(p.e, l); 633 LogParam(p.e, l);
633 } 634 }
634 }; 635 };
635 636
637 template<class P>
638 struct ParamTraits<ScopedVector<P> > {
639 typedef ScopedVector<P> param_type;
640 static void Write(Message* m, const param_type& p) {
641 WriteParam(m, static_cast<int>(p.size()));
642 for (size_t i = 0; i < p.size(); i++)
643 WriteParam(m, *p[i]);
644 }
645 static bool Read(const Message* m, PickleIterator* iter, param_type* r) {
646 int size = 0;
647 if (!m->ReadLength(iter, &size))
648 return false;
649 if (INT_MAX/sizeof(P) <= static_cast<size_t>(size))
650 return false;
651 r->resize(size);
652 for (int i = 0; i < size; i++) {
653 (*r)[i] = new P();
654 if (!ReadParam(m, iter, (*r)[i]))
655 return false;
656 }
657 return true;
658 }
659 static void Log(const param_type& p, std::string* l) {
660 for (size_t i = 0; i < p.size(); ++i) {
661 if (i != 0)
662 l->append(" ");
663 LogParam(*p[i], l);
664 }
665 }
666 };
667
636 // IPC types ParamTraits ------------------------------------------------------- 668 // IPC types ParamTraits -------------------------------------------------------
637 669
638 // A ChannelHandle is basically a platform-inspecific wrapper around the 670 // A ChannelHandle is basically a platform-inspecific wrapper around the
639 // fact that IPC endpoints are handled specially on POSIX. See above comments 671 // fact that IPC endpoints are handled specially on POSIX. See above comments
640 // on FileDescriptor for more background. 672 // on FileDescriptor for more background.
641 template<> 673 template<>
642 struct IPC_EXPORT ParamTraits<IPC::ChannelHandle> { 674 struct IPC_EXPORT ParamTraits<IPC::ChannelHandle> {
643 typedef ChannelHandle param_type; 675 typedef ChannelHandle param_type;
644 static void Write(Message* m, const param_type& p); 676 static void Write(Message* m, const param_type& p);
645 static bool Read(const Message* m, PickleIterator* iter, param_type* r); 677 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 template<typename TA, typename TB, typename TC, typename TD, typename TE> 873 template<typename TA, typename TB, typename TC, typename TD, typename TE>
842 static void WriteReplyParams(Message* reply, TA a, TB b, TC c, TD d, TE e) { 874 static void WriteReplyParams(Message* reply, TA a, TB b, TC c, TD d, TE e) {
843 ReplyParam p(a, b, c, d, e); 875 ReplyParam p(a, b, c, d, e);
844 WriteParam(reply, p); 876 WriteParam(reply, p);
845 } 877 }
846 }; 878 };
847 879
848 } // namespace IPC 880 } // namespace IPC
849 881
850 #endif // IPC_IPC_MESSAGE_UTILS_H_ 882 #endif // IPC_IPC_MESSAGE_UTILS_H_
OLDNEW
« no previous file with comments | « chrome_frame/urlmon_url_request.cc ('k') | net/base/upload_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698