summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-06 20:21:59 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-06 20:21:59 +0000
commit7ea066a9c3e54b7a2fd0c2ac30c8f4a64cf8eb90 (patch)
tree2f283b622f4ee681e05e7e6119903146f6f4d1ea /chrome/common
parentd2515f6e52f42d4baaa3c676ba1370ffa1f263eb (diff)
downloadchromium_src-7ea066a9c3e54b7a2fd0c2ac30c8f4a64cf8eb90.zip
chromium_src-7ea066a9c3e54b7a2fd0c2ac30c8f4a64cf8eb90.tar.gz
chromium_src-7ea066a9c3e54b7a2fd0c2ac30c8f4a64cf8eb90.tar.bz2
Stop serializing WebString over IPC. The new rule is that only POD (plain old
data) types from WebKit API are allowed to be used in the browser process. I added a big note about this to webkit_param_traits.h to explain the details of this decision. R=dglazkov Review URL: http://codereview.chromium.org/62032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13181 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/render_messages_internal.h13
-rw-r--r--chrome/common/webkit_param_traits.h80
2 files changed, 35 insertions, 58 deletions
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 0020985..4b36a35 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -161,8 +161,10 @@ IPC_BEGIN_MESSAGES(View)
IPC_MESSAGE_CONTROL1(ViewMsg_UserScripts_NewScripts, base::SharedMemoryHandle)
// Sent when the user wants to search for a word on the page (find in page).
- // Request parameters are passed in as a FindInPageMsg_Request struct.
- IPC_MESSAGE_ROUTED1(ViewMsg_Find, WebKit::WebFindInPageRequest)
+ IPC_MESSAGE_ROUTED3(ViewMsg_Find,
+ int /* request_id */,
+ string16 /* search_text */,
+ WebKit::WebFindOptions)
// Sent when the headers are available for a resource request.
IPC_MESSAGE_ROUTED2(ViewMsg_Resource_ReceivedResponse,
@@ -230,9 +232,10 @@ IPC_BEGIN_MESSAGES(View)
std::string /* css string */)
// Log a message to the console of the target frame
- IPC_MESSAGE_ROUTED2(ViewMsg_AddMessageToConsole,
- std::wstring, /* frame_xpath */
- WebKit::WebConsoleMessage /* message */)
+ IPC_MESSAGE_ROUTED3(ViewMsg_AddMessageToConsole,
+ string16 /* frame_xpath */,
+ string16 /* message */,
+ WebKit::WebConsoleMessage::Level /* message_level */)
// Initialize the V8 debugger in the renderer.
IPC_MESSAGE_ROUTED0(ViewMsg_DebugAttach)
diff --git a/chrome/common/webkit_param_traits.h b/chrome/common/webkit_param_traits.h
index d41bccc..74f311a 100644
--- a/chrome/common/webkit_param_traits.h
+++ b/chrome/common/webkit_param_traits.h
@@ -4,6 +4,21 @@
//
// This file contains ParamTraits templates to support serialization of WebKit
// data types over IPC.
+//
+// NOTE: IT IS IMPORTANT THAT ONLY POD (plain old data) TYPES ARE SERIALIZED.
+//
+// There are several reasons for this restrictions:
+//
+// o We don't want inclusion of this file to imply linking to WebKit code.
+//
+// o Many WebKit structures are not thread-safe. WebString, for example,
+// contains a reference counted buffer, which does not use thread-safe
+// reference counting. If we allowed serializing WebString, then we may run
+// the risk of introducing subtle thread-safety bugs if people passed a
+// WebString across threads via PostTask(NewRunnableMethod(...)).
+//
+// o The WebKit API has redundant types for strings, and we should avoid using
+// those beyond code that interfaces with the WebKit API.
#ifndef CHROME_COMMON_WEBKIT_PARAM_TRAITS_H_
#define CHROME_COMMON_WEBKIT_PARAM_TRAITS_H_
@@ -11,7 +26,7 @@
#include "chrome/common/ipc_message_utils.h"
#include "third_party/WebKit/WebKit/chromium/public/WebCache.h"
#include "third_party/WebKit/WebKit/chromium/public/WebConsoleMessage.h"
-#include "third_party/WebKit/WebKit/chromium/public/WebFindInPageRequest.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/WebScreenInfo.h"
@@ -80,27 +95,6 @@ struct ParamTraits<WebKit::WebScreenInfo> {
};
template <>
-struct ParamTraits<WebKit::WebString> {
- typedef WebKit::WebString param_type;
- static void Write(Message* m, const param_type& p) {
- m->WriteData(reinterpret_cast<const char*>(p.data()),
- static_cast<int>(p.length() * sizeof(WebKit::WebUChar)));
- }
- static bool Read(const Message* m, void** iter, param_type* p) {
- const char* data;
- int data_len;
- if (!m->ReadData(iter, &data, &data_len))
- return false;
- p->assign(reinterpret_cast<const WebKit::WebUChar*>(data),
- static_cast<size_t>(data_len / sizeof(WebKit::WebUChar)));
- return true;
- }
- static void Log(const param_type& p, std::wstring* l) {
- l->append(UTF16ToWideHack(p));
- }
-};
-
-template <>
struct ParamTraits<WebKit::WebConsoleMessage::Level> {
typedef WebKit::WebConsoleMessage::Level param_type;
static void Write(Message* m, const param_type& p) {
@@ -119,46 +113,27 @@ struct ParamTraits<WebKit::WebConsoleMessage::Level> {
};
template <>
-struct ParamTraits<WebKit::WebConsoleMessage> {
- typedef WebKit::WebConsoleMessage param_type;
+struct ParamTraits<WebKit::WebFindOptions> {
+ typedef WebKit::WebFindOptions param_type;
static void Write(Message* m, const param_type& p) {
- WriteParam(m, p.level);
- WriteParam(m, p.text);
- }
- static bool Read(const Message* m, void** iter, param_type* r) {
- return
- ReadParam(m, iter, &r->level) &&
- ReadParam(m, iter, &r->text);
- }
- static void Log(const param_type& p, std::wstring* l) {
- l->append(L"(");
- LogParam(p.level, l);
- l->append(L", ");
- LogParam(p.text, l);
- l->append(L")");
- }
-};
-
-template <>
-struct ParamTraits<WebKit::WebFindInPageRequest> {
- typedef WebKit::WebFindInPageRequest param_type;
- static void Write(Message* m, const param_type& p) {
- WriteParam(m, p.identifier);
- WriteParam(m, p.text);
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->identifier) &&
- ReadParam(m, iter, &p->text) &&
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"<FindInPageRequest>");
+ l->append(L"(");
+ LogParam(p.forward, l);
+ l->append(L", ");
+ LogParam(p.matchCase, l);
+ l->append(L", ");
+ LogParam(p.findNext, l);
+ l->append(L")");
}
};
@@ -176,7 +151,7 @@ struct ParamTraits<WebKit::WebInputEvent::Type> {
return true;
}
static void Log(const param_type& p, std::wstring* l) {
- std::wstring type;
+ const wchar_t* type;
switch (p) {
case WebKit::WebInputEvent::MouseDown:
type = L"MouseDown";
@@ -209,11 +184,10 @@ struct ParamTraits<WebKit::WebInputEvent::Type> {
type = L"None";
break;
}
- LogParam(type, l);
+ LogParam(std::wstring(type), l);
}
};
-// Traits for WebKit::WebCache::UsageStats
template <>
struct ParamTraits<WebKit::WebCache::UsageStats> {
typedef WebKit::WebCache::UsageStats param_type;