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

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: Move ParamTraits to ipc_message_utils.h 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 for (int i = 0; i < size; i++) {
jam 2012/11/12 20:58:54 you should do error checking just like std::vector
hashimoto 2012/11/13 05:03:51 What is still unclear for me is that do we need to
650 r->push_back(new P());
651 if (!ReadParam(m, iter, r->back()))
652 return false;
653 }
654 return true;
655 }
656 static void Log(const param_type& p, std::string* l) {
657 for (size_t i = 0; i < p.size(); ++i) {
658 if (i != 0)
659 l->append(" ");
660 LogParam(*p[i], l);
661 }
662 }
663 };
664
636 // IPC types ParamTraits ------------------------------------------------------- 665 // IPC types ParamTraits -------------------------------------------------------
637 666
638 // A ChannelHandle is basically a platform-inspecific wrapper around the 667 // A ChannelHandle is basically a platform-inspecific wrapper around the
639 // fact that IPC endpoints are handled specially on POSIX. See above comments 668 // fact that IPC endpoints are handled specially on POSIX. See above comments
640 // on FileDescriptor for more background. 669 // on FileDescriptor for more background.
641 template<> 670 template<>
642 struct IPC_EXPORT ParamTraits<IPC::ChannelHandle> { 671 struct IPC_EXPORT ParamTraits<IPC::ChannelHandle> {
643 typedef ChannelHandle param_type; 672 typedef ChannelHandle param_type;
644 static void Write(Message* m, const param_type& p); 673 static void Write(Message* m, const param_type& p);
645 static bool Read(const Message* m, PickleIterator* iter, param_type* r); 674 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> 870 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) { 871 static void WriteReplyParams(Message* reply, TA a, TB b, TC c, TD d, TE e) {
843 ReplyParam p(a, b, c, d, e); 872 ReplyParam p(a, b, c, d, e);
844 WriteParam(reply, p); 873 WriteParam(reply, p);
845 } 874 }
846 }; 875 };
847 876
848 } // namespace IPC 877 } // namespace IPC
849 878
850 #endif // IPC_IPC_MESSAGE_UTILS_H_ 879 #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