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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome_frame/urlmon_url_request.cc ('k') | net/base/upload_data.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_message_utils.h
diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h
index 0e4c68e513efbbc9b6a0651e625a5978dc724739..d5817d2f7c90cbf8d90875331725436aaa512ea2 100644
--- a/ipc/ipc_message_utils.h
+++ b/ipc/ipc_message_utils.h
@@ -12,6 +12,7 @@
#include <vector>
#include "base/format_macros.h"
+#include "base/memory/scoped_vector.h"
#include "base/platform_file.h"
#include "base/string16.h"
#include "base/stringprintf.h"
@@ -633,6 +634,34 @@ struct ParamTraits< Tuple5<A, B, C, D, E> > {
}
};
+template<class P>
+struct ParamTraits<ScopedVector<P> > {
+ typedef ScopedVector<P> param_type;
+ static void Write(Message* m, const param_type& p) {
+ WriteParam(m, static_cast<int>(p.size()));
+ for (size_t i = 0; i < p.size(); i++)
+ WriteParam(m, *p[i]);
+ }
+ static bool Read(const Message* m, PickleIterator* iter, param_type* r) {
+ int size = 0;
+ if (!m->ReadLength(iter, &size))
+ return false;
+ 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
+ r->push_back(new P());
+ if (!ReadParam(m, iter, r->back()))
+ return false;
+ }
+ return true;
+ }
+ static void Log(const param_type& p, std::string* l) {
+ for (size_t i = 0; i < p.size(); ++i) {
+ if (i != 0)
+ l->append(" ");
+ LogParam(*p[i], l);
+ }
+ }
+};
+
// IPC types ParamTraits -------------------------------------------------------
// A ChannelHandle is basically a platform-inspecific wrapper around the
« 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