diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-25 15:04:22 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-25 15:04:22 +0000 |
commit | 9d8ea308b93fdd1b78cded9e604268e9752e2909 (patch) | |
tree | 5a4e49524786f0fb259726e0f92bb1fd64ed01ac | |
parent | 20cd74f9317b37e8faee699dfdf7dcf2a7eea12c (diff) | |
download | chromium_src-9d8ea308b93fdd1b78cded9e604268e9752e2909.zip chromium_src-9d8ea308b93fdd1b78cded9e604268e9752e2909.tar.gz chromium_src-9d8ea308b93fdd1b78cded9e604268e9752e2909.tar.bz2 |
Cleanup the IPC param traits structure:
-traits that are only used by chrome should be in chrome
-traits that aren't used by chrome shouldn't be in content/public
-use macros for serialization where possible
-traits that are only used by one message file should just be listed in it
-get rid of webkit_param_traits since it's not needed anymore. It was added as a hack to keep npchrome_frame.dll's size small by giving a hint to the MSVS linker, but now that there's more split between the message files because of the content split it's not necessary anymore. I've verified that npchrome_frame.dll's size (Release, non-component) size doesn't change.
Review URL: https://codereview.chromium.org/10980010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@158570 0039d316-1c4b-4281-b951-d872f2087c98
34 files changed, 1028 insertions, 1103 deletions
diff --git a/chrome/browser/component_updater/component_updater_service.cc b/chrome/browser/component_updater/component_updater_service.cc index cbf3e99..f005a44 100644 --- a/chrome/browser/component_updater/component_updater_service.cc +++ b/chrome/browser/component_updater/component_updater_service.cc @@ -33,6 +33,7 @@ #include "net/base/load_flags.h" #include "net/url_request/url_fetcher.h" #include "net/url_request/url_fetcher_delegate.h" +#include "net/url_request/url_request_status.h" using content::BrowserThread; using content::UtilityProcessHost; diff --git a/chrome/browser/importer/profile_import_process_messages.h b/chrome/browser/importer/profile_import_process_messages.h index 9a6ed03..d2300dd 100644 --- a/chrome/browser/importer/profile_import_process_messages.h +++ b/chrome/browser/importer/profile_import_process_messages.h @@ -13,8 +13,8 @@ #include "chrome/browser/importer/importer_data_types.h" #include "chrome/browser/importer/profile_writer.h" #include "chrome/browser/search_engines/template_url.h" +#include "chrome/common/common_param_traits_macros.h" #include "content/public/common/common_param_traits.h" -#include "content/public/common/webkit_param_traits.h" #include "ipc/ipc_message_macros.h" #include "ipc/ipc_message_utils.h" #include "webkit/forms/password_form.h" diff --git a/chrome/common/autofill_messages.h b/chrome/common/autofill_messages.h index 4317b94..e23d510 100644 --- a/chrome/common/autofill_messages.h +++ b/chrome/common/autofill_messages.h @@ -7,7 +7,7 @@ #include <string> #include "base/time.h" -#include "content/public/common/webkit_param_traits.h" +#include "chrome/common/common_param_traits_macros.h" #include "ipc/ipc_message_macros.h" #include "ipc/ipc_message_utils.h" #include "ui/gfx/rect.h" diff --git a/chrome/common/automation_messages.cc b/chrome/common/automation_messages.cc index e5b59a1..8aadece 100644 --- a/chrome/common/automation_messages.cc +++ b/chrome/common/automation_messages.cc @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/public/common/webkit_param_traits.h" #include "ui/base/models/menu_model.h" // Get basic type definitions. @@ -53,7 +52,36 @@ ContextMenuModel::Item::Item() namespace IPC { -// static +void ParamTraits<AutomationMouseEvent>::Write(Message* m, + const param_type& p) { + WriteParam(m, std::string(reinterpret_cast<const char*>(&p.mouse_event), + sizeof(p.mouse_event))); + WriteParam(m, p.location_script_chain); +} + +bool ParamTraits<AutomationMouseEvent>::Read(const Message* m, + PickleIterator* iter, + param_type* p) { + std::string mouse_event; + if (!ReadParam(m, iter, &mouse_event)) + return false; + memcpy(&p->mouse_event, mouse_event.c_str(), mouse_event.length()); + if (!ReadParam(m, iter, &p->location_script_chain)) + return false; + return true; +} + +void ParamTraits<AutomationMouseEvent>::Log(const param_type& p, + std::string* l) { + l->append("("); + LogParam(std::string(reinterpret_cast<const char*>(&p.mouse_event), + sizeof(p.mouse_event)), + l); + l->append(", "); + LogParam(p.location_script_chain, l); + l->append(")"); +} + void ParamTraits<ContextMenuModel>::Write(Message* m, const param_type& p) { WriteParam(m, p.items.size()); @@ -70,7 +98,6 @@ void ParamTraits<ContextMenuModel>::Write(Message* m, } } -// static bool ParamTraits<ContextMenuModel>::Read(const Message* m, PickleIterator* iter, param_type* p) { @@ -107,7 +134,6 @@ bool ParamTraits<ContextMenuModel>::Read(const Message* m, return true; } -// static void ParamTraits<ContextMenuModel>::Log(const param_type& p, std::string* l) { l->append("("); @@ -134,37 +160,158 @@ void ParamTraits<ContextMenuModel>::Log(const param_type& p, l->append(")"); } -// static -void ParamTraits<AutomationMouseEvent>::Write(Message* m, - const param_type& p) { - WriteParam(m, std::string(reinterpret_cast<const char*>(&p.mouse_event), - sizeof(p.mouse_event))); - WriteParam(m, p.location_script_chain); +// Only the net::UploadData ParamTraits<> definition needs this definition, so +// keep this in the implementation file so we can forward declare UploadData in +// the header. +template <> +struct ParamTraits<net::UploadElement> { + typedef net::UploadElement param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, static_cast<int>(p.type())); + switch (p.type()) { + case net::UploadElement::TYPE_BYTES: { + m->WriteData(p.bytes(), static_cast<int>(p.bytes_length())); + break; + } + default: { + DCHECK(p.type() == net::UploadElement::TYPE_FILE); + WriteParam(m, p.file_path()); + WriteParam(m, p.file_range_offset()); + WriteParam(m, p.file_range_length()); + WriteParam(m, p.expected_file_modification_time()); + break; + } + } + } + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { + int type; + if (!ReadParam(m, iter, &type)) + return false; + switch (type) { + case net::UploadElement::TYPE_BYTES: { + const char* data; + int len; + if (!m->ReadData(iter, &data, &len)) + return false; + r->SetToBytes(data, len); + break; + } + default: { + DCHECK(type == net::UploadElement::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->SetToFilePathRange(file_path, offset, length, + expected_modification_time); + break; + } + } + return true; + } + static void Log(const param_type& p, std::string* l) { + l->append("<net::UploadElement>"); + } +}; + +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->identifier()); + WriteParam(m, p->is_chunked()); + WriteParam(m, p->last_chunk_appended()); + } } -// static -bool ParamTraits<AutomationMouseEvent>::Read(const Message* m, - PickleIterator* iter, - param_type* p) { - std::string mouse_event; - if (!ReadParam(m, iter, &mouse_event)) +bool ParamTraits<scoped_refptr<net::UploadData> >::Read(const Message* m, + PickleIterator* iter, + param_type* r) { + bool has_object; + if (!ReadParam(m, iter, &has_object)) return false; - memcpy(&p->mouse_event, mouse_event.c_str(), mouse_event.length()); - if (!ReadParam(m, iter, &p->location_script_chain)) + if (!has_object) + return true; + std::vector<net::UploadElement> elements; + if (!ReadParam(m, iter, &elements)) + return false; + int64 identifier; + if (!ReadParam(m, iter, &identifier)) + return false; + bool is_chunked = false; + if (!ReadParam(m, iter, &is_chunked)) return false; + bool last_chunk_appended = false; + if (!ReadParam(m, iter, &last_chunk_appended)) + return false; + *r = new net::UploadData; + (*r)->swap_elements(&elements); + (*r)->set_identifier(identifier); + (*r)->set_is_chunked(is_chunked); + (*r)->set_last_chunk_appended(last_chunk_appended); return true; } -// static -void ParamTraits<AutomationMouseEvent>::Log(const param_type& p, - std::string* l) { - l->append("("); - LogParam(std::string(reinterpret_cast<const char*>(&p.mouse_event), - sizeof(p.mouse_event)), - l); - l->append(", "); - LogParam(p.location_script_chain, l); - l->append(")"); +void ParamTraits<scoped_refptr<net::UploadData> >::Log(const param_type& p, + std::string* l) { + l->append("<net::UploadData>"); +} + +void ParamTraits<net::URLRequestStatus>::Write(Message* m, + const param_type& p) { + WriteParam(m, static_cast<int>(p.status())); + WriteParam(m, p.error()); +} + +bool ParamTraits<net::URLRequestStatus>::Read(const Message* m, + PickleIterator* iter, + param_type* r) { + int status, error; + if (!ReadParam(m, iter, &status) || !ReadParam(m, iter, &error)) + return false; + r->set_status(static_cast<net::URLRequestStatus::Status>(status)); + r->set_error(error); + return true; +} + +void ParamTraits<net::URLRequestStatus>::Log(const param_type& p, + std::string* l) { + std::string status; + switch (p.status()) { + case net::URLRequestStatus::SUCCESS: + status = "SUCCESS"; + break; + case net::URLRequestStatus::IO_PENDING: + status = "IO_PENDING "; + break; + case net::URLRequestStatus::CANCELED: + status = "CANCELED"; + break; + case net::URLRequestStatus::FAILED: + status = "FAILED"; + break; + default: + status = "UNKNOWN"; + break; + } + if (p.status() == net::URLRequestStatus::FAILED) + l->append("("); + + LogParam(status, l); + + if (p.status() == net::URLRequestStatus::FAILED) { + l->append(", "); + LogParam(p.error(), l); + l->append(")"); + } } } // namespace IPC diff --git a/chrome/common/automation_messages.h b/chrome/common/automation_messages.h index 1d86150..0a011ce 100644 --- a/chrome/common/automation_messages.h +++ b/chrome/common/automation_messages.h @@ -15,7 +15,6 @@ #include "content/public/common/common_param_traits.h" #include "content/public/common/page_type.h" #include "content/public/common/security_style.h" -#include "content/public/common/webkit_param_traits.h" #include "googleurl/src/gurl.h" #include "ipc/ipc_message_macros.h" #include "ipc/ipc_message_utils.h" @@ -194,7 +193,14 @@ struct ContextMenuModel { namespace IPC { -// Traits for ContextMenuModel structure to pack/unpack. +template <> +struct ParamTraits<AutomationMouseEvent> { + typedef AutomationMouseEvent param_type; + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, PickleIterator* iter, param_type* p); + static void Log(const param_type& p, std::string* l); +}; + template <> struct ParamTraits<ContextMenuModel> { typedef ContextMenuModel param_type; @@ -203,12 +209,19 @@ struct ParamTraits<ContextMenuModel> { static void Log(const param_type& p, std::string* l); }; -// Traits for AutomationMouseEvent structure to pack/unpack. template <> -struct ParamTraits<AutomationMouseEvent> { - typedef AutomationMouseEvent param_type; +struct ParamTraits<scoped_refptr<net::UploadData> > { + typedef scoped_refptr<net::UploadData> param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, PickleIterator* iter, param_type* p); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); + static void Log(const param_type& p, std::string* l); +}; + +template <> +struct ParamTraits<net::URLRequestStatus> { + typedef net::URLRequestStatus param_type; + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); }; diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index cb077e5..d7334f1 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -25,7 +25,6 @@ #include "chrome/common/thumbnail_score.h" #include "chrome/common/translate_errors.h" #include "content/public/common/common_param_traits.h" -#include "content/public/common/webkit_param_traits.h" #include "ipc/ipc_channel_handle.h" #include "ipc/ipc_message_macros.h" #include "ipc/ipc_platform_file.h" diff --git a/chrome/renderer/autofill/form_autocomplete_browsertest.cc b/chrome/renderer/autofill/form_autocomplete_browsertest.cc index 0e5d662..5285231 100644 --- a/chrome/renderer/autofill/form_autocomplete_browsertest.cc +++ b/chrome/renderer/autofill/form_autocomplete_browsertest.cc @@ -16,7 +16,6 @@ using webkit::forms::FormData; using WebKit::WebFrame; using WebKit::WebString; -using WebKit::WebTextDirection; using WebKit::WebURLError; typedef ChromeRenderViewTest FormAutocompleteTest; diff --git a/chrome/renderer/page_click_tracker.cc b/chrome/renderer/page_click_tracker.cc index 9e40679..1ed680d 100644 --- a/chrome/renderer/page_click_tracker.cc +++ b/chrome/renderer/page_click_tracker.cc @@ -12,6 +12,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMMouseEvent.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" diff --git a/chrome/renderer/plugins/plugin_placeholder.cc b/chrome/renderer/plugins/plugin_placeholder.cc index c1b3158..9c92579 100644 --- a/chrome/renderer/plugins/plugin_placeholder.cc +++ b/chrome/renderer/plugins/plugin_placeholder.cc @@ -22,6 +22,7 @@ #include "grit/generated_resources.h" #include "grit/renderer_resources.h" #include "grit/webkit_strings.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebURLRequest.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" diff --git a/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc b/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc index b19b02c..a8f843e 100644 --- a/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc +++ b/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc @@ -344,7 +344,7 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMetadata( WebIDBMetadata web_metadata = idb_database->metadata(); metadata->name = web_metadata.name; metadata->version = web_metadata.version; - metadata->intVersion = web_metadata.intVersion; + metadata->int_version = web_metadata.intVersion; for (size_t i = 0; i < web_metadata.objectStores.size(); ++i) { const WebIDBMetadata::ObjectStore& web_store_metadata = diff --git a/content/browser/renderer_host/async_resource_handler.cc b/content/browser/renderer_host/async_resource_handler.cc index ffa73b0..8c77c27 100644 --- a/content/browser/renderer_host/async_resource_handler.cc +++ b/content/browser/renderer_host/async_resource_handler.cc @@ -29,6 +29,7 @@ #include "net/base/io_buffer.h" #include "net/base/load_flags.h" #include "net/base/net_log.h" +#include "net/base/net_util.h" #include "webkit/glue/resource_loader_bridge.h" using base::TimeTicks; diff --git a/content/browser/renderer_host/render_view_host_unittest.cc b/content/browser/renderer_host/render_view_host_unittest.cc index 0e9a35e..b5cff72 100644 --- a/content/browser/renderer_host/render_view_host_unittest.cc +++ b/content/browser/renderer_host/render_view_host_unittest.cc @@ -13,6 +13,7 @@ #include "content/public/common/bindings_policy.h" #include "content/public/common/page_transition_types.h" #include "content/public/test/mock_render_process_host.h" +#include "net/base/net_util.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h" #include "webkit/glue/webdropdata.h" diff --git a/content/common/browser_plugin_messages.h b/content/common/browser_plugin_messages.h index f052b70..f992633 100644 --- a/content/common/browser_plugin_messages.h +++ b/content/common/browser_plugin_messages.h @@ -9,6 +9,7 @@ #include "base/basictypes.h" #include "base/process.h" #include "content/common/content_export.h" +#include "content/common/content_param_traits.h" #include "content/public/common/common_param_traits.h" #include "ipc/ipc_channel_handle.h" #include "ipc/ipc_message_macros.h" diff --git a/content/common/cc_messages.cc b/content/common/cc_messages.cc new file mode 100644 index 0000000..374d065 --- /dev/null +++ b/content/common/cc_messages.cc @@ -0,0 +1,139 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/common/cc_messages.h" + +#include "content/public/common/common_param_traits.h" + +namespace IPC { + +void ParamTraits<WebKit::WebData>::Write(Message* m, const param_type& p) { + if (p.isEmpty()) { + m->WriteData(NULL, 0); + } else { + m->WriteData(p.data(), p.size()); + } +} + +bool ParamTraits<WebKit::WebData>::Read( + const Message* m, PickleIterator* iter, param_type* r) { + const char *data = NULL; + int data_size = 0; + if (!m->ReadData(iter, &data, &data_size) || data_size < 0) + return false; + if (data_size) + r->assign(data, data_size); + else + r->reset(); + return true; +} + +void ParamTraits<WebKit::WebData>::Log(const param_type& p, std::string* l) { + l->append("(WebData of size "); + LogParam(p.size(), l); + l->append(")"); +} + +void ParamTraits<WebKit::WebTransformationMatrix>::Write( + Message* m, const param_type& p) { + WriteParam(m, p.m11()); + WriteParam(m, p.m12()); + WriteParam(m, p.m13()); + WriteParam(m, p.m14()); + WriteParam(m, p.m21()); + WriteParam(m, p.m22()); + WriteParam(m, p.m23()); + WriteParam(m, p.m24()); + WriteParam(m, p.m31()); + WriteParam(m, p.m32()); + WriteParam(m, p.m33()); + WriteParam(m, p.m34()); + WriteParam(m, p.m41()); + WriteParam(m, p.m42()); + WriteParam(m, p.m43()); + WriteParam(m, p.m44()); +} + +bool ParamTraits<WebKit::WebTransformationMatrix>::Read( + const Message* m, PickleIterator* iter, param_type* r) { + double m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, + m41, m42, m43, m44; + bool success = + ReadParam(m, iter, &m11) && + ReadParam(m, iter, &m12) && + ReadParam(m, iter, &m13) && + ReadParam(m, iter, &m14) && + ReadParam(m, iter, &m21) && + ReadParam(m, iter, &m22) && + ReadParam(m, iter, &m23) && + ReadParam(m, iter, &m24) && + ReadParam(m, iter, &m31) && + ReadParam(m, iter, &m32) && + ReadParam(m, iter, &m33) && + ReadParam(m, iter, &m34) && + ReadParam(m, iter, &m41) && + ReadParam(m, iter, &m42) && + ReadParam(m, iter, &m43) && + ReadParam(m, iter, &m44); + + if (success) { + r->setM11(m11); + r->setM12(m12); + r->setM13(m13); + r->setM14(m14); + r->setM21(m21); + r->setM22(m22); + r->setM23(m23); + r->setM24(m24); + r->setM31(m31); + r->setM32(m32); + r->setM33(m33); + r->setM34(m34); + r->setM41(m41); + r->setM42(m42); + r->setM43(m43); + r->setM44(m44); + } + + return success; +} + +void ParamTraits<WebKit::WebTransformationMatrix>::Log( + const param_type& p, std::string* l) { + l->append("("); + LogParam(p.m11(), l); + l->append(", "); + LogParam(p.m12(), l); + l->append(", "); + LogParam(p.m13(), l); + l->append(", "); + LogParam(p.m14(), l); + l->append(", "); + LogParam(p.m21(), l); + l->append(", "); + LogParam(p.m22(), l); + l->append(", "); + LogParam(p.m23(), l); + l->append(", "); + LogParam(p.m24(), l); + l->append(", "); + LogParam(p.m31(), l); + l->append(", "); + LogParam(p.m32(), l); + l->append(", "); + LogParam(p.m33(), l); + l->append(", "); + LogParam(p.m34(), l); + l->append(", "); + LogParam(p.m41(), l); + l->append(", "); + LogParam(p.m42(), l); + l->append(", "); + LogParam(p.m43(), l); + l->append(", "); + LogParam(p.m44(), l); + l->append(") "); +} + +} // namespace IPC diff --git a/content/common/cc_messages.h b/content/common/cc_messages.h new file mode 100644 index 0000000..52b8020 --- /dev/null +++ b/content/common/cc_messages.h @@ -0,0 +1,41 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// IPC Messages sent between compositor instances. +// Multiply-included message file, hence no include guard. + +#include "content/common/content_export.h" +#include "ipc/ipc_message_macros.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebData.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMatrix.h" + +#ifndef CONTENT_COMMON_CC_MESSAGES_H_ +#define CONTENT_COMMON_CC_MESSAGES_H_ + +namespace IPC { + +template <> +struct ParamTraits<WebKit::WebData> { + typedef WebKit::WebData param_type; + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); + static void Log(const param_type& p, std::string* l); +}; + +template <> +struct ParamTraits<WebKit::WebTransformationMatrix> { + typedef WebKit::WebTransformationMatrix param_type; + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); + static void Log(const param_type& p, std::string* l); +}; + +} // namespace IPC + +#endif // CONTENT_COMMON_CC_MESSAGES_H_ + + +#define IPC_MESSAGE_START CCMsgStart +#undef IPC_MESSAGE_EXPORT +#define IPC_MESSAGE_EXPORT CONTENT_EXPORT diff --git a/content/common/content_message_generator.h b/content/common/content_message_generator.h index 1bce78a..b377d1a 100644 --- a/content/common/content_message_generator.h +++ b/content/common/content_message_generator.h @@ -9,6 +9,7 @@ #include "content/common/accessibility_messages.h" #include "content/common/appcache_messages.h" #include "content/common/browser_plugin_messages.h" +#include "content/common/cc_messages.h" #include "content/common/clipboard_messages.h" #include "content/common/database_messages.h" #include "content/common/desktop_notification_messages.h" diff --git a/content/common/content_param_traits.cc b/content/common/content_param_traits.cc new file mode 100644 index 0000000..a48ccc5 --- /dev/null +++ b/content/common/content_param_traits.cc @@ -0,0 +1,185 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/common/content_param_traits.h" + +#include "base/string_number_conversions.h" +#include "net/base/ip_endpoint.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" +#include "webkit/glue/npruntime_util.h" +#include "webkit/plugins/npapi/plugin_host.h" +#include "ui/base/range/range.h" + +NPIdentifier_Param::NPIdentifier_Param() + : identifier() { +} + +NPIdentifier_Param::~NPIdentifier_Param() { +} + +NPVariant_Param::NPVariant_Param() + : type(NPVARIANT_PARAM_VOID), + bool_value(false), + int_value(0), + double_value(0), + npobject_routing_id(-1) { +} + +NPVariant_Param::~NPVariant_Param() { +} + +namespace IPC { + +void ParamTraits<net::IPEndPoint>::Write(Message* m, const param_type& p) { + WriteParam(m, p.address()); + WriteParam(m, p.port()); +} + +bool ParamTraits<net::IPEndPoint>::Read(const Message* m, PickleIterator* iter, + param_type* p) { + net::IPAddressNumber address; + int port; + if (!ReadParam(m, iter, &address) || !ReadParam(m, iter, &port)) + return false; + *p = net::IPEndPoint(address, port); + return true; +} + +void ParamTraits<net::IPEndPoint>::Log(const param_type& p, std::string* l) { + LogParam("IPEndPoint:" + p.ToString(), l); +} + +void ParamTraits<NPVariant_Param>::Write(Message* m, const param_type& p) { + WriteParam(m, static_cast<int>(p.type)); + if (p.type == NPVARIANT_PARAM_BOOL) { + WriteParam(m, p.bool_value); + } else if (p.type == NPVARIANT_PARAM_INT) { + WriteParam(m, p.int_value); + } else if (p.type == NPVARIANT_PARAM_DOUBLE) { + WriteParam(m, p.double_value); + } else if (p.type == NPVARIANT_PARAM_STRING) { + WriteParam(m, p.string_value); + } else if (p.type == NPVARIANT_PARAM_SENDER_OBJECT_ROUTING_ID || + p.type == NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID) { + // This is the routing id used to connect NPObjectProxy in the other + // process with NPObjectStub in this process or to identify the raw + // npobject pointer to be used in the callee process. + WriteParam(m, p.npobject_routing_id); + } else { + DCHECK(p.type == NPVARIANT_PARAM_VOID || p.type == NPVARIANT_PARAM_NULL); + } +} + +bool ParamTraits<NPVariant_Param>::Read(const Message* m, + PickleIterator* iter, + param_type* r) { + int type; + if (!ReadParam(m, iter, &type)) + return false; + + bool result = false; + r->type = static_cast<NPVariant_ParamEnum>(type); + if (r->type == NPVARIANT_PARAM_BOOL) { + result = ReadParam(m, iter, &r->bool_value); + } else if (r->type == NPVARIANT_PARAM_INT) { + result = ReadParam(m, iter, &r->int_value); + } else if (r->type == NPVARIANT_PARAM_DOUBLE) { + result = ReadParam(m, iter, &r->double_value); + } else if (r->type == NPVARIANT_PARAM_STRING) { + result = ReadParam(m, iter, &r->string_value); + } else if (r->type == NPVARIANT_PARAM_SENDER_OBJECT_ROUTING_ID || + r->type == NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID) { + result = ReadParam(m, iter, &r->npobject_routing_id); + } else if ((r->type == NPVARIANT_PARAM_VOID) || + (r->type == NPVARIANT_PARAM_NULL)) { + result = true; + } else { + NOTREACHED(); + } + + return result; +} + +void ParamTraits<NPVariant_Param>::Log(const param_type& p, std::string* l) { + l->append(StringPrintf("NPVariant_Param(%d, ", static_cast<int>(p.type))); + if (p.type == NPVARIANT_PARAM_BOOL) { + LogParam(p.bool_value, l); + } else if (p.type == NPVARIANT_PARAM_INT) { + LogParam(p.int_value, l); + } else if (p.type == NPVARIANT_PARAM_DOUBLE) { + LogParam(p.double_value, l); + } else if (p.type == NPVARIANT_PARAM_STRING) { + LogParam(p.string_value, l); + } else if (p.type == NPVARIANT_PARAM_SENDER_OBJECT_ROUTING_ID || + p.type == NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID) { + LogParam(p.npobject_routing_id, l); + } else { + l->append("<none>"); + } + l->append(")"); +} + +void ParamTraits<NPIdentifier_Param>::Write(Message* m, const param_type& p) { + webkit_glue::SerializeNPIdentifier(p.identifier, m); +} + +bool ParamTraits<NPIdentifier_Param>::Read(const Message* m, + PickleIterator* iter, + param_type* r) { + return webkit_glue::DeserializeNPIdentifier(iter, &r->identifier); +} + +void ParamTraits<NPIdentifier_Param>::Log(const param_type& p, std::string* l) { + if (WebKit::WebBindings::identifierIsString(p.identifier)) { + NPUTF8* str = WebKit::WebBindings::utf8FromIdentifier(p.identifier); + l->append(str); + webkit::npapi::PluginHost::Singleton()->host_functions()->memfree(str); + } else { + l->append(base::IntToString( + WebKit::WebBindings::intFromIdentifier(p.identifier))); + } +} + +void ParamTraits<ui::Range>::Write(Message* m, const ui::Range& r) { + m->WriteUInt64(r.start()); + m->WriteUInt64(r.end()); +} + +bool ParamTraits<ui::Range>::Read(const Message* m, + PickleIterator* iter, + ui::Range* r) { + uint64 start, end; + if (!m->ReadUInt64(iter, &start) || !m->ReadUInt64(iter, &end)) + return false; + r->set_start(start); + r->set_end(end); + return true; +} + +void ParamTraits<ui::Range>::Log(const ui::Range& r, std::string* l) { + l->append(base::StringPrintf("(%"PRIuS", %"PRIuS")", r.start(), r.end())); +} + +} // namespace IPC + +// Generate param traits write methods. +#include "ipc/param_traits_write_macros.h" +namespace IPC { +#undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_ +#include "content/common/content_param_traits_macros.h" +} // namespace IPC + +// Generate param traits read methods. +#include "ipc/param_traits_read_macros.h" +namespace IPC { +#undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_ +#include "content/common/content_param_traits_macros.h" +} // namespace IPC + +// Generate param traits log methods. +#include "ipc/param_traits_log_macros.h" +namespace IPC { +#undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_ +#include "content/common/content_param_traits_macros.h" +} // namespace IPC diff --git a/content/public/common/webkit_param_traits.h b/content/common/content_param_traits.h index 7132053..9e7bd44 100644 --- a/content/public/common/webkit_param_traits.h +++ b/content/common/content_param_traits.h @@ -3,41 +3,28 @@ // found in the LICENSE file. // This file is used to define IPC::ParamTraits<> specializations for a number -// of WebKit types so that they can be serialized over IPC. IPC::ParamTraits<> +// of types so that they can be serialized over IPC. IPC::ParamTraits<> // specializations for basic types (like int and std::string) and types in the // 'base' project can be found in ipc/ipc_message_utils.h. This file contains // specializations for types that are used by the content code, and which need // manual serialization code. This is usually because they're not structs with -// public members. +// public members, or because the same type is being used in multiple +// *_messages.h headers. -#ifndef CONTENT_PUBLIC_COMMON_WEBKIT_PARAM_TRAITS_H_ -#define CONTENT_PUBLIC_COMMON_WEBKIT_PARAM_TRAITS_H_ +#ifndef CONTENT_COMMON_CONTENT_PARAM_TRAITS_H_ +#define CONTENT_COMMON_CONTENT_PARAM_TRAITS_H_ -#include <string> - -#include "base/memory/ref_counted.h" -#include "content/common/content_export.h" -#include "ipc/ipc_message_utils.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebData.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMatrix.h" +#include "content/common/content_param_traits_macros.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h" -#include "webkit/blob/blob_data.h" #include "webkit/glue/npruntime_util.h" -#include "webkit/glue/resource_type.h" #include "webkit/glue/webcursor.h" -#include "webkit/glue/window_open_disposition.h" -#include "webkit/plugins/webplugininfo.h" -namespace webkit { -namespace forms { -struct PasswordForm; -} +namespace net { +class IPEndPoint; } -namespace webkit_glue { -struct ResourceDevToolsInfo; -struct ResourceLoadTimingInfo; +namespace ui { +class Range; } // Define the NPVariant_Param struct and its enum here since it needs manual @@ -80,34 +67,10 @@ struct NPIdentifier_Param { namespace IPC { template <> -struct ParamTraits<WebKit::WebData> { - typedef WebKit::WebData param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, PickleIterator* iter, param_type* r); - static void Log(const param_type& p, std::string* l); -}; - -template <> -struct ParamTraits<WebKit::WebTransformationMatrix> { - typedef WebKit::WebTransformationMatrix param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, PickleIterator* iter, param_type* r); - static void Log(const param_type& p, std::string* l); -}; - -template <> -struct ParamTraits<webkit_glue::ResourceLoadTimingInfo> { - typedef webkit_glue::ResourceLoadTimingInfo param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, PickleIterator* iter, param_type* r); - static void Log(const param_type& p, std::string* l); -}; - -template <> -struct ParamTraits<scoped_refptr<webkit_glue::ResourceDevToolsInfo> > { - typedef scoped_refptr<webkit_glue::ResourceDevToolsInfo> param_type; +struct ParamTraits<net::IPEndPoint> { + typedef net::IPEndPoint param_type; static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, PickleIterator* iter, param_type* r); + static bool Read(const Message* m, PickleIterator* iter, param_type* p); static void Log(const param_type& p, std::string* l); }; @@ -128,16 +91,8 @@ struct ParamTraits<NPIdentifier_Param> { }; template <> -struct ParamTraits<webkit::WebPluginMimeType> { - typedef webkit::WebPluginMimeType param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, PickleIterator* iter, param_type* r); - static void Log(const param_type& p, std::string* l); -}; - -template <> -struct CONTENT_EXPORT ParamTraits<webkit::WebPluginInfo> { - typedef webkit::WebPluginInfo param_type; +struct ParamTraits<ui::Range> { + typedef ui::Range param_type; static void Write(Message* m, const param_type& p); static bool Read(const Message* m, PickleIterator* iter, param_type* r); static void Log(const param_type& p, std::string* l); @@ -157,57 +112,6 @@ struct ParamTraits<WebCursor> { } }; -template <> -struct ParamTraits<WebKit::WebInputEvent::Type> { - typedef WebKit::WebInputEvent::Type param_type; - static void Write(Message* m, const param_type& p) { - m->WriteInt(p); - } - static bool Read(const Message* m, PickleIterator* iter, param_type* p) { - int type; - if (!m->ReadInt(iter, &type)) - return false; - *p = static_cast<WebKit::WebInputEvent::Type>(type); - return true; - } - static void Log(const param_type& p, std::string* l) { - const char* type; - switch (p) { - case WebKit::WebInputEvent::MouseDown: - type = "MouseDown"; - break; - case WebKit::WebInputEvent::MouseUp: - type = "MouseUp"; - break; - case WebKit::WebInputEvent::MouseMove: - type = "MouseMove"; - break; - case WebKit::WebInputEvent::MouseLeave: - type = "MouseLeave"; - break; - case WebKit::WebInputEvent::MouseEnter: - type = "MouseEnter"; - break; - case WebKit::WebInputEvent::MouseWheel: - type = "MouseWheel"; - break; - case WebKit::WebInputEvent::RawKeyDown: - type = "RawKeyDown"; - break; - case WebKit::WebInputEvent::KeyDown: - type = "KeyDown"; - break; - case WebKit::WebInputEvent::KeyUp: - type = "KeyUp"; - break; - default: - type = "None"; - break; - } - LogParam(std::string(type), l); - } -}; - typedef const WebKit::WebInputEvent* WebInputEventPointer; template <> struct ParamTraits<WebInputEventPointer> { @@ -248,24 +152,6 @@ struct ParamTraits<WebInputEventPointer> { } }; -template <> -struct SimilarTypeTraits<WebKit::WebTextDirection> { - typedef int Type; -}; - -template <> -struct SimilarTypeTraits<WindowOpenDisposition> { - typedef int Type; -}; - -template <> -struct CONTENT_EXPORT ParamTraits<webkit::forms::PasswordForm> { - typedef webkit::forms::PasswordForm param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, PickleIterator* iter, param_type* p); - static void Log(const param_type& p, std::string* l); -}; - } // namespace IPC -#endif // CONTENT_PUBLIC_COMMON_WEBKIT_PARAM_TRAITS_H_ +#endif // CONTENT_COMMON_CONTENT_PARAM_TRAITS_H_ diff --git a/content/common/content_param_traits_macros.h b/content/common/content_param_traits_macros.h new file mode 100644 index 0000000..02d722c --- /dev/null +++ b/content/common/content_param_traits_macros.h @@ -0,0 +1,24 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Singly or Multiply-included shared traits file depending on circumstances. +// This allows the use of IPC serialization macros in more than one IPC message +// file. +#ifndef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_ +#define CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_ + +#include "content/common/content_export.h" +#include "content/public/common/page_transition_types.h" +#include "ipc/ipc_message_macros.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" +#include "webkit/glue/resource_type.h" + +#undef IPC_MESSAGE_EXPORT +#define IPC_MESSAGE_EXPORT CONTENT_EXPORT + +IPC_ENUM_TRAITS(content::PageTransition) +IPC_ENUM_TRAITS(ResourceType::Type) +IPC_ENUM_TRAITS(WebKit::WebInputEvent::Type) + +#endif // CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_ diff --git a/content/common/fileapi/webblob_messages.h b/content/common/fileapi/webblob_messages.h index 4ba4900..92dda82 100644 --- a/content/common/fileapi/webblob_messages.h +++ b/content/common/fileapi/webblob_messages.h @@ -6,8 +6,8 @@ // Multiply-included message file, hence no include guard. #include "content/public/common/common_param_traits.h" -#include "content/public/common/webkit_param_traits.h" #include "ipc/ipc_message_macros.h" +#include "webkit/blob/blob_data.h" #define IPC_MESSAGE_START BlobMsgStart diff --git a/content/common/indexed_db/indexed_db_messages.h b/content/common/indexed_db/indexed_db_messages.h index 9b875c5..4ad2a3f 100644 --- a/content/common/indexed_db/indexed_db_messages.h +++ b/content/common/indexed_db/indexed_db_messages.h @@ -11,7 +11,6 @@ #include "content/common/indexed_db/indexed_db_key_range.h" #include "content/common/indexed_db/indexed_db_param_traits.h" #include "content/public/common/serialized_script_value.h" -#include "content/public/common/webkit_param_traits.h" #include "ipc/ipc_message_macros.h" #include "ipc/ipc_param_traits.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebExceptionCode.h" @@ -359,7 +358,7 @@ IPC_STRUCT_END() IPC_STRUCT_BEGIN(IndexedDBDatabaseMetadata) IPC_STRUCT_MEMBER(string16, name) IPC_STRUCT_MEMBER(string16, version) - IPC_STRUCT_MEMBER(int64_t, intVersion) + IPC_STRUCT_MEMBER(int64, int_version) IPC_STRUCT_MEMBER(std::vector<IndexedDBObjectStoreMetadata>, object_stores) IPC_STRUCT_END() diff --git a/content/common/indexed_db/proxy_webidbdatabase_impl.cc b/content/common/indexed_db/proxy_webidbdatabase_impl.cc index 908c874..19fac79 100644 --- a/content/common/indexed_db/proxy_webidbdatabase_impl.cc +++ b/content/common/indexed_db/proxy_webidbdatabase_impl.cc @@ -51,7 +51,7 @@ WebIDBMetadata RendererWebIDBDatabaseImpl::metadata() const { WebIDBMetadata web_metadata; web_metadata.name = idb_metadata.name; web_metadata.version = idb_metadata.version; - web_metadata.intVersion = idb_metadata.intVersion; + web_metadata.intVersion = idb_metadata.int_version; web_metadata.objectStores = WebVector<WebIDBMetadata::ObjectStore>( idb_metadata.object_stores.size()); diff --git a/content/common/java_bridge_messages.h b/content/common/java_bridge_messages.h index 0f0a694..2d0d480 100644 --- a/content/common/java_bridge_messages.h +++ b/content/common/java_bridge_messages.h @@ -6,7 +6,7 @@ // Multiply-included message file, hence no include guard. -#include "content/public/common/webkit_param_traits.h" +#include "content/common/content_param_traits.h" #include "ipc/ipc_channel_handle.h" #include "ipc/ipc_message_macros.h" diff --git a/content/common/plugin_messages.h b/content/common/plugin_messages.h index 91272d6..c367fed 100644 --- a/content/common/plugin_messages.h +++ b/content/common/plugin_messages.h @@ -6,8 +6,8 @@ #include "build/build_config.h" #include "content/common/content_export.h" +#include "content/common/content_param_traits.h" #include "content/public/common/common_param_traits.h" -#include "content/public/common/webkit_param_traits.h" #include "ipc/ipc_channel_handle.h" #include "ipc/ipc_message_macros.h" #include "ui/gfx/native_widget_types.h" diff --git a/content/common/resource_messages.cc b/content/common/resource_messages.cc new file mode 100644 index 0000000..913883a --- /dev/null +++ b/content/common/resource_messages.cc @@ -0,0 +1,293 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/common/resource_messages.h" + +#include "net/http/http_response_headers.h" +#include "webkit/glue/resource_loader_bridge.h" + +namespace IPC { + +void ParamTraits<scoped_refptr<net::HttpResponseHeaders> >::Write( + Message* m, const param_type& p) { + WriteParam(m, p.get() != NULL); + if (p) { + // Do not disclose Set-Cookie headers over IPC. + p->Persist(m, net::HttpResponseHeaders::PERSIST_SANS_COOKIES); + } +} + +bool ParamTraits<scoped_refptr<net::HttpResponseHeaders> >::Read( + const Message* m, PickleIterator* iter, param_type* r) { + bool has_object; + if (!ReadParam(m, iter, &has_object)) + return false; + if (has_object) + *r = new net::HttpResponseHeaders(*m, iter); + return true; +} + +void ParamTraits<scoped_refptr<net::HttpResponseHeaders> >::Log( + const param_type& p, std::string* l) { + l->append("<HttpResponseHeaders>"); +} + + +void ParamTraits<webkit_base::DataElement>::Write( + Message* m, const param_type& p) { + WriteParam(m, static_cast<int>(p.type())); + switch (p.type()) { + case webkit_base::DataElement::TYPE_BYTES: { + m->WriteData(p.bytes(), static_cast<int>(p.length())); + break; + } + case webkit_base::DataElement::TYPE_FILE: { + WriteParam(m, p.path()); + WriteParam(m, p.offset()); + WriteParam(m, p.length()); + WriteParam(m, p.expected_modification_time()); + break; + } + case webkit_base::DataElement::TYPE_FILE_FILESYSTEM: { + WriteParam(m, p.url()); + WriteParam(m, p.offset()); + WriteParam(m, p.length()); + WriteParam(m, p.expected_modification_time()); + break; + } + default: { + DCHECK(p.type() == webkit_base::DataElement::TYPE_BLOB); + WriteParam(m, p.url()); + WriteParam(m, p.offset()); + WriteParam(m, p.length()); + break; + } + } +} + +bool ParamTraits<webkit_base::DataElement>::Read( + const Message* m, PickleIterator* iter, param_type* r) { + int type; + if (!ReadParam(m, iter, &type)) + return false; + switch (type) { + case webkit_base::DataElement::TYPE_BYTES: { + const char* data; + int len; + if (!m->ReadData(iter, &data, &len)) + return false; + r->SetToBytes(data, len); + break; + } + case webkit_base::DataElement::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->SetToFilePathRange(file_path, offset, length, + expected_modification_time); + break; + } + case webkit_base::DataElement::TYPE_FILE_FILESYSTEM: { + GURL file_system_url; + uint64 offset, length; + base::Time expected_modification_time; + if (!ReadParam(m, iter, &file_system_url)) + 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->SetToFileSystemUrlRange(file_system_url, offset, length, + expected_modification_time); + break; + } + default: { + DCHECK(type == webkit_base::DataElement::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->SetToBlobUrlRange(blob_url, offset, length); + break; + } + } + return true; +} + +void ParamTraits<webkit_base::DataElement>::Log( + const param_type& p, std::string* l) { + l->append("<webkit_base::DataElement>"); +} + +void ParamTraits<scoped_refptr<webkit_glue::ResourceDevToolsInfo> >::Write( + Message* m, const param_type& p) { + WriteParam(m, p.get() != NULL); + if (p.get()) { + WriteParam(m, p->http_status_code); + WriteParam(m, p->http_status_text); + WriteParam(m, p->request_headers); + WriteParam(m, p->response_headers); + WriteParam(m, p->request_headers_text); + WriteParam(m, p->response_headers_text); + } +} + +bool ParamTraits<scoped_refptr<webkit_glue::ResourceDevToolsInfo> >::Read( + const Message* m, PickleIterator* iter, param_type* r) { + bool has_object; + if (!ReadParam(m, iter, &has_object)) + return false; + if (!has_object) + return true; + *r = new webkit_glue::ResourceDevToolsInfo(); + return + ReadParam(m, iter, &(*r)->http_status_code) && + ReadParam(m, iter, &(*r)->http_status_text) && + ReadParam(m, iter, &(*r)->request_headers) && + ReadParam(m, iter, &(*r)->response_headers) && + ReadParam(m, iter, &(*r)->request_headers_text) && + ReadParam(m, iter, &(*r)->response_headers_text); +} + +void ParamTraits<scoped_refptr<webkit_glue::ResourceDevToolsInfo> >::Log( + const param_type& p, std::string* l) { + l->append("("); + if (p) { + LogParam(p->request_headers, l); + l->append(", "); + LogParam(p->response_headers, l); + } + l->append(")"); +} + +void ParamTraits<webkit_glue::ResourceLoadTimingInfo>::Write( + Message* m, const param_type& p) { + WriteParam(m, p.base_time.is_null()); + if (p.base_time.is_null()) + return; + WriteParam(m, p.base_ticks); + WriteParam(m, p.base_time); + WriteParam(m, p.proxy_start); + WriteParam(m, p.proxy_end); + WriteParam(m, p.dns_start); + WriteParam(m, p.dns_end); + WriteParam(m, p.connect_start); + WriteParam(m, p.connect_end); + WriteParam(m, p.ssl_start); + WriteParam(m, p.ssl_end); + WriteParam(m, p.send_start); + WriteParam(m, p.send_end); + WriteParam(m, p.receive_headers_start); + WriteParam(m, p.receive_headers_end); +} + +bool ParamTraits<webkit_glue::ResourceLoadTimingInfo>::Read( + const Message* m, PickleIterator* iter, param_type* r) { + bool is_null; + if (!ReadParam(m, iter, &is_null)) + return false; + if (is_null) + return true; + + return + ReadParam(m, iter, &r->base_ticks) && + ReadParam(m, iter, &r->base_time) && + ReadParam(m, iter, &r->proxy_start) && + ReadParam(m, iter, &r->proxy_end) && + ReadParam(m, iter, &r->dns_start) && + ReadParam(m, iter, &r->dns_end) && + ReadParam(m, iter, &r->connect_start) && + ReadParam(m, iter, &r->connect_end) && + ReadParam(m, iter, &r->ssl_start) && + ReadParam(m, iter, &r->ssl_end) && + ReadParam(m, iter, &r->send_start) && + ReadParam(m, iter, &r->send_end) && + ReadParam(m, iter, &r->receive_headers_start) && + ReadParam(m, iter, &r->receive_headers_end); +} + +void ParamTraits<webkit_glue::ResourceLoadTimingInfo>::Log(const param_type& p, + std::string* l) { + l->append("("); + LogParam(p.base_ticks, l); + l->append(", "); + LogParam(p.base_time, l); + l->append(", "); + LogParam(p.proxy_start, l); + l->append(", "); + LogParam(p.proxy_end, l); + l->append(", "); + LogParam(p.dns_start, l); + l->append(", "); + LogParam(p.dns_end, l); + l->append(", "); + LogParam(p.connect_start, l); + l->append(", "); + LogParam(p.connect_end, l); + l->append(", "); + LogParam(p.ssl_start, l); + l->append(", "); + LogParam(p.ssl_end, l); + l->append(", "); + LogParam(p.send_start, l); + l->append(", "); + LogParam(p.send_end, l); + l->append(", "); + LogParam(p.receive_headers_start, l); + l->append(", "); + LogParam(p.receive_headers_end, l); + l->append(")"); +} + +void ParamTraits<scoped_refptr<webkit_glue::ResourceRequestBody> >::Write( + Message* m, + const param_type& p) { + WriteParam(m, p.get() != NULL); + if (p) { + WriteParam(m, *p->elements()); + WriteParam(m, p->identifier()); + } +} + +bool ParamTraits<scoped_refptr<webkit_glue::ResourceRequestBody> >::Read( + const Message* m, + PickleIterator* iter, + param_type* r) { + bool has_object; + if (!ReadParam(m, iter, &has_object)) + return false; + if (!has_object) + return true; + std::vector<webkit_base::DataElement> elements; + if (!ReadParam(m, iter, &elements)) + return false; + int64 identifier; + if (!ReadParam(m, iter, &identifier)) + return false; + *r = new webkit_glue::ResourceRequestBody; + (*r)->swap_elements(&elements); + (*r)->set_identifier(identifier); + return true; +} + +void ParamTraits<scoped_refptr<webkit_glue::ResourceRequestBody> >::Log( + const param_type& p, std::string* l) { + l->append("<webkit_glue::ResourceRequestBody>"); +} + +} // namespace IPC diff --git a/content/common/resource_messages.h b/content/common/resource_messages.h index 6ee3a5c..a838a34 100644 --- a/content/common/resource_messages.h +++ b/content/common/resource_messages.h @@ -6,11 +6,67 @@ // Multiply-included message file, hence no include guard. #include "base/shared_memory.h" +#include "content/common/content_param_traits_macros.h" #include "content/public/common/common_param_traits.h" #include "content/public/common/resource_response.h" #include "ipc/ipc_message_macros.h" #include "webkit/glue/resource_request_body.h" +#ifndef CONTENT_COMMON_RESOURCE_MESSAGES_H_ +#define CONTENT_COMMON_RESOURCE_MESSAGES_H_ + +namespace webkit_glue { +struct ResourceDevToolsInfo; +struct ResourceLoadTimingInfo; +} + +namespace IPC { + +template <> +struct ParamTraits<scoped_refptr<net::HttpResponseHeaders> > { + typedef scoped_refptr<net::HttpResponseHeaders> param_type; + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); + static void Log(const param_type& p, std::string* l); +}; + +template <> +struct CONTENT_EXPORT ParamTraits<webkit_base::DataElement> { + typedef webkit_base::DataElement param_type; + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); + static void Log(const param_type& p, std::string* l); +}; + +template <> +struct ParamTraits<scoped_refptr<webkit_glue::ResourceDevToolsInfo> > { + typedef scoped_refptr<webkit_glue::ResourceDevToolsInfo> param_type; + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); + static void Log(const param_type& p, std::string* l); +}; + +template <> +struct ParamTraits<webkit_glue::ResourceLoadTimingInfo> { + typedef webkit_glue::ResourceLoadTimingInfo param_type; + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); + static void Log(const param_type& p, std::string* l); +}; + +template <> +struct ParamTraits<scoped_refptr<webkit_glue::ResourceRequestBody> > { + typedef scoped_refptr<webkit_glue::ResourceRequestBody> param_type; + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); + static void Log(const param_type& p, std::string* l); +}; + +} // namespace IPC + +#endif // CONTENT_COMMON_RESOURCE_MESSAGES_H_ + + #define IPC_MESSAGE_START ResourceMsgStart #undef IPC_MESSAGE_EXPORT #define IPC_MESSAGE_EXPORT CONTENT_EXPORT diff --git a/content/common/view_messages.h b/content/common/view_messages.h index aad8ed9..c882778 100644 --- a/content/common/view_messages.h +++ b/content/common/view_messages.h @@ -8,6 +8,7 @@ #include "base/process.h" #include "base/shared_memory.h" #include "content/common/content_export.h" +#include "content/common/content_param_traits.h" #include "content/common/css_colors.h" #include "content/common/edit_command.h" #include "content/common/navigation_gesture.h" @@ -21,7 +22,6 @@ #include "content/public/common/referrer.h" #include "content/public/common/renderer_preferences.h" #include "content/public/common/stop_find_action.h" -#include "content/public/common/webkit_param_traits.h" #include "content/public/common/window_container_type.h" #include "ipc/ipc_channel_handle.h" #include "ipc/ipc_message_macros.h" @@ -38,6 +38,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginAction.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupType.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h" #include "ui/base/dialogs/selected_file_info.h" #include "ui/base/ime/text_input_type.h" #include "ui/base/range/range.h" @@ -118,18 +119,6 @@ IPC_STRUCT_TRAITS_BEGIN(WebKit::WebPluginAction) IPC_STRUCT_TRAITS_MEMBER(enable) IPC_STRUCT_TRAITS_END() -IPC_STRUCT_TRAITS_BEGIN(WebKit::WebPoint) - IPC_STRUCT_TRAITS_MEMBER(x) - IPC_STRUCT_TRAITS_MEMBER(y) -IPC_STRUCT_TRAITS_END() - -IPC_STRUCT_TRAITS_BEGIN(WebKit::WebRect) - IPC_STRUCT_TRAITS_MEMBER(x) - IPC_STRUCT_TRAITS_MEMBER(y) - IPC_STRUCT_TRAITS_MEMBER(width) - IPC_STRUCT_TRAITS_MEMBER(height) -IPC_STRUCT_TRAITS_END() - IPC_STRUCT_TRAITS_BEGIN(WebKit::WebFloatPoint) IPC_STRUCT_TRAITS_MEMBER(x) IPC_STRUCT_TRAITS_MEMBER(y) diff --git a/content/content_common.gypi b/content/content_common.gypi index 38b5d1e..c246a2e 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi @@ -120,6 +120,8 @@ 'common/appcache/appcache_dispatcher.h', 'common/appcache_messages.h', 'common/browser_plugin_messages.h', + 'common/cc_messages.cc', + 'common/cc_messages.h', 'common/child_histogram_message_filter.cc', 'common/child_histogram_message_filter.h', 'common/child_process.cc', @@ -142,6 +144,9 @@ 'common/content_export.h', 'common/content_message_generator.cc', 'common/content_message_generator.h', + 'common/content_param_traits.cc', + 'common/content_param_traits.h', + 'common/content_param_traits_macros.h', 'common/content_paths.cc', 'common/css_colors.h', 'common/database_messages.h', @@ -320,6 +325,7 @@ 'common/request_extra_data.h', 'common/resource_dispatcher.cc', 'common/resource_dispatcher.h', + 'common/resource_messages.cc', 'common/resource_messages.h', 'common/sandbox_init_mac.cc', 'common/sandbox_init_mac.h', @@ -371,8 +377,6 @@ 'public/common/content_client.h', 'public/common/window_container_type.cc', 'public/common/window_container_type.h', - 'public/common/webkit_param_traits.cc', - 'public/common/webkit_param_traits.h', ], 'conditions': [ ['OS=="ios"', { diff --git a/content/public/common/common_param_traits.cc b/content/public/common/common_param_traits.cc index fae54fb..9565865 100644 --- a/content/public/common/common_param_traits.cc +++ b/content/public/common/common_param_traits.cc @@ -7,13 +7,9 @@ #include "content/public/common/content_constants.h" #include "content/public/common/referrer.h" #include "net/base/host_port_pair.h" -#include "net/base/upload_data.h" -#include "net/http/http_response_headers.h" #include "third_party/skia/include/core/SkBitmap.h" -#include "ui/base/range/range.h" #include "ui/gfx/rect.h" #include "ui/gfx/rect_f.h" -#include "webkit/glue/resource_request_body.h" namespace { @@ -72,296 +68,6 @@ void ParamTraits<GURL>::Log(const GURL& p, std::string* l) { l->append(p.spec()); } -void ParamTraits<net::URLRequestStatus>::Write(Message* m, - const param_type& p) { - WriteParam(m, static_cast<int>(p.status())); - WriteParam(m, p.error()); -} - -bool ParamTraits<net::URLRequestStatus>::Read(const Message* m, - PickleIterator* iter, - param_type* r) { - int status, error; - if (!ReadParam(m, iter, &status) || !ReadParam(m, iter, &error)) - return false; - r->set_status(static_cast<net::URLRequestStatus::Status>(status)); - r->set_error(error); - return true; -} - -void ParamTraits<net::URLRequestStatus>::Log(const param_type& p, - std::string* l) { - std::string status; - switch (p.status()) { - case net::URLRequestStatus::SUCCESS: - status = "SUCCESS"; - break; - case net::URLRequestStatus::IO_PENDING: - status = "IO_PENDING "; - break; - case net::URLRequestStatus::CANCELED: - status = "CANCELED"; - break; - case net::URLRequestStatus::FAILED: - status = "FAILED"; - break; - default: - status = "UNKNOWN"; - break; - } - if (p.status() == net::URLRequestStatus::FAILED) - l->append("("); - - LogParam(status, l); - - if (p.status() == net::URLRequestStatus::FAILED) { - l->append(", "); - LogParam(p.error(), l); - l->append(")"); - } -} - -// Only the net::UploadData ParamTraits<> definition needs this definition, so -// keep this in the implementation file so we can forward declare UploadData in -// the header. -template <> -struct ParamTraits<net::UploadElement> { - typedef net::UploadElement param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, static_cast<int>(p.type())); - switch (p.type()) { - case net::UploadElement::TYPE_BYTES: { - m->WriteData(p.bytes(), static_cast<int>(p.bytes_length())); - break; - } - default: { - DCHECK(p.type() == net::UploadElement::TYPE_FILE); - WriteParam(m, p.file_path()); - WriteParam(m, p.file_range_offset()); - WriteParam(m, p.file_range_length()); - WriteParam(m, p.expected_file_modification_time()); - break; - } - } - } - static bool Read(const Message* m, PickleIterator* iter, param_type* r) { - int type; - if (!ReadParam(m, iter, &type)) - return false; - switch (type) { - case net::UploadElement::TYPE_BYTES: { - const char* data; - int len; - if (!m->ReadData(iter, &data, &len)) - return false; - r->SetToBytes(data, len); - break; - } - default: { - DCHECK(type == net::UploadElement::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->SetToFilePathRange(file_path, offset, length, - expected_modification_time); - break; - } - } - return true; - } - static void Log(const param_type& p, std::string* l) { - l->append("<net::UploadElement>"); - } -}; - -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->identifier()); - WriteParam(m, p->is_chunked()); - WriteParam(m, p->last_chunk_appended()); - } -} - -bool ParamTraits<scoped_refptr<net::UploadData> >::Read(const Message* m, - PickleIterator* iter, - param_type* r) { - bool has_object; - if (!ReadParam(m, iter, &has_object)) - return false; - if (!has_object) - return true; - std::vector<net::UploadElement> elements; - if (!ReadParam(m, iter, &elements)) - return false; - int64 identifier; - if (!ReadParam(m, iter, &identifier)) - return false; - bool is_chunked = false; - if (!ReadParam(m, iter, &is_chunked)) - return false; - bool last_chunk_appended = false; - if (!ReadParam(m, iter, &last_chunk_appended)) - return false; - *r = new net::UploadData; - (*r)->swap_elements(&elements); - (*r)->set_identifier(identifier); - (*r)->set_is_chunked(is_chunked); - (*r)->set_last_chunk_appended(last_chunk_appended); - return true; -} - -void ParamTraits<scoped_refptr<net::UploadData> >::Log(const param_type& p, - std::string* l) { - l->append("<net::UploadData>"); -} - -void ParamTraits<webkit_base::DataElement>::Write( - Message* m, const param_type& p) { - WriteParam(m, static_cast<int>(p.type())); - switch (p.type()) { - case webkit_base::DataElement::TYPE_BYTES: { - m->WriteData(p.bytes(), static_cast<int>(p.length())); - break; - } - case webkit_base::DataElement::TYPE_FILE: { - WriteParam(m, p.path()); - WriteParam(m, p.offset()); - WriteParam(m, p.length()); - WriteParam(m, p.expected_modification_time()); - break; - } - case webkit_base::DataElement::TYPE_FILE_FILESYSTEM: { - WriteParam(m, p.url()); - WriteParam(m, p.offset()); - WriteParam(m, p.length()); - WriteParam(m, p.expected_modification_time()); - break; - } - default: { - DCHECK(p.type() == webkit_base::DataElement::TYPE_BLOB); - WriteParam(m, p.url()); - WriteParam(m, p.offset()); - WriteParam(m, p.length()); - break; - } - } -} - -bool ParamTraits<webkit_base::DataElement>::Read( - const Message* m, PickleIterator* iter, param_type* r) { - int type; - if (!ReadParam(m, iter, &type)) - return false; - switch (type) { - case webkit_base::DataElement::TYPE_BYTES: { - const char* data; - int len; - if (!m->ReadData(iter, &data, &len)) - return false; - r->SetToBytes(data, len); - break; - } - case webkit_base::DataElement::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->SetToFilePathRange(file_path, offset, length, - expected_modification_time); - break; - } - case webkit_base::DataElement::TYPE_FILE_FILESYSTEM: { - GURL file_system_url; - uint64 offset, length; - base::Time expected_modification_time; - if (!ReadParam(m, iter, &file_system_url)) - 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->SetToFileSystemUrlRange(file_system_url, offset, length, - expected_modification_time); - break; - } - default: { - DCHECK(type == webkit_base::DataElement::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->SetToBlobUrlRange(blob_url, offset, length); - break; - } - } - return true; -} - -void ParamTraits<webkit_base::DataElement>::Log( - const param_type& p, std::string* l) { - l->append("<webkit_base::DataElement>"); -} - -void ParamTraits<scoped_refptr<webkit_glue::ResourceRequestBody> >::Write( - Message* m, - const param_type& p) { - WriteParam(m, p.get() != NULL); - if (p) { - WriteParam(m, *p->elements()); - WriteParam(m, p->identifier()); - } -} - -bool ParamTraits<scoped_refptr<webkit_glue::ResourceRequestBody> >::Read( - const Message* m, - PickleIterator* iter, - param_type* r) { - bool has_object; - if (!ReadParam(m, iter, &has_object)) - return false; - if (!has_object) - return true; - std::vector<webkit_base::DataElement> elements; - if (!ReadParam(m, iter, &elements)) - return false; - int64 identifier; - if (!ReadParam(m, iter, &identifier)) - return false; - *r = new webkit_glue::ResourceRequestBody; - (*r)->swap_elements(&elements); - (*r)->set_identifier(identifier); - return true; -} - -void ParamTraits<scoped_refptr<webkit_glue::ResourceRequestBody> >::Log( - const param_type& p, std::string* l) { - l->append("<webkit_glue::ResourceRequestBody>"); -} - void ParamTraits<net::HostPortPair>::Write(Message* m, const param_type& p) { WriteParam(m, p.host()); WriteParam(m, p.port()); @@ -384,49 +90,6 @@ void ParamTraits<net::HostPortPair>::Log(const param_type& p, std::string* l) { l->append(p.ToString()); } -void ParamTraits<scoped_refptr<net::HttpResponseHeaders> >::Write( - Message* m, const param_type& p) { - WriteParam(m, p.get() != NULL); - if (p) { - // Do not disclose Set-Cookie headers over IPC. - p->Persist(m, net::HttpResponseHeaders::PERSIST_SANS_COOKIES); - } -} - -bool ParamTraits<scoped_refptr<net::HttpResponseHeaders> >::Read( - const Message* m, PickleIterator* iter, param_type* r) { - bool has_object; - if (!ReadParam(m, iter, &has_object)) - return false; - if (has_object) - *r = new net::HttpResponseHeaders(*m, iter); - return true; -} - -void ParamTraits<scoped_refptr<net::HttpResponseHeaders> >::Log( - const param_type& p, std::string* l) { - l->append("<HttpResponseHeaders>"); -} - -void ParamTraits<net::IPEndPoint>::Write(Message* m, const param_type& p) { - WriteParam(m, p.address()); - WriteParam(m, p.port()); -} - -bool ParamTraits<net::IPEndPoint>::Read(const Message* m, PickleIterator* iter, - param_type* p) { - net::IPAddressNumber address; - int port; - if (!ReadParam(m, iter, &address) || !ReadParam(m, iter, &port)) - return false; - *p = net::IPEndPoint(address, port); - return true; -} - -void ParamTraits<net::IPEndPoint>::Log(const param_type& p, std::string* l) { - LogParam("IPEndPoint:" + p.ToString(), l); -} - void ParamTraits<content::Referrer>::Write( Message* m, const param_type& p) { WriteParam(m, p.url); @@ -544,26 +207,6 @@ void ParamTraits<gfx::RectF>::Log(const gfx::RectF& p, std::string* l) { p.width(), p.height())); } -void ParamTraits<ui::Range>::Write(Message* m, const ui::Range& r) { - m->WriteUInt64(r.start()); - m->WriteUInt64(r.end()); -} - -bool ParamTraits<ui::Range>::Read(const Message* m, - PickleIterator* iter, - ui::Range* r) { - uint64 start, end; - if (!m->ReadUInt64(iter, &start) || !m->ReadUInt64(iter, &end)) - return false; - r->set_start(start); - r->set_end(end); - return true; -} - -void ParamTraits<ui::Range>::Log(const ui::Range& r, std::string* l) { - l->append(base::StringPrintf("(%"PRIuS", %"PRIuS")", r.start(), r.end())); -} - void ParamTraits<SkBitmap>::Write(Message* m, const SkBitmap& p) { size_t fixed_size = sizeof(SkBitmap_Data); SkBitmap_Data bmp_data; diff --git a/content/public/common/common_param_traits.h b/content/public/common/common_param_traits.h index 1d2531f..8128a9e 100644 --- a/content/public/common/common_param_traits.h +++ b/content/public/common/common_param_traits.h @@ -19,11 +19,8 @@ #include "content/public/common/common_param_traits_macros.h" #include "googleurl/src/gurl.h" #include "ipc/ipc_message_utils.h" -#include "net/base/ip_endpoint.h" -#include "net/url_request/url_request_status.h" #include "ui/gfx/native_widget_types.h" #include "ui/surface/transport_dib.h" -#include "webkit/base/data_element.h" class SkBitmap; @@ -39,17 +36,7 @@ class Size; } // namespace gfx namespace net { -class HttpResponseHeaders; class HostPortPair; -class UploadData; -} - -namespace ui { -class Range; -} - -namespace webkit_glue { -class ResourceRequestBody; } namespace IPC { @@ -62,39 +49,6 @@ struct CONTENT_EXPORT ParamTraits<GURL> { static void Log(const param_type& p, std::string* l); }; -template <> -struct CONTENT_EXPORT ParamTraits<net::URLRequestStatus> { - typedef net::URLRequestStatus param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, PickleIterator* iter, param_type* r); - static void Log(const param_type& p, std::string* l); -}; - -template <> -struct CONTENT_EXPORT ParamTraits<scoped_refptr<net::UploadData> > { - typedef scoped_refptr<net::UploadData> param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, PickleIterator* iter, param_type* r); - static void Log(const param_type& p, std::string* l); -}; - -template <> -struct CONTENT_EXPORT ParamTraits<scoped_refptr< - webkit_glue::ResourceRequestBody> > { - typedef scoped_refptr<webkit_glue::ResourceRequestBody> param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, PickleIterator* iter, param_type* r); - static void Log(const param_type& p, std::string* l); -}; - -template <> -struct CONTENT_EXPORT ParamTraits<webkit_base::DataElement> { - typedef webkit_base::DataElement param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, PickleIterator* iter, param_type* r); - static void Log(const param_type& p, std::string* l); -}; - template<> struct CONTENT_EXPORT ParamTraits<net::HostPortPair> { typedef net::HostPortPair param_type; @@ -104,22 +58,6 @@ struct CONTENT_EXPORT ParamTraits<net::HostPortPair> { }; template <> -struct ParamTraits<scoped_refptr<net::HttpResponseHeaders> > { - typedef scoped_refptr<net::HttpResponseHeaders> param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, PickleIterator* iter, param_type* r); - static void Log(const param_type& p, std::string* l); -}; - -template <> -struct ParamTraits<net::IPEndPoint> { - typedef net::IPEndPoint param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, PickleIterator* iter, param_type* p); - static void Log(const param_type& p, std::string* l); -}; - -template <> struct CONTENT_EXPORT ParamTraits<content::Referrer> { typedef content::Referrer param_type; static void Write(Message* m, const param_type& p); @@ -191,14 +129,6 @@ struct ParamTraits<gfx::NativeWindow> { } }; -template <> -struct CONTENT_EXPORT ParamTraits<ui::Range> { - typedef ui::Range param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, PickleIterator* iter, param_type* r); - static void Log(const param_type& p, std::string* l); -}; - #if defined(OS_WIN) template<> struct ParamTraits<TransportDIB::Id> { diff --git a/content/public/common/common_param_traits_macros.h b/content/public/common/common_param_traits_macros.h index cccf634..22340c6 100644 --- a/content/public/common/common_param_traits_macros.h +++ b/content/public/common/common_param_traits_macros.h @@ -9,19 +9,66 @@ #define CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ #include "content/public/common/console_message_level.h" -#include "content/public/common/page_transition_types.h" #include "content/public/common/security_style.h" #include "ipc/ipc_message_macros.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebPoint.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebReferrerPolicy.h" -#include "webkit/glue/resource_type.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" +#include "webkit/forms/password_form.h" +#include "webkit/glue/window_open_disposition.h" +#include "webkit/plugins/webplugininfo.h" #undef IPC_MESSAGE_EXPORT #define IPC_MESSAGE_EXPORT CONTENT_EXPORT IPC_ENUM_TRAITS(content::ConsoleMessageLevel) -IPC_ENUM_TRAITS(content::PageTransition) IPC_ENUM_TRAITS(content::SecurityStyle) -IPC_ENUM_TRAITS(ResourceType::Type) IPC_ENUM_TRAITS(WebKit::WebReferrerPolicy) +IPC_ENUM_TRAITS(WindowOpenDisposition) + +IPC_STRUCT_TRAITS_BEGIN(WebKit::WebPoint) + IPC_STRUCT_TRAITS_MEMBER(x) + IPC_STRUCT_TRAITS_MEMBER(y) +IPC_STRUCT_TRAITS_END() + +IPC_STRUCT_TRAITS_BEGIN(WebKit::WebRect) + IPC_STRUCT_TRAITS_MEMBER(x) + IPC_STRUCT_TRAITS_MEMBER(y) + IPC_STRUCT_TRAITS_MEMBER(width) + IPC_STRUCT_TRAITS_MEMBER(height) +IPC_STRUCT_TRAITS_END() + +IPC_STRUCT_TRAITS_BEGIN(webkit::forms::PasswordForm) +IPC_STRUCT_TRAITS_MEMBER(signon_realm) +IPC_STRUCT_TRAITS_MEMBER(origin) +IPC_STRUCT_TRAITS_MEMBER(action) +IPC_STRUCT_TRAITS_MEMBER(submit_element) +IPC_STRUCT_TRAITS_MEMBER(username_element) +IPC_STRUCT_TRAITS_MEMBER(username_value) +IPC_STRUCT_TRAITS_MEMBER(password_element) +IPC_STRUCT_TRAITS_MEMBER(password_value) +IPC_STRUCT_TRAITS_MEMBER(old_password_element) +IPC_STRUCT_TRAITS_MEMBER(old_password_value) +IPC_STRUCT_TRAITS_MEMBER(ssl_valid) +IPC_STRUCT_TRAITS_MEMBER(preferred) +IPC_STRUCT_TRAITS_MEMBER(blacklisted_by_user) +IPC_STRUCT_TRAITS_END() + +IPC_STRUCT_TRAITS_BEGIN(webkit::WebPluginMimeType) + IPC_STRUCT_TRAITS_MEMBER(mime_type) + IPC_STRUCT_TRAITS_MEMBER(file_extensions) + IPC_STRUCT_TRAITS_MEMBER(description) + IPC_STRUCT_TRAITS_MEMBER(additional_param_names) + IPC_STRUCT_TRAITS_MEMBER(additional_param_values) +IPC_STRUCT_TRAITS_END() + +IPC_STRUCT_TRAITS_BEGIN(webkit::WebPluginInfo) + IPC_STRUCT_TRAITS_MEMBER(name) + IPC_STRUCT_TRAITS_MEMBER(path) + IPC_STRUCT_TRAITS_MEMBER(version) + IPC_STRUCT_TRAITS_MEMBER(desc) + IPC_STRUCT_TRAITS_MEMBER(mime_types) + IPC_STRUCT_TRAITS_MEMBER(type) +IPC_STRUCT_TRAITS_END() #endif // CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ diff --git a/content/public/common/webkit_param_traits.cc b/content/public/common/webkit_param_traits.cc deleted file mode 100644 index 9d4bf94..0000000 --- a/content/public/common/webkit_param_traits.cc +++ /dev/null @@ -1,481 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// NOTE: New trait definitions that will be used by Chrome Frame must be placed -// in common_param_traits2.cc. - -#include "content/public/common/webkit_param_traits.h" - -#include "base/string_number_conversions.h" -#include "content/public/common/common_param_traits.h" -#include "content/public/common/content_constants.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" -#include "webkit/forms/password_form.h" -#include "webkit/glue/resource_loader_bridge.h" -#include "webkit/plugins/npapi/plugin_host.h" - -NPIdentifier_Param::NPIdentifier_Param() - : identifier() { -} - -NPIdentifier_Param::~NPIdentifier_Param() { -} - -NPVariant_Param::NPVariant_Param() - : type(NPVARIANT_PARAM_VOID), - bool_value(false), - int_value(0), - double_value(0), - npobject_routing_id(-1) { -} - -NPVariant_Param::~NPVariant_Param() { -} - -namespace IPC { - -void ParamTraits<WebKit::WebData>::Write(Message* m, const param_type& p) { - if (p.isEmpty()) { - m->WriteData(NULL, 0); - } else { - m->WriteData(p.data(), p.size()); - } -} - -bool ParamTraits<WebKit::WebData>::Read( - const Message* m, PickleIterator* iter, param_type* r) { - const char *data = NULL; - int data_size = 0; - if (!m->ReadData(iter, &data, &data_size) || data_size < 0) - return false; - if (data_size) - r->assign(data, data_size); - else - r->reset(); - return true; -} - -void ParamTraits<WebKit::WebData>::Log(const param_type& p, std::string* l) { - l->append("(WebData of size "); - LogParam(p.size(), l); - l->append(")"); -} - -void ParamTraits<WebKit::WebTransformationMatrix>::Write( - Message* m, const param_type& p) { - WriteParam(m, p.m11()); - WriteParam(m, p.m12()); - WriteParam(m, p.m13()); - WriteParam(m, p.m14()); - WriteParam(m, p.m21()); - WriteParam(m, p.m22()); - WriteParam(m, p.m23()); - WriteParam(m, p.m24()); - WriteParam(m, p.m31()); - WriteParam(m, p.m32()); - WriteParam(m, p.m33()); - WriteParam(m, p.m34()); - WriteParam(m, p.m41()); - WriteParam(m, p.m42()); - WriteParam(m, p.m43()); - WriteParam(m, p.m44()); -} - -bool ParamTraits<WebKit::WebTransformationMatrix>::Read( - const Message* m, PickleIterator* iter, param_type* r) { - double m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44; - bool success = - ReadParam(m, iter, &m11) && - ReadParam(m, iter, &m12) && - ReadParam(m, iter, &m13) && - ReadParam(m, iter, &m14) && - ReadParam(m, iter, &m21) && - ReadParam(m, iter, &m22) && - ReadParam(m, iter, &m23) && - ReadParam(m, iter, &m24) && - ReadParam(m, iter, &m31) && - ReadParam(m, iter, &m32) && - ReadParam(m, iter, &m33) && - ReadParam(m, iter, &m34) && - ReadParam(m, iter, &m41) && - ReadParam(m, iter, &m42) && - ReadParam(m, iter, &m43) && - ReadParam(m, iter, &m44); - - if (success) { - r->setM11(m11); - r->setM12(m12); - r->setM13(m13); - r->setM14(m14); - r->setM21(m21); - r->setM22(m22); - r->setM23(m23); - r->setM24(m24); - r->setM31(m31); - r->setM32(m32); - r->setM33(m33); - r->setM34(m34); - r->setM41(m41); - r->setM42(m42); - r->setM43(m43); - r->setM44(m44); - } - - return success; -} - -void ParamTraits<WebKit::WebTransformationMatrix>::Log( - const param_type& p, std::string* l) { - l->append("("); - LogParam(p.m11(), l); - l->append(", "); - LogParam(p.m12(), l); - l->append(", "); - LogParam(p.m13(), l); - l->append(", "); - LogParam(p.m14(), l); - l->append(", "); - LogParam(p.m21(), l); - l->append(", "); - LogParam(p.m22(), l); - l->append(", "); - LogParam(p.m23(), l); - l->append(", "); - LogParam(p.m24(), l); - l->append(", "); - LogParam(p.m31(), l); - l->append(", "); - LogParam(p.m32(), l); - l->append(", "); - LogParam(p.m33(), l); - l->append(", "); - LogParam(p.m34(), l); - l->append(", "); - LogParam(p.m41(), l); - l->append(", "); - LogParam(p.m42(), l); - l->append(", "); - LogParam(p.m43(), l); - l->append(", "); - LogParam(p.m44(), l); - l->append(") "); -} - -void ParamTraits<webkit_glue::ResourceLoadTimingInfo>::Write( - Message* m, const param_type& p) { - WriteParam(m, p.base_time.is_null()); - if (p.base_time.is_null()) - return; - WriteParam(m, p.base_ticks); - WriteParam(m, p.base_time); - WriteParam(m, p.proxy_start); - WriteParam(m, p.proxy_end); - WriteParam(m, p.dns_start); - WriteParam(m, p.dns_end); - WriteParam(m, p.connect_start); - WriteParam(m, p.connect_end); - WriteParam(m, p.ssl_start); - WriteParam(m, p.ssl_end); - WriteParam(m, p.send_start); - WriteParam(m, p.send_end); - WriteParam(m, p.receive_headers_start); - WriteParam(m, p.receive_headers_end); -} - -bool ParamTraits<webkit_glue::ResourceLoadTimingInfo>::Read( - const Message* m, PickleIterator* iter, param_type* r) { - bool is_null; - if (!ReadParam(m, iter, &is_null)) - return false; - if (is_null) - return true; - - return - ReadParam(m, iter, &r->base_ticks) && - ReadParam(m, iter, &r->base_time) && - ReadParam(m, iter, &r->proxy_start) && - ReadParam(m, iter, &r->proxy_end) && - ReadParam(m, iter, &r->dns_start) && - ReadParam(m, iter, &r->dns_end) && - ReadParam(m, iter, &r->connect_start) && - ReadParam(m, iter, &r->connect_end) && - ReadParam(m, iter, &r->ssl_start) && - ReadParam(m, iter, &r->ssl_end) && - ReadParam(m, iter, &r->send_start) && - ReadParam(m, iter, &r->send_end) && - ReadParam(m, iter, &r->receive_headers_start) && - ReadParam(m, iter, &r->receive_headers_end); -} - -void ParamTraits<webkit_glue::ResourceLoadTimingInfo>::Log(const param_type& p, - std::string* l) { - l->append("("); - LogParam(p.base_ticks, l); - l->append(", "); - LogParam(p.base_time, l); - l->append(", "); - LogParam(p.proxy_start, l); - l->append(", "); - LogParam(p.proxy_end, l); - l->append(", "); - LogParam(p.dns_start, l); - l->append(", "); - LogParam(p.dns_end, l); - l->append(", "); - LogParam(p.connect_start, l); - l->append(", "); - LogParam(p.connect_end, l); - l->append(", "); - LogParam(p.ssl_start, l); - l->append(", "); - LogParam(p.ssl_end, l); - l->append(", "); - LogParam(p.send_start, l); - l->append(", "); - LogParam(p.send_end, l); - l->append(", "); - LogParam(p.receive_headers_start, l); - l->append(", "); - LogParam(p.receive_headers_end, l); - l->append(")"); -} - -void ParamTraits<scoped_refptr<webkit_glue::ResourceDevToolsInfo> >::Write( - Message* m, const param_type& p) { - WriteParam(m, p.get() != NULL); - if (p.get()) { - WriteParam(m, p->http_status_code); - WriteParam(m, p->http_status_text); - WriteParam(m, p->request_headers); - WriteParam(m, p->response_headers); - WriteParam(m, p->request_headers_text); - WriteParam(m, p->response_headers_text); - } -} - -bool ParamTraits<scoped_refptr<webkit_glue::ResourceDevToolsInfo> >::Read( - const Message* m, PickleIterator* iter, param_type* r) { - bool has_object; - if (!ReadParam(m, iter, &has_object)) - return false; - if (!has_object) - return true; - *r = new webkit_glue::ResourceDevToolsInfo(); - return - ReadParam(m, iter, &(*r)->http_status_code) && - ReadParam(m, iter, &(*r)->http_status_text) && - ReadParam(m, iter, &(*r)->request_headers) && - ReadParam(m, iter, &(*r)->response_headers) && - ReadParam(m, iter, &(*r)->request_headers_text) && - ReadParam(m, iter, &(*r)->response_headers_text); -} - -void ParamTraits<scoped_refptr<webkit_glue::ResourceDevToolsInfo> >::Log( - const param_type& p, std::string* l) { - l->append("("); - if (p) { - LogParam(p->request_headers, l); - l->append(", "); - LogParam(p->response_headers, l); - } - l->append(")"); -} - -void ParamTraits<NPVariant_Param>::Write(Message* m, const param_type& p) { - WriteParam(m, static_cast<int>(p.type)); - if (p.type == NPVARIANT_PARAM_BOOL) { - WriteParam(m, p.bool_value); - } else if (p.type == NPVARIANT_PARAM_INT) { - WriteParam(m, p.int_value); - } else if (p.type == NPVARIANT_PARAM_DOUBLE) { - WriteParam(m, p.double_value); - } else if (p.type == NPVARIANT_PARAM_STRING) { - WriteParam(m, p.string_value); - } else if (p.type == NPVARIANT_PARAM_SENDER_OBJECT_ROUTING_ID || - p.type == NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID) { - // This is the routing id used to connect NPObjectProxy in the other - // process with NPObjectStub in this process or to identify the raw - // npobject pointer to be used in the callee process. - WriteParam(m, p.npobject_routing_id); - } else { - DCHECK(p.type == NPVARIANT_PARAM_VOID || p.type == NPVARIANT_PARAM_NULL); - } -} - -bool ParamTraits<NPVariant_Param>::Read(const Message* m, - PickleIterator* iter, - param_type* r) { - int type; - if (!ReadParam(m, iter, &type)) - return false; - - bool result = false; - r->type = static_cast<NPVariant_ParamEnum>(type); - if (r->type == NPVARIANT_PARAM_BOOL) { - result = ReadParam(m, iter, &r->bool_value); - } else if (r->type == NPVARIANT_PARAM_INT) { - result = ReadParam(m, iter, &r->int_value); - } else if (r->type == NPVARIANT_PARAM_DOUBLE) { - result = ReadParam(m, iter, &r->double_value); - } else if (r->type == NPVARIANT_PARAM_STRING) { - result = ReadParam(m, iter, &r->string_value); - } else if (r->type == NPVARIANT_PARAM_SENDER_OBJECT_ROUTING_ID || - r->type == NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID) { - result = ReadParam(m, iter, &r->npobject_routing_id); - } else if ((r->type == NPVARIANT_PARAM_VOID) || - (r->type == NPVARIANT_PARAM_NULL)) { - result = true; - } else { - NOTREACHED(); - } - - return result; -} - -void ParamTraits<NPVariant_Param>::Log(const param_type& p, std::string* l) { - l->append(StringPrintf("NPVariant_Param(%d, ", static_cast<int>(p.type))); - if (p.type == NPVARIANT_PARAM_BOOL) { - LogParam(p.bool_value, l); - } else if (p.type == NPVARIANT_PARAM_INT) { - LogParam(p.int_value, l); - } else if (p.type == NPVARIANT_PARAM_DOUBLE) { - LogParam(p.double_value, l); - } else if (p.type == NPVARIANT_PARAM_STRING) { - LogParam(p.string_value, l); - } else if (p.type == NPVARIANT_PARAM_SENDER_OBJECT_ROUTING_ID || - p.type == NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID) { - LogParam(p.npobject_routing_id, l); - } else { - l->append("<none>"); - } - l->append(")"); -} - -void ParamTraits<NPIdentifier_Param>::Write(Message* m, const param_type& p) { - webkit_glue::SerializeNPIdentifier(p.identifier, m); -} - -bool ParamTraits<NPIdentifier_Param>::Read(const Message* m, - PickleIterator* iter, - param_type* r) { - return webkit_glue::DeserializeNPIdentifier(iter, &r->identifier); -} - -void ParamTraits<NPIdentifier_Param>::Log(const param_type& p, std::string* l) { - if (WebKit::WebBindings::identifierIsString(p.identifier)) { - NPUTF8* str = WebKit::WebBindings::utf8FromIdentifier(p.identifier); - l->append(str); - webkit::npapi::PluginHost::Singleton()->host_functions()->memfree(str); - } else { - l->append(base::IntToString( - WebKit::WebBindings::intFromIdentifier(p.identifier))); - } -} - -void ParamTraits<webkit::WebPluginMimeType>::Write(Message* m, - const param_type& p) { - WriteParam(m, p.mime_type); - WriteParam(m, p.file_extensions); - WriteParam(m, p.description); - WriteParam(m, p.additional_param_names); - WriteParam(m, p.additional_param_values); -} - -bool ParamTraits<webkit::WebPluginMimeType>::Read(const Message* m, - PickleIterator* iter, - param_type* p) { - return - ReadParam(m, iter, &p->mime_type) && - ReadParam(m, iter, &p->file_extensions) && - ReadParam(m, iter, &p->description) && - ReadParam(m, iter, &p->additional_param_names) && - ReadParam(m, iter, &p->additional_param_values); -} - -void ParamTraits<webkit::WebPluginMimeType>::Log( - const param_type& p, std::string* l) { - l->append("("); - LogParam(p.mime_type, l); l->append(", "); - LogParam(p.file_extensions, l); l->append(", "); - LogParam(p.description, l); l->append(", "); - LogParam(p.additional_param_names, l); l->append(", "); - LogParam(p.additional_param_values, l); - l->append(")"); -} - -void ParamTraits<webkit::WebPluginInfo>::Write(Message* m, - const param_type& p) { - WriteParam(m, p.name); - WriteParam(m, p.path); - WriteParam(m, p.version); - WriteParam(m, p.desc); - WriteParam(m, p.mime_types); - WriteParam(m, p.type); -} - -bool ParamTraits<webkit::WebPluginInfo>::Read(const Message* m, - PickleIterator* iter, - param_type* p) { - return - ReadParam(m, iter, &p->name) && - ReadParam(m, iter, &p->path) && - ReadParam(m, iter, &p->version) && - ReadParam(m, iter, &p->desc) && - ReadParam(m, iter, &p->mime_types) && - ReadParam(m, iter, &p->type); -} -void ParamTraits<webkit::WebPluginInfo>::Log(const param_type& p, - std::string* l) { - l->append("("); - LogParam(p.name, l); l->append(", "); - LogParam(p.path, l); l->append(", "); - LogParam(p.version, l); l->append(", "); - LogParam(p.desc, l); l->append(", "); - LogParam(p.mime_types, l); l->append(", "); - LogParam(p.type, l); - l->append(")"); -} - -void ParamTraits<webkit::forms::PasswordForm>::Write(Message* m, - const param_type& p) { - WriteParam(m, p.signon_realm); - WriteParam(m, p.origin); - WriteParam(m, p.action); - WriteParam(m, p.submit_element); - WriteParam(m, p.username_element); - WriteParam(m, p.username_value); - WriteParam(m, p.password_element); - WriteParam(m, p.password_value); - WriteParam(m, p.old_password_element); - WriteParam(m, p.old_password_value); - WriteParam(m, p.ssl_valid); - WriteParam(m, p.preferred); - WriteParam(m, p.blacklisted_by_user); -} - -bool ParamTraits<webkit::forms::PasswordForm>::Read(const Message* m, - PickleIterator* iter, - param_type* p) { - return - ReadParam(m, iter, &p->signon_realm) && - ReadParam(m, iter, &p->origin) && - ReadParam(m, iter, &p->action) && - ReadParam(m, iter, &p->submit_element) && - ReadParam(m, iter, &p->username_element) && - ReadParam(m, iter, &p->username_value) && - ReadParam(m, iter, &p->password_element) && - ReadParam(m, iter, &p->password_value) && - ReadParam(m, iter, &p->old_password_element) && - ReadParam(m, iter, &p->old_password_value) && - ReadParam(m, iter, &p->ssl_valid) && - ReadParam(m, iter, &p->preferred) && - ReadParam(m, iter, &p->blacklisted_by_user); -} -void ParamTraits<webkit::forms::PasswordForm>::Log(const param_type& p, - std::string* l) { - l->append("<PasswordForm>"); -} - -} // namespace IPC diff --git a/content/renderer/java/java_bridge_dispatcher.h b/content/renderer/java/java_bridge_dispatcher.h index d5f3e56..be291cf 100644 --- a/content/renderer/java/java_bridge_dispatcher.h +++ b/content/renderer/java/java_bridge_dispatcher.h @@ -5,11 +5,15 @@ #ifndef CONTENT_RENDERER_JAVA_JAVA_BRIDGE_DISPATCHER_H_ #define CONTENT_RENDERER_JAVA_JAVA_BRIDGE_DISPATCHER_H_ -#include "content/public/common/webkit_param_traits.h" +#include <map> + +#include "base/memory/ref_counted.h" #include "content/public/renderer/render_view_observer.h" #include "ipc/ipc_channel_handle.h" +#include "third_party/npapi/bindings/npruntime.h" class JavaBridgeChannel; +struct NPVariant_Param; // This class handles injecting Java objects into the main frame of a // RenderView. The 'add' and 'remove' messages received from the browser diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h index 26e42cc..ca4e5f8 100644 --- a/ipc/ipc_message_utils.h +++ b/ipc/ipc_message_utils.h @@ -107,6 +107,7 @@ enum IPCMessageStart { HyphenatorMsgStart, AndroidWebViewMsgStart, ViewerMsgStart, + CCMsgStart, LastIPCMsgStart // Must come last. }; |