diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-11 16:38:22 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-11 16:38:22 +0000 |
commit | ef85bbeac4d297d238bb9c17312261182187cebc (patch) | |
tree | 8b0bfbde3264837374854e8c4ce43356c3677907 /chrome/common | |
parent | b24c81a4c510bec2902b12d4768d6d47aafed9f2 (diff) | |
download | chromium_src-ef85bbeac4d297d238bb9c17312261182187cebc.zip chromium_src-ef85bbeac4d297d238bb9c17312261182187cebc.tar.gz chromium_src-ef85bbeac4d297d238bb9c17312261182187cebc.tar.bz2 |
FBTF: Allow forward declaration of classes passed to sync IPC messages.
This is a continuation of r55259, where we convert the remaining IPC messages
to the new system. At this point, all the messages should be able to accept
forward declared classes/structs as parameters.
BUG=51411
TEST=none
Review URL: http://codereview.chromium.org/3018045
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55735 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/render_messages.cc | 63 | ||||
-rw-r--r-- | chrome/common/render_messages.h | 57 | ||||
-rw-r--r-- | chrome/common/render_messages_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/common/webkit_param_traits.cc | 131 | ||||
-rw-r--r-- | chrome/common/webkit_param_traits.h | 118 |
5 files changed, 222 insertions, 149 deletions
diff --git a/chrome/common/render_messages.cc b/chrome/common/render_messages.cc index 68aa81d..04a258c 100644 --- a/chrome/common/render_messages.cc +++ b/chrome/common/render_messages.cc @@ -5,8 +5,71 @@ #include "chrome/common/render_messages.h" #include "chrome/common/thumbnail_score.h" +#include "third_party/WebKit/WebKit/chromium/public/WebCompositionUnderline.h" +#include "third_party/WebKit/WebKit/chromium/public/WebFindOptions.h" +#include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" +#include "webkit/glue/webaccessibility.h" #include "webkit/glue/webcursor.h" #define MESSAGES_INTERNAL_IMPL_FILE \ "chrome/common/render_messages_internal.h" #include "ipc/ipc_message_impl_macros.h" + +namespace IPC { + +void ParamTraits<webkit_glue::WebAccessibility>::Write(Message* m, + const param_type& p) { + WriteParam(m, p.id); + WriteParam(m, p.name); + WriteParam(m, p.value); + WriteParam(m, static_cast<int>(p.role)); + WriteParam(m, static_cast<int>(p.state)); + WriteParam(m, p.location); + WriteParam(m, p.attributes); + WriteParam(m, p.children); +} + +bool ParamTraits<webkit_glue::WebAccessibility>::Read( + const Message* m, void** iter, param_type* p) { + bool ret = ReadParam(m, iter, &p->id); + ret = ret && ReadParam(m, iter, &p->name); + ret = ret && ReadParam(m, iter, &p->value); + int role = -1; + ret = ret && ReadParam(m, iter, &role); + if (role >= webkit_glue::WebAccessibility::ROLE_NONE && + role < webkit_glue::WebAccessibility::NUM_ROLES) { + p->role = static_cast<webkit_glue::WebAccessibility::Role>(role); + } else { + p->role = webkit_glue::WebAccessibility::ROLE_NONE; + } + int state = 0; + ret = ret && ReadParam(m, iter, &state); + p->state = static_cast<webkit_glue::WebAccessibility::State>(state); + ret = ret && ReadParam(m, iter, &p->location); + ret = ret && ReadParam(m, iter, &p->attributes); + ret = ret && ReadParam(m, iter, &p->children); + return ret; +} + +void ParamTraits<webkit_glue::WebAccessibility>::Log(const param_type& p, + std::wstring* l) { + l->append(L"("); + LogParam(p.id, l); + l->append(L", "); + LogParam(p.name, l); + l->append(L", "); + LogParam(p.value, l); + l->append(L", "); + LogParam(static_cast<int>(p.role), l); + l->append(L", "); + LogParam(static_cast<int>(p.state), l); + l->append(L", "); + LogParam(p.location, l); + l->append(L", "); + LogParam(p.attributes, l); + l->append(L", "); + LogParam(p.children, l); + l->append(L")"); +} + +} // namespace IPC diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index e45d79d..8dc63a9 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -52,7 +52,6 @@ #include "webkit/glue/plugins/webplugin.h" #include "webkit/glue/plugins/webplugininfo.h" #include "webkit/glue/resource_loader_bridge.h" -#include "webkit/glue/webaccessibility.h" #include "webkit/glue/webcookie.h" #include "webkit/glue/webdropdata.h" #include "webkit/glue/webmenuitem.h" @@ -62,6 +61,10 @@ namespace base { class Time; } +namespace webkit_glue { +struct WebAccessibility; +} + class SkBitmap; // Parameters structure for ViewMsg_Navigate, which has too many data @@ -3322,55 +3325,9 @@ struct ParamTraits<WindowContainerType> { template <> struct ParamTraits<webkit_glue::WebAccessibility> { typedef webkit_glue::WebAccessibility param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.id); - WriteParam(m, p.name); - WriteParam(m, p.value); - WriteParam(m, static_cast<int>(p.role)); - WriteParam(m, static_cast<int>(p.state)); - WriteParam(m, p.location); - WriteParam(m, p.attributes); - WriteParam(m, p.children); - } - static bool Read(const Message* m, void** iter, param_type* p) { - bool ret = ReadParam(m, iter, &p->id); - ret = ret && ReadParam(m, iter, &p->name); - ret = ret && ReadParam(m, iter, &p->value); - int role = -1; - ret = ret && ReadParam(m, iter, &role); - if (role >= webkit_glue::WebAccessibility::ROLE_NONE && - role < webkit_glue::WebAccessibility::NUM_ROLES) { - p->role = static_cast<webkit_glue::WebAccessibility::Role>(role); - } else { - p->role = webkit_glue::WebAccessibility::ROLE_NONE; - } - int state = 0; - ret = ret && ReadParam(m, iter, &state); - p->state = static_cast<webkit_glue::WebAccessibility::State>(state); - ret = ret && ReadParam(m, iter, &p->location); - ret = ret && ReadParam(m, iter, &p->attributes); - ret = ret && ReadParam(m, iter, &p->children); - return ret; - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"("); - LogParam(p.id, l); - l->append(L", "); - LogParam(p.name, l); - l->append(L", "); - LogParam(p.value, l); - l->append(L", "); - LogParam(static_cast<int>(p.role), l); - l->append(L", "); - LogParam(static_cast<int>(p.state), l); - l->append(L", "); - LogParam(p.location, l); - l->append(L", "); - LogParam(p.attributes, l); - l->append(L", "); - LogParam(p.children, l); - l->append(L")"); - } + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, void** iter, param_type* p); + static void Log(const param_type& p, std::wstring* l); }; // Traits for ViewMsg_DeviceOrientationUpdated_Params diff --git a/chrome/common/render_messages_unittest.cc b/chrome/common/render_messages_unittest.cc index ccfc898..4fc0aab 100644 --- a/chrome/common/render_messages_unittest.cc +++ b/chrome/common/render_messages_unittest.cc @@ -7,6 +7,8 @@ #include "base/utf_string_conversions.h" #include "chrome/common/render_messages.h" #include "testing/gtest/include/gtest/gtest.h" +#include "webkit/glue/webaccessibility.h" +#include "third_party/WebKit/WebKit/chromium/public/WebRect.h" TEST(RenderMessagesUnittest, WebAccessibility) { // Test a simple case. diff --git a/chrome/common/webkit_param_traits.cc b/chrome/common/webkit_param_traits.cc new file mode 100644 index 0000000..06ee1e2 --- /dev/null +++ b/chrome/common/webkit_param_traits.cc @@ -0,0 +1,131 @@ +// Copyright (c) 2010 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 "chrome/common/webkit_param_traits.h" + +#include "third_party/WebKit/WebKit/chromium/public/WebCompositionUnderline.h" +#include "third_party/WebKit/WebKit/chromium/public/WebFindOptions.h" +#include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" + +namespace IPC { + +void ParamTraits<WebKit::WebRect>::Write(Message* m, const param_type& p) { + WriteParam(m, p.x); + WriteParam(m, p.y); + WriteParam(m, p.width); + WriteParam(m, p.height); + } + +bool ParamTraits<WebKit::WebRect>::Read(const Message* m, void** iter, + param_type* p) { + return + ReadParam(m, iter, &p->x) && + ReadParam(m, iter, &p->y) && + ReadParam(m, iter, &p->width) && + ReadParam(m, iter, &p->height); +} + +void ParamTraits<WebKit::WebRect>::Log(const param_type& p, std::wstring* l) { + l->append(L"("); + LogParam(p.x, l); + l->append(L", "); + LogParam(p.y, l); + l->append(L", "); + LogParam(p.width, l); + l->append(L", "); + LogParam(p.height, l); + l->append(L")"); +} + +void ParamTraits<WebKit::WebScreenInfo>::Write(Message* m, const param_type& p) { + WriteParam(m, p.depth); + WriteParam(m, p.depthPerComponent); + WriteParam(m, p.isMonochrome); + WriteParam(m, p.rect); + WriteParam(m, p.availableRect); +} + +bool ParamTraits<WebKit::WebScreenInfo>::Read(const Message* m, void** iter, + param_type* p) { + return + ReadParam(m, iter, &p->depth) && + ReadParam(m, iter, &p->depthPerComponent) && + ReadParam(m, iter, &p->isMonochrome) && + ReadParam(m, iter, &p->rect) && + ReadParam(m, iter, &p->availableRect); +} + +void ParamTraits<WebKit::WebScreenInfo>::Log(const param_type& p, + std::wstring* l) { + l->append(L"("); + LogParam(p.depth, l); + l->append(L", "); + LogParam(p.depthPerComponent, l); + l->append(L", "); + LogParam(p.isMonochrome, l); + l->append(L", "); + LogParam(p.rect, l); + l->append(L", "); + LogParam(p.availableRect, l); + l->append(L")"); +} + +void ParamTraits<WebKit::WebFindOptions>::Write(Message* m, + const param_type& p) { + WriteParam(m, p.forward); + WriteParam(m, p.matchCase); + WriteParam(m, p.findNext); +} + +bool ParamTraits<WebKit::WebFindOptions>::Read(const Message* m, void** iter, + param_type* p) { + return + ReadParam(m, iter, &p->forward) && + ReadParam(m, iter, &p->matchCase) && + ReadParam(m, iter, &p->findNext); +} + +void ParamTraits<WebKit::WebFindOptions>::Log(const param_type& p, + std::wstring* l) { + l->append(L"("); + LogParam(p.forward, l); + l->append(L", "); + LogParam(p.matchCase, l); + l->append(L", "); + LogParam(p.findNext, l); + l->append(L")"); +} + +void ParamTraits<WebKit::WebCompositionUnderline>::Write(Message* m, + const param_type& p) { + WriteParam(m, p.startOffset); + WriteParam(m, p.endOffset); + WriteParam(m, p.color); + WriteParam(m, p.thick); +} + +bool ParamTraits<WebKit::WebCompositionUnderline>::Read( + const Message* m, void** iter, + param_type* p) { + return + ReadParam(m, iter, &p->startOffset) && + ReadParam(m, iter, &p->endOffset) && + ReadParam(m, iter, &p->color) && + ReadParam(m, iter, &p->thick); +} + +void ParamTraits<WebKit::WebCompositionUnderline>::Log(const param_type& p, + std::wstring* l) { + l->append(L"("); + LogParam(p.startOffset, l); + l->append(L","); + LogParam(p.endOffset, l); + l->append(L":"); + LogParam(p.color, l); + l->append(L":"); + LogParam(p.thick, l); + l->append(L")"); +} + +} // namespace IPC diff --git a/chrome/common/webkit_param_traits.h b/chrome/common/webkit_param_traits.h index 748c26b..4b0433a 100644 --- a/chrome/common/webkit_param_traits.h +++ b/chrome/common/webkit_param_traits.h @@ -26,80 +26,38 @@ #include "ipc/ipc_message_utils.h" #include "third_party/WebKit/WebKit/chromium/public/WebCache.h" -#include "third_party/WebKit/WebKit/chromium/public/WebCompositionUnderline.h" #include "third_party/WebKit/WebKit/chromium/public/WebConsoleMessage.h" #include "third_party/WebKit/WebKit/chromium/public/WebContextMenuData.h" #include "third_party/WebKit/WebKit/chromium/public/WebDragOperation.h" -#include "third_party/WebKit/WebKit/chromium/public/WebFindOptions.h" #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" #include "third_party/WebKit/WebKit/chromium/public/WebMediaPlayerAction.h" #include "third_party/WebKit/WebKit/chromium/public/WebPopupType.h" -#include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" #include "third_party/WebKit/WebKit/chromium/public/WebTextDirection.h" #include "third_party/WebKit/WebKit/chromium/public/WebTextInputType.h" +namespace WebKit { +struct WebCompositionUnderline; +struct WebFindOptions; +struct WebRect; +struct WebScreenInfo; +} + namespace IPC { template <> struct ParamTraits<WebKit::WebRect> { typedef WebKit::WebRect param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.x); - WriteParam(m, p.y); - WriteParam(m, p.width); - WriteParam(m, p.height); - } - static bool Read(const Message* m, void** iter, param_type* p) { - return - ReadParam(m, iter, &p->x) && - ReadParam(m, iter, &p->y) && - ReadParam(m, iter, &p->width) && - ReadParam(m, iter, &p->height); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"("); - LogParam(p.x, l); - l->append(L", "); - LogParam(p.y, l); - l->append(L", "); - LogParam(p.width, l); - l->append(L", "); - LogParam(p.height, l); - l->append(L")"); - } + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, void** iter, param_type* p); + static void Log(const param_type& p, std::wstring* l); }; template <> struct ParamTraits<WebKit::WebScreenInfo> { typedef WebKit::WebScreenInfo param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.depth); - WriteParam(m, p.depthPerComponent); - WriteParam(m, p.isMonochrome); - WriteParam(m, p.rect); - WriteParam(m, p.availableRect); - } - static bool Read(const Message* m, void** iter, param_type* p) { - return - ReadParam(m, iter, &p->depth) && - ReadParam(m, iter, &p->depthPerComponent) && - ReadParam(m, iter, &p->isMonochrome) && - ReadParam(m, iter, &p->rect) && - ReadParam(m, iter, &p->availableRect); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"("); - LogParam(p.depth, l); - l->append(L", "); - LogParam(p.depthPerComponent, l); - l->append(L", "); - LogParam(p.isMonochrome, l); - l->append(L", "); - LogParam(p.rect, l); - l->append(L", "); - LogParam(p.availableRect, l); - l->append(L")"); - } + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, void** iter, param_type* p); + static void Log(const param_type& p, std::wstring* l); }; template <> @@ -141,26 +99,9 @@ struct ParamTraits<WebKit::WebPopupType> { template <> struct ParamTraits<WebKit::WebFindOptions> { typedef WebKit::WebFindOptions param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.forward); - WriteParam(m, p.matchCase); - WriteParam(m, p.findNext); - } - static bool Read(const Message* m, void** iter, param_type* p) { - return - ReadParam(m, iter, &p->forward) && - ReadParam(m, iter, &p->matchCase) && - ReadParam(m, iter, &p->findNext); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"("); - LogParam(p.forward, l); - l->append(L", "); - LogParam(p.matchCase, l); - l->append(L", "); - LogParam(p.findNext, l); - l->append(L")"); - } + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, void** iter, param_type* p); + static void Log(const param_type& p, std::wstring* l); }; template <> @@ -378,30 +319,9 @@ template <> template <> struct ParamTraits<WebKit::WebCompositionUnderline> { typedef WebKit::WebCompositionUnderline param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.startOffset); - WriteParam(m, p.endOffset); - WriteParam(m, p.color); - WriteParam(m, p.thick); - } - static bool Read(const Message* m, void** iter, param_type* p) { - return - ReadParam(m, iter, &p->startOffset) && - ReadParam(m, iter, &p->endOffset) && - ReadParam(m, iter, &p->color) && - ReadParam(m, iter, &p->thick); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"("); - LogParam(p.startOffset, l); - l->append(L","); - LogParam(p.endOffset, l); - l->append(L":"); - LogParam(p.color, l); - l->append(L":"); - LogParam(p.thick, l); - l->append(L")"); - } + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, void** iter, param_type* p); + static void Log(const param_type& p, std::wstring* l); }; template <> |