diff options
-rw-r--r-- | chrome/common/common_param_traits.cc | 101 | ||||
-rw-r--r-- | chrome/common/common_param_traits.h | 21 | ||||
-rw-r--r-- | chrome/common/render_messages.cc | 100 | ||||
-rw-r--r-- | chrome/common/render_messages.h | 12 | ||||
-rw-r--r-- | webkit/blob/blob_data.cc | 12 | ||||
-rw-r--r-- | webkit/blob/blob_data.h | 11 |
6 files changed, 136 insertions, 121 deletions
diff --git a/chrome/common/common_param_traits.cc b/chrome/common/common_param_traits.cc index b92921a..d18c6c5 100644 --- a/chrome/common/common_param_traits.cc +++ b/chrome/common/common_param_traits.cc @@ -18,7 +18,6 @@ #ifndef EXCLUDE_SKIA_DEPENDENCIES #include "third_party/skia/include/core/SkBitmap.h" #endif -#include "webkit/blob/blob_data.h" #include "webkit/glue/dom_operations.h" #include "webkit/glue/password_form.h" @@ -410,106 +409,6 @@ void ParamTraits<scoped_refptr<net::UploadData> >::Log(const param_type& p, l->append("<net::UploadData>"); } -// Only the webkit_blob::BlobData ParamTraits<> definition needs this -// definition, so keep this in the implementation file so we can forward declare -// BlobData in the header. -template <> -struct ParamTraits<webkit_blob::BlobData::Item> { - typedef webkit_blob::BlobData::Item param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, static_cast<int>(p.type())); - if (p.type() == webkit_blob::BlobData::TYPE_DATA) { - WriteParam(m, p.data()); - } else if (p.type() == webkit_blob::BlobData::TYPE_FILE) { - WriteParam(m, p.file_path()); - WriteParam(m, p.offset()); - WriteParam(m, p.length()); - WriteParam(m, p.expected_modification_time()); - } else { - WriteParam(m, p.blob_url()); - WriteParam(m, p.offset()); - WriteParam(m, p.length()); - } - } - static bool Read(const Message* m, void** iter, param_type* r) { - int type; - if (!ReadParam(m, iter, &type)) - return false; - if (type == webkit_blob::BlobData::TYPE_DATA) { - std::string data; - if (!ReadParam(m, iter, &data)) - return false; - r->SetToData(data); - } else if (type == webkit_blob::BlobData::TYPE_FILE) { - FilePath file_path; - uint64 offset, length; - base::Time expected_modification_time; - if (!ReadParam(m, iter, &file_path)) - return false; - if (!ReadParam(m, iter, &offset)) - return false; - if (!ReadParam(m, iter, &length)) - return false; - if (!ReadParam(m, iter, &expected_modification_time)) - return false; - r->SetToFile(file_path, offset, length, expected_modification_time); - } else { - DCHECK(type == webkit_blob::BlobData::TYPE_BLOB); - GURL blob_url; - uint64 offset, length; - if (!ReadParam(m, iter, &blob_url)) - return false; - if (!ReadParam(m, iter, &offset)) - return false; - if (!ReadParam(m, iter, &length)) - return false; - r->SetToBlob(blob_url, offset, length); - } - return true; - } - static void Log(const param_type& p, std::string* l) { - l->append("<BlobData::Item>"); - } -}; - -void ParamTraits<scoped_refptr<webkit_blob::BlobData> >::Write( - Message* m, const param_type& p) { - WriteParam(m, p.get() != NULL); - if (p) { - WriteParam(m, p->items()); - WriteParam(m, p->content_type()); - WriteParam(m, p->content_disposition()); - } -} - -bool ParamTraits<scoped_refptr<webkit_blob::BlobData> >::Read( - const Message* m, void** iter, param_type* r) { - bool has_object; - if (!ReadParam(m, iter, &has_object)) - return false; - if (!has_object) - return true; - std::vector<webkit_blob::BlobData::Item> items; - if (!ReadParam(m, iter, &items)) - return false; - std::string content_type; - if (!ReadParam(m, iter, &content_type)) - return false; - std::string content_disposition; - if (!ReadParam(m, iter, &content_disposition)) - return false; - *r = new webkit_blob::BlobData; - (*r)->swap_items(&items); - (*r)->set_content_type(content_type); - (*r)->set_content_disposition(content_disposition); - return true; -} - -void ParamTraits<scoped_refptr<webkit_blob::BlobData> >::Log( - const param_type& p, std::string* l) { - l->append("<webkit_blob::BlobData>"); -} - void ParamTraits<ThumbnailScore>::Write(Message* m, const param_type& p) { IPC::ParamTraits<double>::Write(m, p.boring_score); IPC::ParamTraits<bool>::Write(m, p.good_clipping); diff --git a/chrome/common/common_param_traits.h b/chrome/common/common_param_traits.h index 11c9749..d8796d6 100644 --- a/chrome/common/common_param_traits.h +++ b/chrome/common/common_param_traits.h @@ -21,6 +21,14 @@ #include "ipc/ipc_message_utils.h" #include "net/url_request/url_request_status.h" #include "printing/native_metafile.h" +// !!! WARNING: DO NOT ADD NEW WEBKIT DEPENDENCIES !!! +// +// That means don't add #includes to any file in 'webkit/' or +// 'third_party/WebKit/'. Chrome Frame and NACL build parts of base/ and +// chrome/common/ for a mini-library that doesn't depend on webkit. +// +// TODO(erg): The following two headers are historical and only work because +// their definitions are inlined, which also needs to be fixed. #include "webkit/glue/webcursor.h" #include "webkit/glue/window_open_disposition.h" @@ -48,10 +56,6 @@ namespace printing { struct PageRange; } // namespace printing -namespace webkit_blob { -class BlobData; -} - namespace webkit_glue { struct PasswordForm; struct WebApplicationInfo; @@ -275,15 +279,6 @@ struct ParamTraits<scoped_refptr<net::UploadData> > { static void Log(const param_type& p, std::string* l); }; -// Traits for webkit_blob::BlobData. -template <> -struct ParamTraits<scoped_refptr<webkit_blob::BlobData> > { - typedef scoped_refptr<webkit_blob::BlobData> param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); - static void Log(const param_type& p, std::string* l); -}; - template<> struct ParamTraits<ThumbnailScore> { typedef ThumbnailScore param_type; diff --git a/chrome/common/render_messages.cc b/chrome/common/render_messages.cc index b6e6d66..f437bf4 100644 --- a/chrome/common/render_messages.cc +++ b/chrome/common/render_messages.cc @@ -1084,6 +1084,106 @@ void ParamTraits<webkit_glue::WebAccessibility>::Log(const param_type& p, l->append(")"); } +// Only the webkit_blob::BlobData ParamTraits<> definition needs this +// definition, so keep this in the implementation file so we can forward declare +// BlobData in the header. +template <> +struct ParamTraits<webkit_blob::BlobData::Item> { + typedef webkit_blob::BlobData::Item param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, static_cast<int>(p.type())); + if (p.type() == webkit_blob::BlobData::TYPE_DATA) { + WriteParam(m, p.data()); + } else if (p.type() == webkit_blob::BlobData::TYPE_FILE) { + WriteParam(m, p.file_path()); + WriteParam(m, p.offset()); + WriteParam(m, p.length()); + WriteParam(m, p.expected_modification_time()); + } else { + WriteParam(m, p.blob_url()); + WriteParam(m, p.offset()); + WriteParam(m, p.length()); + } + } + static bool Read(const Message* m, void** iter, param_type* r) { + int type; + if (!ReadParam(m, iter, &type)) + return false; + if (type == webkit_blob::BlobData::TYPE_DATA) { + std::string data; + if (!ReadParam(m, iter, &data)) + return false; + r->SetToData(data); + } else if (type == webkit_blob::BlobData::TYPE_FILE) { + FilePath file_path; + uint64 offset, length; + base::Time expected_modification_time; + if (!ReadParam(m, iter, &file_path)) + return false; + if (!ReadParam(m, iter, &offset)) + return false; + if (!ReadParam(m, iter, &length)) + return false; + if (!ReadParam(m, iter, &expected_modification_time)) + return false; + r->SetToFile(file_path, offset, length, expected_modification_time); + } else { + DCHECK(type == webkit_blob::BlobData::TYPE_BLOB); + GURL blob_url; + uint64 offset, length; + if (!ReadParam(m, iter, &blob_url)) + return false; + if (!ReadParam(m, iter, &offset)) + return false; + if (!ReadParam(m, iter, &length)) + return false; + r->SetToBlob(blob_url, offset, length); + } + return true; + } + static void Log(const param_type& p, std::string* l) { + l->append("<BlobData::Item>"); + } +}; + +void ParamTraits<scoped_refptr<webkit_blob::BlobData> >::Write( + Message* m, const param_type& p) { + WriteParam(m, p.get() != NULL); + if (p) { + WriteParam(m, p->items()); + WriteParam(m, p->content_type()); + WriteParam(m, p->content_disposition()); + } +} + +bool ParamTraits<scoped_refptr<webkit_blob::BlobData> >::Read( + const Message* m, void** iter, param_type* r) { + bool has_object; + if (!ReadParam(m, iter, &has_object)) + return false; + if (!has_object) + return true; + std::vector<webkit_blob::BlobData::Item> items; + if (!ReadParam(m, iter, &items)) + return false; + std::string content_type; + if (!ReadParam(m, iter, &content_type)) + return false; + std::string content_disposition; + if (!ReadParam(m, iter, &content_disposition)) + return false; + *r = new webkit_blob::BlobData; + (*r)->swap_items(&items); + (*r)->set_content_type(content_type); + (*r)->set_content_disposition(content_disposition); + return true; +} + +void ParamTraits<scoped_refptr<webkit_blob::BlobData> >::Log( + const param_type& p, std::string* l) { + l->append("<webkit_blob::BlobData>"); +} + void ParamTraits<AudioBuffersState>::Write(Message* m, const param_type& p) { WriteParam(m, p.pending_bytes); WriteParam(m, p.hardware_delay_bytes); diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index ce893d2..da54616 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -49,6 +49,10 @@ class HttpResponseHeaders; class UploadData; } +namespace webkit_blob { +class BlobData; +} + namespace webkit_glue { struct FormData; class FormField; @@ -587,6 +591,14 @@ struct ParamTraits<webkit_glue::WebAccessibility> { static void Log(const param_type& p, std::string* l); }; +template <> +struct ParamTraits<scoped_refptr<webkit_blob::BlobData> > { + typedef scoped_refptr<webkit_blob::BlobData> param_type; + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, void** iter, param_type* r); + static void Log(const param_type& p, std::string* l); +}; + // Traits for base::PlatformFileError template <> struct SimilarTypeTraits<base::PlatformFileError> { diff --git a/webkit/blob/blob_data.cc b/webkit/blob/blob_data.cc index 838014b..026408e 100644 --- a/webkit/blob/blob_data.cc +++ b/webkit/blob/blob_data.cc @@ -17,6 +17,16 @@ using WebKit::WebString; namespace webkit_blob { +BlobData::Item::Item() + : type_(TYPE_DATA), + offset_(0), + length_(0) { +} + +BlobData::Item::~Item() {} + +BlobData::BlobData() {} + BlobData::BlobData(const WebBlobData& data) { size_t i = 0; WebBlobData::Item item; @@ -52,4 +62,6 @@ BlobData::BlobData(const WebBlobData& data) { content_disposition_ = data.contentDisposition().utf8().data(); } +BlobData::~BlobData() {} + } // namespace webkit_blob diff --git a/webkit/blob/blob_data.h b/webkit/blob/blob_data.h index 3be694f..9764ce4 100644 --- a/webkit/blob/blob_data.h +++ b/webkit/blob/blob_data.h @@ -30,11 +30,8 @@ class BlobData : public base::RefCounted<BlobData> { class Item { public: - Item() - : type_(TYPE_DATA), - offset_(0), - length_(0) { - } + Item(); + ~Item(); Type type() const { return type_; } const std::string& data() const { return data_; } @@ -91,7 +88,7 @@ class BlobData : public base::RefCounted<BlobData> { base::Time expected_modification_time_; }; - BlobData() { } + BlobData(); explicit BlobData(const WebKit::WebBlobData& data); void AppendData(const std::string& data) { @@ -144,7 +141,7 @@ class BlobData : public base::RefCounted<BlobData> { private: friend class base::RefCounted<BlobData>; - virtual ~BlobData() { } + virtual ~BlobData(); std::string content_type_; std::string content_disposition_; |