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

Unified Diff: chrome/common/automation_messages.cc

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: _ 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
Index: chrome/common/automation_messages.cc
diff --git a/chrome/common/automation_messages.cc b/chrome/common/automation_messages.cc
index 8aadecef7a58d0ed8ec85d4a68739a95297c95fe..061e7b4552debab89fd269863425c092c15a343f 100644
--- a/chrome/common/automation_messages.cc
+++ b/chrome/common/automation_messages.cc
@@ -221,11 +221,41 @@ struct ParamTraits<net::UploadElement> {
}
};
+template<>
+struct ParamTraits<ScopedVector<net::UploadElement> > {
jam 2012/11/09 17:38:48 can you add a param traits for ScopedVector that's
hashimoto 2012/11/10 09:34:52 Moved this to ipc_messge_utils.h. I've switched f
jam 2012/11/12 20:58:54 I'm not sure what you mean. you mean when it comes
hashimoto 2012/11/13 05:03:51 I thought this size check was to avoid copying hea
+ typedef ScopedVector<net::UploadElement> 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;
+ // ReadLength() checks for < 0 itself.
+ if (!m->ReadLength(iter, &size))
+ return false;
+ r->resize(size);
+ for (int i = 0; i < size; i++) {
+ (*r)[i] = new net::UploadElement();
+ if (!ReadParam(m, iter, (*r)[i]))
+ 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);
+ }
+ }
+};
+
void ParamTraits<scoped_refptr<net::UploadData> >::Write(Message* m,
const param_type& p) {
WriteParam(m, p.get() != NULL);
if (p) {
- WriteParam(m, *p->elements());
+ WriteParam(m, p->elements());
WriteParam(m, p->identifier());
WriteParam(m, p->is_chunked());
WriteParam(m, p->last_chunk_appended());
@@ -240,7 +270,7 @@ bool ParamTraits<scoped_refptr<net::UploadData> >::Read(const Message* m,
return false;
if (!has_object)
return true;
- std::vector<net::UploadElement> elements;
+ ScopedVector<net::UploadElement> elements;
if (!ReadParam(m, iter, &elements))
return false;
int64 identifier;

Powered by Google App Engine
This is Rietveld 408576698