diff options
Diffstat (limited to 'chrome/common')
22 files changed, 1173 insertions, 1212 deletions
diff --git a/chrome/common/common.scons b/chrome/common/common.scons index ae4c0bf..7e5cc14 100644 --- a/chrome/common/common.scons +++ b/chrome/common/common.scons @@ -94,10 +94,8 @@ input_files = ChromeFileList([ 'ipc_sync_channel.h', 'ipc_sync_message.cc', 'ipc_sync_message.h', - 'plugin_messages.cc', 'plugin_messages.h', 'plugin_messages_internal.h', - 'render_messages.cc', 'render_messages.h', 'render_messages_internal.h', ]), @@ -229,7 +227,6 @@ if not env.Bit('windows'): 'gfx/path.cc', 'ipc_logging.cc', 'os_exchange_data.cc', - 'plugin_messages.cc', 'process_watcher.cc', ) diff --git a/chrome/common/common.vcproj b/chrome/common/common.vcproj index c0f6af6..c3986d2b 100644 --- a/chrome/common/common.vcproj +++ b/chrome/common/common.vcproj @@ -285,10 +285,6 @@ > </File> <File - RelativePath=".\plugin_messages.cc" - > - </File> - <File RelativePath=".\plugin_messages.h" > </File> @@ -297,10 +293,6 @@ > </File> <File - RelativePath=".\render_messages.cc" - > - </File> - <File RelativePath=".\render_messages.h" > </File> diff --git a/chrome/common/ipc_fuzzing_tests.cc b/chrome/common/ipc_fuzzing_tests.cc index cbd2bd3..6e67844 100644 --- a/chrome/common/ipc_fuzzing_tests.cc +++ b/chrome/common/ipc_fuzzing_tests.cc @@ -96,10 +96,9 @@ TEST(IPCMessageIntegrity, ReadVectorTooLarge2) { EXPECT_FALSE(ReadParam(&m, &iter, &vec)); } -// Typically the ipc_message_macros files is included twice but here we only -// include it once in 'enum mode' because we want more control of the class -// definitions. -#define IPC_MESSAGE_MACROS_ENUMS +// We don't actually use the messages defined in this fiel, but we do this +// to get to the IPC macros. +#define MESSAGES_INTERNAL_FILE "chrome/common/ipc_sync_message_unittest.h" #include "chrome/common/ipc_message_macros.h" enum IPCMessageIds { diff --git a/chrome/common/ipc_logging.cc b/chrome/common/ipc_logging.cc index ec2fe82..2946093 100644 --- a/chrome/common/ipc_logging.cc +++ b/chrome/common/ipc_logging.cc @@ -41,6 +41,8 @@ Logging::Logging() consumer_(NULL), queue_invoke_later_pending_(false), main_thread_(MessageLoop::current()) { + memset(log_function_mapping_, sizeof(log_function_mapping_), 0); + // Create an event for this browser instance that's set when logging is // enabled, so child processes can know when logging is enabled. int browser_pid; @@ -88,8 +90,18 @@ void Logging::OnObjectSignaled(HANDLE object) { RegisterWaitForEvent(!enabled_); } +void Logging::RegisterMessageLogger(int msg_start, LogFunction* func) { + int msg_class = msg_start >> 12; + if (msg_class > arraysize(log_function_mapping_)) { + NOTREACHED(); + return; + } + + log_function_mapping_[msg_class] = func; +} + std::wstring Logging::GetEventName(bool enabled) { - return Logging::current()->GetEventName(GetCurrentProcessId(), enabled); + return current()->GetEventName(GetCurrentProcessId(), enabled); } std::wstring Logging::GetEventName(int browser_pid, bool enabled) { @@ -188,24 +200,12 @@ void Logging::OnPostDispatchMessage(const Message& message, } } -// static -LogFunction* g_log_function_mapping[16]; -void RegisterMessageLogger(int msg_start, LogFunction* func) { - int msg_class = msg_start >> 12; - if (msg_class > arraysize(g_log_function_mapping)) { - NOTREACHED(); - return; - } - - g_log_function_mapping[msg_class] = func; -} - void Logging::GetMessageText(uint16 type, std::wstring* name, const Message* message, std::wstring* params) { int message_class = type >> 12; - if (g_log_function_mapping[message_class] != NULL) { - g_log_function_mapping[message_class](type, name, message, params); + if (current()->log_function_mapping_[message_class] != NULL) { + current()->log_function_mapping_[message_class](type, name, message, params); } else { DLOG(INFO) << "No logger function associated with message class " << message_class; diff --git a/chrome/common/ipc_logging.h b/chrome/common/ipc_logging.h index 567ba84..bf49595 100644 --- a/chrome/common/ipc_logging.h +++ b/chrome/common/ipc_logging.h @@ -12,6 +12,7 @@ #include "base/lock.h" #include "base/object_watcher.h" #include "base/singleton.h" +#include "chrome/common/ipc_message_utils.h" class MessageLoop; @@ -27,7 +28,7 @@ class Logging : public base::ObjectWatcher::Delegate { // Implemented by consumers of log messages. class Consumer { public: - virtual void Log(const IPC::LogData& data) = 0; + virtual void Log(const LogData& data) = 0; }; void SetConsumer(Consumer* consumer); @@ -41,7 +42,7 @@ class Logging : public base::ObjectWatcher::Delegate { // Called by child processes to give the logger object the channel to send // logging data to the browser process. - void SetIPCSender(IPC::Message::Sender* sender); + void SetIPCSender(Message::Sender* sender); // Called in the browser process when logging data from a child process is // received. @@ -66,8 +67,14 @@ class Logging : public base::ObjectWatcher::Delegate { // ObjectWatcher::Delegate implementation void OnObjectSignaled(HANDLE object); + typedef void (LogFunction)(uint16 type, + std::wstring* name, + const Message* msg, + std::wstring* params); + void RegisterMessageLogger(int msg_start, LogFunction* func); + private: - friend struct DefaultSingletonTraits<IPC::Logging>; + friend struct DefaultSingletonTraits<Logging>; Logging(); std::wstring GetEventName(int browser_pid, bool enabled); @@ -85,10 +92,12 @@ class Logging : public base::ObjectWatcher::Delegate { std::vector<LogData> queued_logs_; bool queue_invoke_later_pending_; - IPC::Message::Sender* sender_; + Message::Sender* sender_; MessageLoop* main_thread_; Consumer* consumer_; + + LogFunction* log_function_mapping_[LastMsgIndex]; }; } // namespace IPC diff --git a/chrome/common/ipc_message_macros.h b/chrome/common/ipc_message_macros.h index e724e2e..49c15b5 100644 --- a/chrome/common/ipc_message_macros.h +++ b/chrome/common/ipc_message_macros.h @@ -41,6 +41,33 @@ #include "chrome/common/ipc_message_utils.h" + +#ifndef MESSAGES_INTERNAL_FILE +#error This file should only be included by X_messages.h, which needs to define MESSAGES_INTERNAL_FILE first. +#endif + +#ifndef IPC_MESSAGE_MACROS_INCLUDE_BLOCK +#define IPC_MESSAGE_MACROS_INCLUDE_BLOCK + +// Multi-pass include of X_messages_internal.h. Preprocessor magic allows +// us to use 1 header to define the enums and classes for our render messages. +#define IPC_MESSAGE_MACROS_ENUMS +#include MESSAGES_INTERNAL_FILE + +#define IPC_MESSAGE_MACROS_CLASSES +#include MESSAGES_INTERNAL_FILE + +#ifdef IPC_MESSAGE_MACROS_LOG_ENABLED +#define IPC_MESSAGE_MACROS_LOG +#include MESSAGES_INTERNAL_FILE +#endif + +#undef MESSAGES_INTERNAL_FILE +#undef IPC_MESSAGE_MACROS_INCLUDE_BLOCK + +#endif + + // Undefine the macros from the previous pass (if any). #undef IPC_BEGIN_MESSAGES #undef IPC_END_MESSAGES @@ -57,7 +84,6 @@ #undef IPC_MESSAGE_ROUTED4 #undef IPC_MESSAGE_ROUTED5 #undef IPC_MESSAGE_ROUTED6 -#undef IPC_MESSAGE_EMPTY #undef IPC_SYNC_MESSAGE_CONTROL0_0 #undef IPC_SYNC_MESSAGE_CONTROL0_1 #undef IPC_SYNC_MESSAGE_CONTROL0_2 @@ -94,6 +120,7 @@ #undef IPC_SYNC_MESSAGE_ROUTED4_0 #undef IPC_SYNC_MESSAGE_ROUTED4_1 + #if defined(IPC_MESSAGE_MACROS_ENUMS) #undef IPC_MESSAGE_MACROS_ENUMS @@ -102,10 +129,11 @@ // 16 channel types (currently using 8) and 4K messages per type. Should // really make type be 32 bits, but then we break automation with older Chrome // builds.. -#define IPC_BEGIN_MESSAGES(label, start) \ + +#define IPC_BEGIN_MESSAGES(label) \ enum label##MsgType { \ - label##Start = start << 12, \ - label##PreStart = (start << 12) - 1, // Do this so that automation messages keep the same id as before + label##Start = label##MsgStart << 12, \ + label##PreStart = (label##MsgStart << 12) - 1, // Do this so that automation messages keep the same id as before #define IPC_END_MESSAGES(label) \ label##End \ @@ -150,9 +178,6 @@ #define IPC_MESSAGE_ROUTED6(msg_class, type1, type2, type3, type4, type5, type6) \ msg_class##__ID, -#define IPC_MESSAGE_EMPTY(msg_class) \ - msg_class##__ID, - #define IPC_SYNC_MESSAGE_CONTROL0_0(msg_class) \ msg_class##__ID, @@ -341,7 +366,7 @@ void class_name::OnMessageReceived(const IPC::Message& msg) \ #elif defined(IPC_MESSAGE_MACROS_LOG) #undef IPC_MESSAGE_MACROS_LOG -#define IPC_BEGIN_MESSAGES(label, start) \ +#define IPC_BEGIN_MESSAGES(label) \ void label##MsgLog(uint16 type, std::wstring* name, const IPC::Message* msg, std::wstring* params) { \ switch (type) { @@ -399,9 +424,6 @@ void class_name::OnMessageReceived(const IPC::Message& msg) \ #define IPC_MESSAGE_ROUTED6(msg_class, type1, type2, type3, type4, type5, type6) \ IPC_MESSAGE_LOG(msg_class) -#define IPC_MESSAGE_EMPTY(msg_class) \ - IPC_MESSAGE_LOG(msg_class) - #define IPC_SYNC_MESSAGE_CONTROL0_0(msg_class) \ IPC_MESSAGE_LOG(msg_class) @@ -510,7 +532,7 @@ void class_name::OnMessageReceived(const IPC::Message& msg) \ #elif defined(IPC_MESSAGE_MACROS_CLASSES) #undef IPC_MESSAGE_MACROS_CLASSES -#define IPC_BEGIN_MESSAGES(label, start) +#define IPC_BEGIN_MESSAGES(label) #define IPC_END_MESSAGES(label) #define IPC_MESSAGE_CONTROL0(msg_class) \ @@ -655,14 +677,6 @@ void class_name::OnMessageReceived(const IPC::Message& msg) \ routing_id, ID, MakeTuple(arg1, arg2, arg3, arg4, arg5, arg6)) {} \ }; -// Dummy class for now, just to give us the ID field. -#define IPC_MESSAGE_EMPTY(msg_class) \ - class msg_class { \ - public: \ - enum { ID = msg_class##__ID }; \ - static void Log(const IPC::Message* msg, std::wstring* l) {} \ - }; - #define IPC_SYNC_MESSAGE_CONTROL0_0(msg_class) \ class msg_class : public IPC::MessageWithReply<Tuple0, Tuple0 > { \ public: \ diff --git a/chrome/common/ipc_message_unittest.cc b/chrome/common/ipc_message_unittest.cc index 8596185..d6ff045 100644 --- a/chrome/common/ipc_message_unittest.cc +++ b/chrome/common/ipc_message_unittest.cc @@ -20,11 +20,11 @@ TEST(IPCMessageTest, Serialize) { for (size_t i = 0; i < arraysize(serialize_cases); i++) { GURL input(serialize_cases[i]); IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); - IPC::ParamTraits<GURL>::Write(&msg, input); + ParamTraits<GURL>::Write(&msg, input); GURL output; void* iter = NULL; - EXPECT_TRUE(IPC::ParamTraits<GURL>::Read(&msg, &iter, &output)); + EXPECT_TRUE(ParamTraits<GURL>::Read(&msg, &iter, &output)); // We want to test each component individually to make sure its range was // correctly serialized and deserialized, not just the spec. @@ -45,6 +45,6 @@ TEST(IPCMessageTest, Serialize) { msg.WriteInt(99); GURL output; void* iter = NULL; - EXPECT_FALSE(IPC::ParamTraits<GURL>::Read(&msg, &iter, &output)); + EXPECT_FALSE(ParamTraits<GURL>::Read(&msg, &iter, &output)); } diff --git a/chrome/common/ipc_message_utils.cc b/chrome/common/ipc_message_utils.cc index 2512ff4..cf82dc8 100644 --- a/chrome/common/ipc_message_utils.cc +++ b/chrome/common/ipc_message_utils.cc @@ -9,8 +9,6 @@ #include "SkBitmap.h" #include "webkit/glue/dom_operations.h" -namespace IPC { - namespace { struct SkBitmap_Data { @@ -46,7 +44,7 @@ struct SkBitmap_Data { } // namespace -void ParamTraits<SkBitmap>::Write(Message* m, const SkBitmap& p) { +void ParamTraits<SkBitmap>::Write(IPC::Message* m, const SkBitmap& p) { size_t fixed_size = sizeof(SkBitmap_Data); SkBitmap_Data bmp_data; bmp_data.InitSkBitmapDataForTransfer(p); @@ -58,7 +56,7 @@ void ParamTraits<SkBitmap>::Write(Message* m, const SkBitmap& p) { static_cast<int>(pixel_size)); } -bool ParamTraits<SkBitmap>::Read(const Message* m, void** iter, SkBitmap* r) { +bool ParamTraits<SkBitmap>::Read(const IPC::Message* m, void** iter, SkBitmap* r) { const char* fixed_data; int fixed_data_size = 0; if (!m->ReadData(iter, &fixed_data, &fixed_data_size) || @@ -87,12 +85,12 @@ void ParamTraits<SkBitmap>::Log(const SkBitmap& p, std::wstring* l) { } -void ParamTraits<GURL>::Write(Message* m, const GURL& p) { +void ParamTraits<GURL>::Write(IPC::Message* m, const GURL& p) { m->WriteString(p.possibly_invalid_spec()); // TODO(brettw) bug 684583: Add encoding for query params. } -bool ParamTraits<GURL>::Read(const Message* m, void** iter, GURL* p) { +bool ParamTraits<GURL>::Read(const IPC::Message* m, void** iter, GURL* p) { std::string s; if (!m->ReadString(iter, &s)) { *p = GURL(); @@ -107,12 +105,12 @@ void ParamTraits<GURL>::Log(const GURL& p, std::wstring* l) { } -void ParamTraits<gfx::Point>::Write(Message* m, const gfx::Point& p) { +void ParamTraits<gfx::Point>::Write(IPC::Message* m, const gfx::Point& p) { m->WriteInt(p.x()); m->WriteInt(p.y()); } -bool ParamTraits<gfx::Point>::Read(const Message* m, void** iter, +bool ParamTraits<gfx::Point>::Read(const IPC::Message* m, void** iter, gfx::Point* r) { int x, y; if (!m->ReadInt(iter, &x) || @@ -128,14 +126,14 @@ void ParamTraits<gfx::Point>::Log(const gfx::Point& p, std::wstring* l) { } -void ParamTraits<gfx::Rect>::Write(Message* m, const gfx::Rect& p) { +void ParamTraits<gfx::Rect>::Write(IPC::Message* m, const gfx::Rect& p) { m->WriteInt(p.x()); m->WriteInt(p.y()); m->WriteInt(p.width()); m->WriteInt(p.height()); } -bool ParamTraits<gfx::Rect>::Read(const Message* m, void** iter, gfx::Rect* r) { +bool ParamTraits<gfx::Rect>::Read(const IPC::Message* m, void** iter, gfx::Rect* r) { int x, y, w, h; if (!m->ReadInt(iter, &x) || !m->ReadInt(iter, &y) || @@ -155,12 +153,12 @@ void ParamTraits<gfx::Rect>::Log(const gfx::Rect& p, std::wstring* l) { } -void ParamTraits<gfx::Size>::Write(Message* m, const gfx::Size& p) { +void ParamTraits<gfx::Size>::Write(IPC::Message* m, const gfx::Size& p) { m->WriteInt(p.width()); m->WriteInt(p.height()); } -bool ParamTraits<gfx::Size>::Read(const Message* m, void** iter, gfx::Size* r) { +bool ParamTraits<gfx::Size>::Read(const IPC::Message* m, void** iter, gfx::Size* r) { int w, h; if (!m->ReadInt(iter, &w) || !m->ReadInt(iter, &h)) @@ -175,7 +173,7 @@ void ParamTraits<gfx::Size>::Log(const gfx::Size& p, std::wstring* l) { } void ParamTraits<webkit_glue::WebApplicationInfo>::Write( - Message* m, const webkit_glue::WebApplicationInfo& p) { + IPC::Message* m, const webkit_glue::WebApplicationInfo& p) { WriteParam(m, p.title); WriteParam(m, p.description); WriteParam(m, p.app_url); @@ -188,7 +186,7 @@ void ParamTraits<webkit_glue::WebApplicationInfo>::Write( } bool ParamTraits<webkit_glue::WebApplicationInfo>::Read( - const Message* m, void** iter, webkit_glue::WebApplicationInfo* r) { + const IPC::Message* m, void** iter, webkit_glue::WebApplicationInfo* r) { size_t icon_count; bool result = ReadParam(m, iter, &r->title) && @@ -212,6 +210,3 @@ void ParamTraits<webkit_glue::WebApplicationInfo>::Log( const webkit_glue::WebApplicationInfo& p, std::wstring* l) { l->append(L"<WebApplicationInfo>"); } - -} // namespace IPC - diff --git a/chrome/common/ipc_message_utils.h b/chrome/common/ipc_message_utils.h index 39bb231..35146ee 100644 --- a/chrome/common/ipc_message_utils.h +++ b/chrome/common/ipc_message_utils.h @@ -34,70 +34,43 @@ namespace webkit_glue { struct WebApplicationInfo; } // namespace webkit_glue -namespace IPC { - -// Used by the message macros to register a logging function based on the -// message class. -typedef void (LogFunction)(uint16 type, - std::wstring* name, - const IPC::Message* msg, - std::wstring* params); -void RegisterMessageLogger(int msg_start, LogFunction* func); - - -//----------------------------------------------------------------------------- -// An iterator class for reading the fields contained within a Message. - -class MessageIterator { - public: - explicit MessageIterator(const Message& m) : msg_(m), iter_(NULL) { - } - int NextInt() const { - int val; - if (!msg_.ReadInt(&iter_, &val)) - NOTREACHED(); - return val; - } - intptr_t NextIntPtr() const { - intptr_t val; - if (!msg_.ReadIntPtr(&iter_, &val)) - NOTREACHED(); - return val; - } - const std::string NextString() const { - std::string val; - if (!msg_.ReadString(&iter_, &val)) - NOTREACHED(); - return val; - } - const std::wstring NextWString() const { - std::wstring val; - if (!msg_.ReadWString(&iter_, &val)) - NOTREACHED(); - return val; - } - const void NextData(const char** data, int* length) const { - if (!msg_.ReadData(&iter_, data, length)) { - NOTREACHED(); - } - } - private: - const Message& msg_; - mutable void* iter_; +// Used by IPC_BEGIN_MESSAGES so that each message class starts from a unique +// base. Messages have unique IDs across channels in order for the IPC logging +// code to figure out the message class from its ID. +enum IPCMessageStart { + // By using a start value of 0 for automation messages, we keep backward + // compatibility with old builds. + AutomationMsgStart = 0, + ViewMsgStart, + ViewHostMsgStart, + PluginProcessMsgStart, + PluginProcessHostMsgStart, + PluginMsgStart, + PluginHostMsgStart, + NPObjectMsgStart, + TestMsgStart, + // NOTE: When you add a new message class, also update + // IPCStatusView::IPCStatusView to ensure logging works. + // NOTE: this enum is used by IPC_MESSAGE_MACRO to generate a unique message + // id. Only 4 bits are used for the message type, so if this enum needs more + // than 16 entries, that code needs to be updated. + LastMsgIndex }; +COMPILE_ASSERT(LastMsgIndex <= 16, need_to_update_IPC_MESSAGE_MACRO); + //----------------------------------------------------------------------------- // ParamTraits specializations, etc. template <class P> struct ParamTraits {}; template <class P> -static inline void WriteParam(Message* m, const P& p) { +static inline void WriteParam(IPC::Message* m, const P& p) { ParamTraits<P>::Write(m, p); } template <class P> -static inline bool ReadParam(const Message* m, void** iter, P* p) { +static inline bool ReadParam(const IPC::Message* m, void** iter, P* p) { return ParamTraits<P>::Read(m, iter, p); } @@ -109,10 +82,10 @@ static inline void LogParam(const P& p, std::wstring* l) { template <> struct ParamTraits<bool> { typedef bool param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { m->WriteBool(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { return m->ReadBool(iter, r); } static void Log(const param_type& p, std::wstring* l) { @@ -123,10 +96,10 @@ struct ParamTraits<bool> { template <> struct ParamTraits<int> { typedef int param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { m->WriteInt(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { return m->ReadInt(iter, r); } static void Log(const param_type& p, std::wstring* l) { @@ -137,10 +110,10 @@ struct ParamTraits<int> { template <> struct ParamTraits<long> { typedef long param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { m->WriteLong(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { return m->ReadLong(iter, r); } static void Log(const param_type& p, std::wstring* l) { @@ -151,10 +124,10 @@ struct ParamTraits<long> { template <> struct ParamTraits<size_t> { typedef size_t param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { m->WriteSize(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { return m->ReadSize(iter, r); } static void Log(const param_type& p, std::wstring* l) { @@ -168,10 +141,10 @@ struct ParamTraits<size_t> { template <> struct ParamTraits<uint32> { typedef uint32 param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { m->WriteUInt32(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { return m->ReadUInt32(iter, r); } static void Log(const param_type& p, std::wstring* l) { @@ -183,10 +156,10 @@ struct ParamTraits<uint32> { template <> struct ParamTraits<int64> { typedef int64 param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { m->WriteInt64(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { return m->ReadInt64(iter, r); } static void Log(const param_type& p, std::wstring* l) { @@ -197,10 +170,10 @@ struct ParamTraits<int64> { template <> struct ParamTraits<uint64> { typedef uint64 param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { m->WriteInt64(static_cast<int64>(p)); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { return m->ReadInt64(iter, reinterpret_cast<int64*>(r)); } static void Log(const param_type& p, std::wstring* l) { @@ -211,10 +184,10 @@ struct ParamTraits<uint64> { template <> struct ParamTraits<double> { typedef double param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { m->WriteData(reinterpret_cast<const char*>(&p), sizeof(param_type)); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { const char *data; int data_size = 0; bool result = m->ReadData(iter, &data, &data_size); @@ -235,10 +208,10 @@ struct ParamTraits<double> { template <> struct ParamTraits<wchar_t> { typedef wchar_t param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { m->WriteData(reinterpret_cast<const char*>(&p), sizeof(param_type)); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { const char *data; int data_size = 0; bool result = m->ReadData(iter, &data, &data_size); @@ -259,10 +232,10 @@ struct ParamTraits<wchar_t> { template <> struct ParamTraits<base::Time> { typedef base::Time param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { ParamTraits<int64>::Write(m, p.ToInternalValue()); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { int64 value; if (!ParamTraits<int64>::Read(m, iter, &value)) return false; @@ -278,10 +251,10 @@ struct ParamTraits<base::Time> { template <> struct ParamTraits<LOGFONT> { typedef LOGFONT param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { m->WriteData(reinterpret_cast<const char*>(&p), sizeof(LOGFONT)); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { const char *data; int data_size = 0; bool result = m->ReadData(iter, &data, &data_size); @@ -302,10 +275,10 @@ struct ParamTraits<LOGFONT> { template <> struct ParamTraits<MSG> { typedef MSG param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { m->WriteData(reinterpret_cast<const char*>(&p), sizeof(MSG)); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { const char *data; int data_size = 0; bool result = m->ReadData(iter, &data, &data_size); @@ -324,11 +297,11 @@ struct ParamTraits<MSG> { template <> struct ParamTraits<SkBitmap> { typedef SkBitmap param_type; - static void Write(Message* m, const param_type& p); + static void Write(IPC::Message* m, const param_type& p); // Note: This function expects parameter |r| to be of type &SkBitmap since // r->SetConfig() and r->SetPixels() are called. - static bool Read(const Message* m, void** iter, param_type* r); + static bool Read(const IPC::Message* m, void** iter, param_type* r); static void Log(const param_type& p, std::wstring* l); }; @@ -336,10 +309,10 @@ struct ParamTraits<SkBitmap> { template <> struct ParamTraits<std::string> { typedef std::string param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { m->WriteString(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { return m->ReadString(iter, r); } static void Log(const param_type& p, std::wstring* l) { @@ -350,7 +323,7 @@ struct ParamTraits<std::string> { template <> struct ParamTraits<std::vector<unsigned char> > { typedef std::vector<unsigned char> param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { if (p.size() == 0) { m->WriteData(NULL, 0); } else { @@ -358,7 +331,7 @@ struct ParamTraits<std::vector<unsigned char> > { static_cast<int>(p.size())); } } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { const char *data; int data_size = 0; if (!m->ReadData(iter, &data, &data_size) || data_size < 0) @@ -377,14 +350,14 @@ struct ParamTraits<std::vector<unsigned char> > { template <> struct ParamTraits<std::vector<char> > { typedef std::vector<char> param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { if (p.size() == 0) { m->WriteData(NULL, 0); } else { m->WriteData(&p.front(), static_cast<int>(p.size())); } } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { const char *data; int data_size = 0; if (!m->ReadData(iter, &data, &data_size) || data_size < 0) @@ -403,12 +376,12 @@ struct ParamTraits<std::vector<char> > { template <class P> struct ParamTraits<std::vector<P> > { typedef std::vector<P> param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, static_cast<int>(p.size())); for (size_t i = 0; i < p.size(); i++) WriteParam(m, p[i]); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { int size; if (!m->ReadLength(iter, &size)) return false; @@ -442,7 +415,7 @@ struct ParamTraits<std::vector<P> > { template <class K, class V> struct ParamTraits<std::map<K, V> > { typedef std::map<K, V> param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, static_cast<int>(p.size())); typename param_type::const_iterator iter; for (iter = p.begin(); iter != p.end(); ++iter) { @@ -450,7 +423,7 @@ struct ParamTraits<std::map<K, V> > { WriteParam(m, iter->second); } } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { int size; if (!ReadParam(m, iter, &size) || size < 0) return false; @@ -472,10 +445,10 @@ struct ParamTraits<std::map<K, V> > { template <> struct ParamTraits<std::wstring> { typedef std::wstring param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { m->WriteWString(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { return m->ReadWString(iter, r); } static void Log(const param_type& p, std::wstring* l) { @@ -486,8 +459,8 @@ struct ParamTraits<std::wstring> { template <> struct ParamTraits<GURL> { typedef GURL param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* p); + static void Write(IPC::Message* m, const param_type& p); + static bool Read(const IPC::Message* m, void** iter, param_type* p); static void Log(const param_type& p, std::wstring* l); }; @@ -496,10 +469,10 @@ struct ParamTraits<GURL> { template <> struct ParamTraits<HANDLE> { typedef HANDLE param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { m->WriteIntPtr(reinterpret_cast<intptr_t>(p)); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { DCHECK_EQ(sizeof(param_type), sizeof(intptr_t)); return m->ReadIntPtr(iter, reinterpret_cast<intptr_t*>(r)); } @@ -511,10 +484,10 @@ struct ParamTraits<HANDLE> { template <> struct ParamTraits<HCURSOR> { typedef HCURSOR param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { m->WriteIntPtr(reinterpret_cast<intptr_t>(p)); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { DCHECK_EQ(sizeof(param_type), sizeof(intptr_t)); return m->ReadIntPtr(iter, reinterpret_cast<intptr_t*>(r)); } @@ -526,10 +499,10 @@ struct ParamTraits<HCURSOR> { template <> struct ParamTraits<HWND> { typedef HWND param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { m->WriteIntPtr(reinterpret_cast<intptr_t>(p)); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { DCHECK_EQ(sizeof(param_type), sizeof(intptr_t)); return m->ReadIntPtr(iter, reinterpret_cast<intptr_t*>(r)); } @@ -541,7 +514,7 @@ struct ParamTraits<HWND> { template <> struct ParamTraits<HRGN> { typedef HRGN param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { int data_size = GetRegionData(p, 0, NULL); if (data_size) { char* bytes = new char[data_size]; @@ -552,7 +525,7 @@ struct ParamTraits<HRGN> { m->WriteData(NULL, 0); } } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { bool res = FALSE; const char *data; int data_size = 0; @@ -574,10 +547,10 @@ struct ParamTraits<HRGN> { template <> struct ParamTraits<HACCEL> { typedef HACCEL param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { m->WriteIntPtr(reinterpret_cast<intptr_t>(p)); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { DCHECK_EQ(sizeof(param_type), sizeof(intptr_t)); return m->ReadIntPtr(iter, reinterpret_cast<intptr_t*>(r)); } @@ -586,11 +559,11 @@ struct ParamTraits<HACCEL> { template <> struct ParamTraits<POINT> { typedef POINT param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { m->WriteInt(p.x); m->WriteInt(p.y); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { int x, y; if (!m->ReadInt(iter, &x) || !m->ReadInt(iter, &y)) return false; @@ -607,10 +580,10 @@ struct ParamTraits<POINT> { template <> struct ParamTraits<FilePath> { typedef FilePath param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { ParamTraits<FilePath::StringType>::Write(m, p.value()); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { FilePath::StringType value; if (!ParamTraits<FilePath::StringType>::Read(m, iter, &value)) return false; @@ -625,44 +598,44 @@ struct ParamTraits<FilePath> { template <> struct ParamTraits<gfx::Point> { typedef gfx::Point param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static void Write(IPC::Message* m, const param_type& p); + static bool Read(const IPC::Message* m, void** iter, param_type* r); static void Log(const param_type& p, std::wstring* l); }; template <> struct ParamTraits<gfx::Rect> { typedef gfx::Rect param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static void Write(IPC::Message* m, const param_type& p); + static bool Read(const IPC::Message* m, void** iter, param_type* r); static void Log(const param_type& p, std::wstring* l); }; template <> struct ParamTraits<gfx::Size> { typedef gfx::Size param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static void Write(IPC::Message* m, const param_type& p); + static bool Read(const IPC::Message* m, void** iter, param_type* r); static void Log(const param_type& p, std::wstring* l); }; template<> struct ParamTraits<ThumbnailScore> { typedef ThumbnailScore param_type; - static void Write(Message* m, const param_type& p) { - IPC::ParamTraits<double>::Write(m, p.boring_score); - IPC::ParamTraits<bool>::Write(m, p.good_clipping); - IPC::ParamTraits<bool>::Write(m, p.at_top); - IPC::ParamTraits<base::Time>::Write(m, p.time_at_snapshot); + static void Write(IPC::Message* m, const param_type& p) { + ParamTraits<double>::Write(m, p.boring_score); + ParamTraits<bool>::Write(m, p.good_clipping); + ParamTraits<bool>::Write(m, p.at_top); + ParamTraits<base::Time>::Write(m, p.time_at_snapshot); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { double boring_score; bool good_clipping, at_top; base::Time time_at_snapshot; - if (!IPC::ParamTraits<double>::Read(m, iter, &boring_score) || - !IPC::ParamTraits<bool>::Read(m, iter, &good_clipping) || - !IPC::ParamTraits<bool>::Read(m, iter, &at_top) || - !IPC::ParamTraits<base::Time>::Read(m, iter, &time_at_snapshot)) + if (!ParamTraits<double>::Read(m, iter, &boring_score) || + !ParamTraits<bool>::Read(m, iter, &good_clipping) || + !ParamTraits<bool>::Read(m, iter, &at_top) || + !ParamTraits<base::Time>::Read(m, iter, &time_at_snapshot)) return false; r->boring_score = boring_score; @@ -680,10 +653,10 @@ struct ParamTraits<ThumbnailScore> { template <> struct ParamTraits<WindowOpenDisposition> { typedef WindowOpenDisposition param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { m->WriteInt(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { int temp; bool res = m->ReadInt(iter, &temp); *r = static_cast<WindowOpenDisposition>(temp); @@ -697,10 +670,10 @@ struct ParamTraits<WindowOpenDisposition> { template <> struct ParamTraits<ConsoleMessageLevel> { typedef ConsoleMessageLevel param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { m->WriteInt(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { int temp; bool res = m->ReadInt(iter, &temp); *r = static_cast<ConsoleMessageLevel>(temp); @@ -714,13 +687,13 @@ struct ParamTraits<ConsoleMessageLevel> { template <> struct ParamTraits<CacheManager::ResourceTypeStat> { typedef CacheManager::ResourceTypeStat param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, p.count); WriteParam(m, p.size); WriteParam(m, p.live_size); WriteParam(m, p.decoded_size); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { bool result = ReadParam(m, iter, &r->count) && ReadParam(m, iter, &r->size) && @@ -737,14 +710,14 @@ struct ParamTraits<CacheManager::ResourceTypeStat> { template <> struct ParamTraits<CacheManager::ResourceTypeStats> { typedef CacheManager::ResourceTypeStats param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, p.images); WriteParam(m, p.css_stylesheets); WriteParam(m, p.scripts); WriteParam(m, p.xsl_stylesheets); WriteParam(m, p.fonts); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { bool result = ReadParam(m, iter, &r->images) && ReadParam(m, iter, &r->css_stylesheets) && @@ -768,10 +741,10 @@ struct ParamTraits<CacheManager::ResourceTypeStats> { template <> struct ParamTraits<XFORM> { typedef XFORM param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { m->WriteData(reinterpret_cast<const char*>(&p), sizeof(XFORM)); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { const char *data; int data_size = 0; bool result = m->ReadData(iter, &data, &data_size); @@ -793,10 +766,10 @@ struct ParamTraits<XFORM> { template <> struct ParamTraits<WebCursor> { typedef WebCursor param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { p.Serialize(m); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { return r->Deserialize(m, iter); } static void Log(const param_type& p, std::wstring* l) { @@ -804,6 +777,8 @@ struct ParamTraits<WebCursor> { } }; +namespace IPC { + struct LogData { std::wstring channel; uint16 type; @@ -816,10 +791,12 @@ struct LogData { std::wstring params; }; +} + template <> -struct ParamTraits<LogData> { - typedef LogData param_type; - static void Write(Message* m, const param_type& p) { +struct ParamTraits<IPC::LogData> { + typedef IPC::LogData param_type; + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, p.channel); WriteParam(m, static_cast<int>(p.type)); WriteParam(m, p.flags); @@ -828,7 +805,7 @@ struct ParamTraits<LogData> { WriteParam(m, p.dispatch); WriteParam(m, p.params); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { int type; bool result = ReadParam(m, iter, &r->channel) && @@ -849,9 +826,9 @@ struct ParamTraits<LogData> { template <> struct ParamTraits<Tuple0> { typedef Tuple0 param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { return true; } static void Log(const param_type& p, std::wstring* l) { @@ -861,10 +838,10 @@ struct ParamTraits<Tuple0> { template <class A> struct ParamTraits< Tuple1<A> > { typedef Tuple1<A> param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, p.a); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { return ReadParam(m, iter, &r->a); } static void Log(const param_type& p, std::wstring* l) { @@ -875,11 +852,11 @@ struct ParamTraits< Tuple1<A> > { template <class A, class B> struct ParamTraits< Tuple2<A, B> > { typedef Tuple2<A, B> param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, p.a); WriteParam(m, p.b); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { return (ReadParam(m, iter, &r->a) && ReadParam(m, iter, &r->b)); } @@ -893,12 +870,12 @@ struct ParamTraits< Tuple2<A, B> > { template <class A, class B, class C> struct ParamTraits< Tuple3<A, B, C> > { typedef Tuple3<A, B, C> param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, p.a); WriteParam(m, p.b); WriteParam(m, p.c); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { return (ReadParam(m, iter, &r->a) && ReadParam(m, iter, &r->b) && ReadParam(m, iter, &r->c)); @@ -915,13 +892,13 @@ struct ParamTraits< Tuple3<A, B, C> > { template <class A, class B, class C, class D> struct ParamTraits< Tuple4<A, B, C, D> > { typedef Tuple4<A, B, C, D> param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, p.a); WriteParam(m, p.b); WriteParam(m, p.c); WriteParam(m, p.d); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { return (ReadParam(m, iter, &r->a) && ReadParam(m, iter, &r->b) && ReadParam(m, iter, &r->c) && @@ -941,14 +918,14 @@ struct ParamTraits< Tuple4<A, B, C, D> > { template <class A, class B, class C, class D, class E> struct ParamTraits< Tuple5<A, B, C, D, E> > { typedef Tuple5<A, B, C, D, E> param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, p.a); WriteParam(m, p.b); WriteParam(m, p.c); WriteParam(m, p.d); WriteParam(m, p.e); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { return (ReadParam(m, iter, &r->a) && ReadParam(m, iter, &r->b) && ReadParam(m, iter, &r->c) && @@ -971,7 +948,7 @@ struct ParamTraits< Tuple5<A, B, C, D, E> > { template <class A, class B, class C, class D, class E, class F> struct ParamTraits< Tuple6<A, B, C, D, E, F> > { typedef Tuple6<A, B, C, D, E, F> param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, p.a); WriteParam(m, p.b); WriteParam(m, p.c); @@ -979,7 +956,7 @@ struct ParamTraits< Tuple6<A, B, C, D, E, F> > { WriteParam(m, p.e); WriteParam(m, p.f); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { return (ReadParam(m, iter, &r->a) && ReadParam(m, iter, &r->b) && ReadParam(m, iter, &r->c) && @@ -1005,11 +982,77 @@ struct ParamTraits< Tuple6<A, B, C, D, E, F> > { template <> struct ParamTraits<webkit_glue::WebApplicationInfo> { typedef webkit_glue::WebApplicationInfo param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); + static void Write(IPC::Message* m, const param_type& p); + static bool Read(const IPC::Message* m, void** iter, param_type* r); static void Log(const param_type& p, std::wstring* l); }; +// Traits for ViewMsg_FindInPageMsg_Request structure to pack/unpack. +template <> +struct ParamTraits<FindInPageRequest> { + typedef FindInPageRequest param_type; + static void Write(IPC::Message* m, const param_type& p) { + WriteParam(m, p.request_id); + WriteParam(m, p.search_string); + WriteParam(m, p.forward); + WriteParam(m, p.match_case); + WriteParam(m, p.find_next); + } + static bool Read(const IPC::Message* m, void** iter, param_type* p) { + return + ReadParam(m, iter, &p->request_id) && + ReadParam(m, iter, &p->search_string) && + ReadParam(m, iter, &p->forward) && + ReadParam(m, iter, &p->match_case) && + ReadParam(m, iter, &p->find_next); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"<FindInPageRequest>"); + } +}; + +namespace IPC { + +//----------------------------------------------------------------------------- +// An iterator class for reading the fields contained within a Message. + +class MessageIterator { + public: + explicit MessageIterator(const Message& m) : msg_(m), iter_(NULL) { + } + int NextInt() const { + int val; + if (!msg_.ReadInt(&iter_, &val)) + NOTREACHED(); + return val; + } + intptr_t NextIntPtr() const { + intptr_t val; + if (!msg_.ReadIntPtr(&iter_, &val)) + NOTREACHED(); + return val; + } + const std::string NextString() const { + std::string val; + if (!msg_.ReadString(&iter_, &val)) + NOTREACHED(); + return val; + } + const std::wstring NextWString() const { + std::wstring val; + if (!msg_.ReadWString(&iter_, &val)) + NOTREACHED(); + return val; + } + const void NextData(const char** data, int* length) const { + if (!msg_.ReadData(&iter_, data, length)) { + NOTREACHED(); + } + } + private: + const Message& msg_; + mutable void* iter_; +}; //----------------------------------------------------------------------------- // Generic message subclasses @@ -1025,7 +1068,7 @@ class MessageWithTuple : public Message { WriteParam(this, p); } - static bool Read(const Message* msg, Param* p) { + static bool Read(const IPC::Message* msg, Param* p) { void* iter = NULL; bool rv = ReadParam(msg, &iter, p); DCHECK(rv) << "Error deserializing message " << msg->type(); @@ -1034,7 +1077,7 @@ class MessageWithTuple : public Message { // Generic dispatcher. Should cover most cases. template<class T, class Method> - static bool Dispatch(const Message* msg, T* obj, Method func) { + static bool Dispatch(const IPC::Message* msg, T* obj, Method func) { Param p; if (Read(msg, &p)) { DispatchToMethod(obj, func, p); @@ -1047,7 +1090,7 @@ class MessageWithTuple : public Message { // needs the message as well. They assume that "Param" is a type of Tuple // (except the one arg case, as there is no Tuple1). template<class T, typename TA> - static bool Dispatch(const Message* msg, T* obj, + static bool Dispatch(const IPC::Message* msg, T* obj, void (T::*func)(const Message&, TA)) { Param p; if (Read(msg, &p)) { @@ -1058,7 +1101,7 @@ class MessageWithTuple : public Message { } template<class T, typename TA, typename TB> - static bool Dispatch(const Message* msg, T* obj, + static bool Dispatch(const IPC::Message* msg, T* obj, void (T::*func)(const Message&, TA, TB)) { Param p; if (Read(msg, &p)) { @@ -1069,7 +1112,7 @@ class MessageWithTuple : public Message { } template<class T, typename TA, typename TB, typename TC> - static bool Dispatch(const Message* msg, T* obj, + static bool Dispatch(const IPC::Message* msg, T* obj, void (T::*func)(const Message&, TA, TB, TC)) { Param p; if (Read(msg, &p)) { @@ -1080,7 +1123,7 @@ class MessageWithTuple : public Message { } template<class T, typename TA, typename TB, typename TC, typename TD> - static bool Dispatch(const Message* msg, T* obj, + static bool Dispatch(const IPC::Message* msg, T* obj, void (T::*func)(const Message&, TA, TB, TC, TD)) { Param p; if (Read(msg, &p)) { @@ -1092,7 +1135,7 @@ class MessageWithTuple : public Message { template<class T, typename TA, typename TB, typename TC, typename TD, typename TE> - static bool Dispatch(const Message* msg, T* obj, + static bool Dispatch(const IPC::Message* msg, T* obj, void (T::*func)(const Message&, TA, TB, TC, TD, TE)) { Param p; if (Read(msg, &p)) { @@ -1102,11 +1145,59 @@ class MessageWithTuple : public Message { return false; } - static void Log(const Message* msg, std::wstring* l) { + static void Log(const IPC::Message* msg, std::wstring* l) { Param p; if (Read(msg, &p)) LogParam(p, l); } + + // Functions used to do manual unpacking. Only used by the automation code, + // these should go away once that code uses SyncChannel. + template<typename TA, typename TB> + static bool Read(const IPC::Message* msg, TA* a, TB* b) { + ParamType params; + if (!Read(msg, ¶ms)) + return false; + *a = params.a; + *b = params.b; + return true; + } + + template<typename TA, typename TB, typename TC> + static bool Read(const IPC::Message* msg, TA* a, TB* b, TC* c) { + ParamType params; + if (!Read(msg, ¶ms)) + return false; + *a = params.a; + *b = params.b; + *c = params.c; + return true; + } + + template<typename TA, typename TB, typename TC, typename TD> + static bool Read(const IPC::Message* msg, TA* a, TB* b, TC* c, TD* d) { + ParamType params; + if (!Read(msg, ¶ms)) + return false; + *a = params.a; + *b = params.b; + *c = params.c; + *d = params.d; + return true; + } + + template<typename TA, typename TB, typename TC, typename TD, typename TE> + static bool Read(const IPC::Message* msg, TA* a, TB* b, TC* c, TD* d, TE* e) { + ParamType params; + if (!Read(msg, ¶ms)) + return false; + *a = params.a; + *b = params.b; + *c = params.c; + *d = params.d; + *e = params.e; + return true; + } }; // This class assumes that its template argument is a RefTuple (a Tuple with @@ -1138,7 +1229,7 @@ class MessageWithReply : public SyncMessage { WriteParam(this, send); } - static void Log(const Message* msg, std::wstring* l) { + static void Log(const IPC::Message* msg, std::wstring* l) { if (msg->is_sync()) { SendParam p; void* iter = SyncMessage::GetDataIterator(msg); @@ -1163,7 +1254,7 @@ class MessageWithReply : public SyncMessage { } template<class T, class Method> - static bool Dispatch(const Message* msg, T* obj, Method func) { + static bool Dispatch(const IPC::Message* msg, T* obj, Method func) { SendParam send_params; void* iter = GetDataIterator(msg); Message* reply = GenerateReply(msg); @@ -1191,7 +1282,7 @@ class MessageWithReply : public SyncMessage { } template<class T, class Method> - static bool DispatchDelayReply(const Message* msg, T* obj, Method func) { + static bool DispatchDelayReply(const IPC::Message* msg, T* obj, Method func) { SendParam send_params; void* iter = GetDataIterator(msg); Message* reply = GenerateReply(msg); @@ -1252,32 +1343,6 @@ class MessageWithReply : public SyncMessage { } }; -// Traits for ViewMsg_FindInPageMsg_Request structure to pack/unpack. -template <> -struct ParamTraits<FindInPageRequest> { - typedef FindInPageRequest param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.request_id); - WriteParam(m, p.search_string); - WriteParam(m, p.forward); - WriteParam(m, p.match_case); - WriteParam(m, p.find_next); - } - static bool Read(const Message* m, void** iter, param_type* p) { - return - ReadParam(m, iter, &p->request_id) && - ReadParam(m, iter, &p->search_string) && - ReadParam(m, iter, &p->forward) && - ReadParam(m, iter, &p->match_case) && - ReadParam(m, iter, &p->find_next); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"<FindInPageRequest>"); - } -}; - -//----------------------------------------------------------------------------- - } // namespace IPC #endif // CHROME_COMMON_IPC_MESSAGE_UTILS_H_ diff --git a/chrome/common/ipc_sync_channel_unittest.cc b/chrome/common/ipc_sync_channel_unittest.cc index 53d3f2a..2ccbd96 100644 --- a/chrome/common/ipc_sync_channel_unittest.cc +++ b/chrome/common/ipc_sync_channel_unittest.cc @@ -20,12 +20,9 @@ #include "chrome/common/stl_util-inl.h" #include "testing/gtest/include/gtest/gtest.h" -#define IPC_MESSAGE_MACROS_ENUMS -#include "chrome/common/ipc_sync_channel_unittest.h" -// define the classes -#define IPC_MESSAGE_MACROS_CLASSES -#include "chrome/common/ipc_sync_channel_unittest.h" +#define MESSAGES_INTERNAL_FILE "chrome/common/ipc_sync_message_unittest.h" +#include "chrome/common/ipc_message_macros.h" using namespace IPC; using base::WaitableEvent; diff --git a/chrome/common/ipc_sync_channel_unittest.h b/chrome/common/ipc_sync_channel_unittest.h deleted file mode 100644 index c4d2354..0000000 --- a/chrome/common/ipc_sync_channel_unittest.h +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2006-2008 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/ipc_message_macros.h" - -// Messages used for IPC::SyncChannel unit test -IPC_BEGIN_MESSAGES(SyncChannelTest, 9) - IPC_SYNC_MESSAGE_CONTROL0_0(SyncChannelTestMsg_NoArgs) - - IPC_SYNC_MESSAGE_CONTROL0_1(SyncChannelTestMsg_AnswerToLife, - int /* answer */) - - IPC_SYNC_MESSAGE_CONTROL1_1(SyncChannelTestMsg_Double, - int /* in */, - int /* out */) - -IPC_END_MESSAGES(SyncChannelTest) - diff --git a/chrome/common/ipc_sync_message_unittest.cc b/chrome/common/ipc_sync_message_unittest.cc index ae44acb..6508eaf 100644 --- a/chrome/common/ipc_sync_message_unittest.cc +++ b/chrome/common/ipc_sync_message_unittest.cc @@ -14,13 +14,9 @@ #include "base/logging.h" #include "testing/gtest/include/gtest/gtest.h" -#define IPC_MESSAGE_MACROS_ENUMS -#include "chrome/common/ipc_sync_message_unittest.h" - -// define the classes -#define IPC_MESSAGE_MACROS_CLASSES -#include "chrome/common/ipc_sync_message_unittest.h" +#define MESSAGES_INTERNAL_FILE "chrome/common/ipc_sync_message_unittest.h" +#include "chrome/common/ipc_message_macros.h" static IPC::Message* g_reply; diff --git a/chrome/common/ipc_sync_message_unittest.h b/chrome/common/ipc_sync_message_unittest.h index 8393533..3b32c10 100644 --- a/chrome/common/ipc_sync_message_unittest.h +++ b/chrome/common/ipc_sync_message_unittest.h @@ -4,7 +4,16 @@ #include "chrome/common/ipc_message_macros.h" -IPC_BEGIN_MESSAGES(TestMsg, 8) +IPC_BEGIN_MESSAGES(Test) + IPC_SYNC_MESSAGE_CONTROL0_0(SyncChannelTestMsg_NoArgs) + + IPC_SYNC_MESSAGE_CONTROL0_1(SyncChannelTestMsg_AnswerToLife, + int /* answer */) + + IPC_SYNC_MESSAGE_CONTROL1_1(SyncChannelTestMsg_Double, + int /* in */, + int /* out */) + // out1 is false IPC_SYNC_MESSAGE_CONTROL0_1(Msg_C_0_1, bool) diff --git a/chrome/common/plugin_messages.cc b/chrome/common/plugin_messages.cc deleted file mode 100644 index cd5b00a..0000000 --- a/chrome/common/plugin_messages.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2006-2008 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/ipc_message.h" - -#ifdef IPC_MESSAGE_LOG_ENABLED - -#define IPC_MESSAGE_MACROS_LOG_ENABLED - -#endif // IPC_MESSAGE_LOG_ENABLED - -#include "chrome/common/plugin_messages.h" - -void PluginMessagesInit() { -#ifdef IPC_MESSAGE_LOG_ENABLED - IPC::RegisterMessageLogger(PluginProcessStart, PluginProcessMsgLog); - IPC::RegisterMessageLogger(PluginProcessHostStart, PluginProcessHostMsgLog); - IPC::RegisterMessageLogger(PluginStart, PluginMsgLog); - IPC::RegisterMessageLogger(PluginHostStart, PluginHostMsgLog); - IPC::RegisterMessageLogger(NPObjectStart, NPObjectMsgLog); -#endif -} diff --git a/chrome/common/plugin_messages.h b/chrome/common/plugin_messages.h index 025acc2..793dde3 100644 --- a/chrome/common/plugin_messages.h +++ b/chrome/common/plugin_messages.h @@ -15,14 +15,11 @@ #include "base/gfx/rect.h" #include "base/basictypes.h" -#include "chrome/common/ipc_message.h" #include "chrome/common/ipc_message_utils.h" #include "googleurl/src/gurl.h" #include "third_party/npapi/bindings/npapi.h" #include "webkit/glue/npruntime_util.h" -void PluginMessagesInit(); - // Name prefix of the event handle when a message box is displayed. #define kMessageBoxEventPrefix L"message_box_active" @@ -38,95 +35,11 @@ struct PluginMsg_Init_Params { HANDLE modal_dialog_event; }; -struct PluginHostMsg_URLRequest_Params { - std::string method; - bool is_javascript_url; - std::string target; - std::vector<char> buffer; - bool is_file_data; - bool notify; - std::string url; - HANDLE notify_data; - bool popups_allowed; -}; - -struct PluginMsg_URLRequestReply_Params { - int resource_id; - std::string url; - bool notify_needed; - HANDLE notify_data; - HANDLE stream; -}; - -struct PluginMsg_PrintResponse_Params { - HANDLE shared_memory; - size_t size; -}; - -struct PluginMsg_DidReceiveResponseParams { - int id; - std::string mime_type; - std::string headers; - uint32 expected_length; - uint32 last_modified; - bool request_is_seekable; -}; - -struct NPIdentifier_Param { - NPIdentifier identifier; -}; - -enum NPVariant_ParamEnum { - NPVARIANT_PARAM_VOID, - NPVARIANT_PARAM_NULL, - NPVARIANT_PARAM_BOOL, - NPVARIANT_PARAM_INT, - NPVARIANT_PARAM_DOUBLE, - NPVARIANT_PARAM_STRING, - // Used when when the NPObject is running in the caller's process, so we - // create an NPObjectProxy in the other process. - NPVARIANT_PARAM_OBJECT_ROUTING_ID, - // Used when the NPObject we're sending is running in the callee's process - // (i.e. we have an NPObjectProxy for it). In that case we want the callee - // to just use the raw pointer. - NPVARIANT_PARAM_OBJECT_POINTER, -}; - -struct NPVariant_Param { - NPVariant_ParamEnum type; - bool bool_value; - int int_value; - double double_value; - std::string string_value; - int npobject_routing_id; - void* npobject_pointer; -}; - - -#define IPC_MESSAGE_MACROS_ENUMS -#include "chrome/common/plugin_messages_internal.h" - -#ifdef IPC_MESSAGE_MACROS_LOG_ENABLED -# undef IPC_MESSAGE_MACROS_LOG -# define IPC_MESSAGE_MACROS_CLASSES - -# include "chrome/common/plugin_messages_internal.h" -# define IPC_MESSAGE_MACROS_LOG -# undef IPC_MESSAGE_MACROS_CLASSES - -# include "chrome/common/plugin_messages_internal.h" -#else -# define IPC_MESSAGE_MACROS_CLASSES -# include "chrome/common/plugin_messages_internal.h" -#endif - -namespace IPC { - // Traits for PluginMsg_Init_Params structure to pack/unpack. template <> struct ParamTraits<PluginMsg_Init_Params> { typedef PluginMsg_Init_Params param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, p.containing_window); WriteParam(m, p.url); DCHECK(p.arg_names.size() == p.arg_values.size()); @@ -135,7 +48,7 @@ struct ParamTraits<PluginMsg_Init_Params> { WriteParam(m, p.load_manually); WriteParam(m, p.modal_dialog_event); } - static bool Read(const Message* m, void** iter, param_type* p) { + static bool Read(const IPC::Message* m, void** iter, param_type* p) { return ReadParam(m, iter, &p->containing_window) && ReadParam(m, iter, &p->url) && ReadParam(m, iter, &p->arg_names) && @@ -160,10 +73,23 @@ struct ParamTraits<PluginMsg_Init_Params> { } }; + +struct PluginHostMsg_URLRequest_Params { + std::string method; + bool is_javascript_url; + std::string target; + std::vector<char> buffer; + bool is_file_data; + bool notify; + std::string url; + HANDLE notify_data; + bool popups_allowed; +}; + template <> struct ParamTraits<PluginHostMsg_URLRequest_Params> { typedef PluginHostMsg_URLRequest_Params param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, p.method); WriteParam(m, p.is_javascript_url); WriteParam(m, p.target); @@ -174,7 +100,7 @@ struct ParamTraits<PluginHostMsg_URLRequest_Params> { WriteParam(m, p.notify_data); WriteParam(m, p.popups_allowed); } - static bool Read(const Message* m, void** iter, param_type* p) { + static bool Read(const IPC::Message* m, void** iter, param_type* p) { return ReadParam(m, iter, &p->method) && ReadParam(m, iter, &p->is_javascript_url) && @@ -209,17 +135,26 @@ struct ParamTraits<PluginHostMsg_URLRequest_Params> { } }; + +struct PluginMsg_URLRequestReply_Params { + int resource_id; + std::string url; + bool notify_needed; + HANDLE notify_data; + HANDLE stream; +}; + template <> struct ParamTraits<PluginMsg_URLRequestReply_Params> { typedef PluginMsg_URLRequestReply_Params param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, p.resource_id); WriteParam(m, p.url); WriteParam(m, p.notify_needed); WriteParam(m, p.notify_data); WriteParam(m, p.stream); } - static bool Read(const Message* m, void** iter, param_type* p) { + static bool Read(const IPC::Message* m, void** iter, param_type* p) { return ReadParam(m, iter, &p->resource_id) && ReadParam(m, iter, &p->url) && @@ -242,14 +177,20 @@ struct ParamTraits<PluginMsg_URLRequestReply_Params> { } }; + +struct PluginMsg_PrintResponse_Params { + HANDLE shared_memory; + size_t size; +}; + template <> struct ParamTraits<PluginMsg_PrintResponse_Params> { typedef PluginMsg_PrintResponse_Params param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, p.shared_memory); WriteParam(m, p.size); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { return ReadParam(m, iter, &r->shared_memory) && ReadParam(m, iter, &r->size); @@ -258,10 +199,20 @@ struct ParamTraits<PluginMsg_PrintResponse_Params> { } }; + +struct PluginMsg_DidReceiveResponseParams { + int id; + std::string mime_type; + std::string headers; + uint32 expected_length; + uint32 last_modified; + bool request_is_seekable; +}; + template <> struct ParamTraits<PluginMsg_DidReceiveResponseParams> { typedef PluginMsg_DidReceiveResponseParams param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, p.id); WriteParam(m, p.mime_type); WriteParam(m, p.headers); @@ -269,7 +220,7 @@ struct ParamTraits<PluginMsg_DidReceiveResponseParams> { WriteParam(m, p.last_modified); WriteParam(m, p.request_is_seekable); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { return ReadParam(m, iter, &r->id) && ReadParam(m, iter, &r->mime_type) && @@ -295,97 +246,18 @@ struct ParamTraits<PluginMsg_DidReceiveResponseParams> { } }; -template <> -struct ParamTraits<NPEvent> { - typedef NPEvent param_type; - static void Write(Message* m, const param_type& p) { - m->WriteData(reinterpret_cast<const char*>(&p), sizeof(NPEvent)); - } - static bool Read(const Message* m, void** iter, param_type* r) { - const char *data; - int data_size = 0; - bool result = m->ReadData(iter, &data, &data_size); - if (!result || data_size != sizeof(NPEvent)) { - NOTREACHED(); - return false; - } - memcpy(r, data, sizeof(NPEvent)); - return true; - } - static void Log(const param_type& p, std::wstring* l) { - std::wstring event, wparam, lparam; - lparam = StringPrintf(L"(%d, %d)", LOWORD(p.lParam), HIWORD(p.lParam)); - switch(p.event) { - case WM_KEYDOWN: - event = L"WM_KEYDOWN"; - wparam = StringPrintf(L"%d", p.wParam); - lparam = StringPrintf(L"%d", p.lParam); - break; - case WM_KEYUP: - event = L"WM_KEYDOWN"; - wparam = StringPrintf(L"%d", p.wParam); - lparam = StringPrintf(L"%x", p.lParam); - break; - case WM_MOUSEMOVE: - event = L"WM_MOUSEMOVE"; - if (p.wParam & MK_LBUTTON) { - wparam = L"MK_LBUTTON"; - } else if (p.wParam & MK_MBUTTON) { - wparam = L"MK_MBUTTON"; - } else if (p.wParam & MK_RBUTTON) { - wparam = L"MK_RBUTTON"; - } - break; - case WM_LBUTTONDOWN: - event = L"WM_LBUTTONDOWN"; - break; - case WM_MBUTTONDOWN: - event = L"WM_MBUTTONDOWN"; - break; - case WM_RBUTTONDOWN: - event = L"WM_RBUTTONDOWN"; - break; - case WM_LBUTTONUP: - event = L"WM_LBUTTONUP"; - break; - case WM_MBUTTONUP: - event = L"WM_MBUTTONUP"; - break; - case WM_RBUTTONUP: - event = L"WM_RBUTTONUP"; - break; - } - - if (p.wParam & MK_CONTROL) { - if (!wparam.empty()) - wparam += L" "; - wparam += L"MK_CONTROL"; - } - - if (p.wParam & MK_SHIFT) { - if (!wparam.empty()) - wparam += L" "; - wparam += L"MK_SHIFT"; - } - - l->append(L"("); - LogParam(event, l); - l->append(L", "); - LogParam(wparam, l); - l->append(L", "); - LogParam(lparam, l); - l->append(L")"); - } +struct NPIdentifier_Param { + NPIdentifier identifier; }; template <> struct ParamTraits<NPIdentifier_Param> { typedef NPIdentifier_Param param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { webkit_glue::SerializeNPIdentifier(p.identifier, m); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { return webkit_glue::DeserializeNPIdentifier(*m, iter, &r->identifier); } static void Log(const param_type& p, std::wstring* l) { @@ -399,10 +271,37 @@ struct ParamTraits<NPIdentifier_Param> { } }; + +enum NPVariant_ParamEnum { + NPVARIANT_PARAM_VOID, + NPVARIANT_PARAM_NULL, + NPVARIANT_PARAM_BOOL, + NPVARIANT_PARAM_INT, + NPVARIANT_PARAM_DOUBLE, + NPVARIANT_PARAM_STRING, + // Used when when the NPObject is running in the caller's process, so we + // create an NPObjectProxy in the other process. + NPVARIANT_PARAM_OBJECT_ROUTING_ID, + // Used when the NPObject we're sending is running in the callee's process + // (i.e. we have an NPObjectProxy for it). In that case we want the callee + // to just use the raw pointer. + NPVARIANT_PARAM_OBJECT_POINTER, +}; + +struct NPVariant_Param { + NPVariant_ParamEnum type; + bool bool_value; + int int_value; + double double_value; + std::string string_value; + int npobject_routing_id; + void* npobject_pointer; +}; + template <> struct ParamTraits<NPVariant_Param> { typedef NPVariant_Param param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, static_cast<int>(p.type)); if (p.type == NPVARIANT_PARAM_BOOL) { WriteParam(m, p.bool_value); @@ -425,7 +324,7 @@ struct ParamTraits<NPVariant_Param> { DCHECK(p.type == NPVARIANT_PARAM_VOID || p.type == NPVARIANT_PARAM_NULL); } } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { int type; if (!ReadParam(m, iter, &type)) return false; @@ -473,7 +372,94 @@ struct ParamTraits<NPVariant_Param> { } }; -} // namespace IPC + +template <> +struct ParamTraits<NPEvent> { + typedef NPEvent param_type; + static void Write(IPC::Message* m, const param_type& p) { + m->WriteData(reinterpret_cast<const char*>(&p), sizeof(NPEvent)); + } + static bool Read(const IPC::Message* m, void** iter, param_type* r) { + const char *data; + int data_size = 0; + bool result = m->ReadData(iter, &data, &data_size); + if (!result || data_size != sizeof(NPEvent)) { + NOTREACHED(); + return false; + } + + memcpy(r, data, sizeof(NPEvent)); + return true; + } + static void Log(const param_type& p, std::wstring* l) { + std::wstring event, wparam, lparam; + lparam = StringPrintf(L"(%d, %d)", LOWORD(p.lParam), HIWORD(p.lParam)); + switch(p.event) { + case WM_KEYDOWN: + event = L"WM_KEYDOWN"; + wparam = StringPrintf(L"%d", p.wParam); + lparam = StringPrintf(L"%d", p.lParam); + break; + case WM_KEYUP: + event = L"WM_KEYDOWN"; + wparam = StringPrintf(L"%d", p.wParam); + lparam = StringPrintf(L"%x", p.lParam); + break; + case WM_MOUSEMOVE: + event = L"WM_MOUSEMOVE"; + if (p.wParam & MK_LBUTTON) { + wparam = L"MK_LBUTTON"; + } else if (p.wParam & MK_MBUTTON) { + wparam = L"MK_MBUTTON"; + } else if (p.wParam & MK_RBUTTON) { + wparam = L"MK_RBUTTON"; + } + break; + case WM_LBUTTONDOWN: + event = L"WM_LBUTTONDOWN"; + break; + case WM_MBUTTONDOWN: + event = L"WM_MBUTTONDOWN"; + break; + case WM_RBUTTONDOWN: + event = L"WM_RBUTTONDOWN"; + break; + case WM_LBUTTONUP: + event = L"WM_LBUTTONUP"; + break; + case WM_MBUTTONUP: + event = L"WM_MBUTTONUP"; + break; + case WM_RBUTTONUP: + event = L"WM_RBUTTONUP"; + break; + } + + if (p.wParam & MK_CONTROL) { + if (!wparam.empty()) + wparam += L" "; + wparam += L"MK_CONTROL"; + } + + if (p.wParam & MK_SHIFT) { + if (!wparam.empty()) + wparam += L" "; + wparam += L"MK_SHIFT"; + } + + l->append(L"("); + LogParam(event, l); + l->append(L", "); + LogParam(wparam, l); + l->append(L", "); + LogParam(lparam, l); + l->append(L")"); + } +}; + + +#define MESSAGES_INTERNAL_FILE "chrome/common/plugin_messages_internal.h" +#include "chrome/common/ipc_message_macros.h" #endif // CHROME_COMMON_PLUGIN_MESSAGES_H__ diff --git a/chrome/common/plugin_messages_internal.h b/chrome/common/plugin_messages_internal.h index 85093d5..d8561d0 100644 --- a/chrome/common/plugin_messages_internal.h +++ b/chrome/common/plugin_messages_internal.h @@ -9,7 +9,7 @@ //----------------------------------------------------------------------------- // PluginProcess messages // These are messages sent from the browser to the plugin process. -IPC_BEGIN_MESSAGES(PluginProcess, 3) +IPC_BEGIN_MESSAGES(PluginProcess) // Tells the plugin process to create a new channel for communication with a // renderer. The channel name is returned in a // PluginProcessHostMsg_ChannelCreated message. @@ -35,7 +35,7 @@ IPC_END_MESSAGES(PluginProcess) //----------------------------------------------------------------------------- // PluginProcessHost messages // These are messages sent from the plugin process to the browser process. -IPC_BEGIN_MESSAGES(PluginProcessHost, 4) +IPC_BEGIN_MESSAGES(PluginProcessHost) // Response to a PluginProcessMsg_CreateChannel message. IPC_MESSAGE_CONTROL2(PluginProcessHostMsg_ChannelCreated, int /* process_id */, @@ -92,7 +92,7 @@ IPC_END_MESSAGES(PluginProcessHost) //----------------------------------------------------------------------------- // Plugin messages // These are messages sent from the renderer process to the plugin process. -IPC_BEGIN_MESSAGES(Plugin, 5) +IPC_BEGIN_MESSAGES(Plugin) // Tells the plugin process to create a new plugin instance with the given // id. A corresponding WebPluginDelegateStub is created which hosts the // WebPluginDelegateImpl. @@ -202,7 +202,7 @@ IPC_END_MESSAGES(Plugin) // PluginHost messages // These are messages sent from the plugin process to the renderer process. // They all map to the corresponding WebPlugin methods. -IPC_BEGIN_MESSAGES(PluginHost, 6) +IPC_BEGIN_MESSAGES(PluginHost) // Sends the plugin window information to the renderer. // The window parameter is a handle to the window if the plugin is a windowed // plugin. It is NULL for windowless plugins. @@ -274,7 +274,7 @@ IPC_END_MESSAGES(PluginHost) // NPObject messages // These are messages used to marshall NPObjects. They are sent both from the // plugin to the renderer and from the renderer to the plugin. -IPC_BEGIN_MESSAGES(NPObject, 7) +IPC_BEGIN_MESSAGES(NPObject) IPC_SYNC_MESSAGE_ROUTED0_0(NPObjectMsg_Release) IPC_SYNC_MESSAGE_ROUTED1_1(NPObjectMsg_HasMethod, diff --git a/chrome/common/render_messages.cc b/chrome/common/render_messages.cc deleted file mode 100644 index 55f21552..0000000 --- a/chrome/common/render_messages.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) 2006-2008 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/ipc_message.h" - -#ifdef IPC_MESSAGE_LOG_ENABLED - -// Preprocessor magic: render_messages.h defines the enums and debug string -// functions if this define is set. -#define IPC_MESSAGE_MACROS_LOG_ENABLED - -#endif // IPC_MESSAGE_LOG_ENABLED - -#include "chrome/common/render_messages.h" - -void RenderMessagesInit() { -#ifdef IPC_MESSAGE_LOG_ENABLED - IPC::RegisterMessageLogger(ViewStart, ViewMsgLog); - IPC::RegisterMessageLogger(ViewHostStart, ViewHostMsgLog); -#endif -} diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index 95c7e6d..c33d63e 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -15,7 +15,6 @@ #include "base/shared_memory.h" #include "chrome/common/bitmap_wire_data.h" #include "chrome/common/filter_policy.h" -#include "chrome/common/ipc_message.h" #include "chrome/common/ipc_message_utils.h" #include "chrome/common/modal_dialog_event.h" #include "chrome/common/page_transition_types.h" @@ -31,6 +30,7 @@ #include "webkit/glue/resource_loader_bridge.h" #include "webkit/glue/screen_info.h" #include "webkit/glue/webdropdata.h" +#include "webkit/glue/webinputevent.h" #include "webkit/glue/webplugin.h" #include "webkit/glue/webpreferences.h" #include "webkit/glue/webview_delegate.h" @@ -66,8 +66,43 @@ struct ViewMsg_Navigate_Params { bool reload; }; -// Parameters structure for ViewHostMsg_FrameNavigate, which has too many data -// parameters to be reasonably put in a predefined IPC message. +// Traits for ViewMsg_Navigate_Params structure to pack/unpack. +template <> +struct ParamTraits<ViewMsg_Navigate_Params> { + typedef ViewMsg_Navigate_Params param_type; + static void Write(IPC::Message* m, const param_type& p) { + WriteParam(m, p.page_id); + WriteParam(m, p.url); + WriteParam(m, p.referrer); + WriteParam(m, p.transition); + WriteParam(m, p.state); + WriteParam(m, p.reload); + } + static bool Read(const IPC::Message* m, void** iter, param_type* p) { + return + ReadParam(m, iter, &p->page_id) && + ReadParam(m, iter, &p->url) && + ReadParam(m, iter, &p->referrer) && + ReadParam(m, iter, &p->transition) && + ReadParam(m, iter, &p->state) && + ReadParam(m, iter, &p->reload); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"("); + LogParam(p.page_id, l); + l->append(L", "); + LogParam(p.url, l); + l->append(L", "); + LogParam(p.transition, l); + l->append(L", "); + LogParam(p.state, l); + l->append(L", "); + LogParam(p.reload, l); + l->append(L")"); + } +}; + + struct ViewHostMsg_FrameNavigate_Params { // Page ID of this navigation. The renderer creates a new unique page ID // anytime a new session history entry is created. This means you'll get new @@ -121,8 +156,80 @@ struct ViewHostMsg_FrameNavigate_Params { bool is_content_filtered; }; -// Parameters structure for ViewHostMsg_ContextMenu, which has too many data -// parameters to be reasonably put in a predefined IPC message. +template <> +struct ParamTraits<ViewHostMsg_FrameNavigate_Params> { + typedef ViewHostMsg_FrameNavigate_Params param_type; + static void Write(IPC::Message* m, const param_type& p) { + WriteParam(m, p.page_id); + WriteParam(m, p.url); + WriteParam(m, p.referrer); + WriteParam(m, p.transition); + WriteParam(m, p.redirects); + WriteParam(m, p.should_update_history); + WriteParam(m, p.searchable_form_url); + WriteParam(m, p.searchable_form_element_name); + WriteParam(m, p.searchable_form_encoding); + WriteParam(m, p.password_form); + WriteParam(m, p.security_info); + WriteParam(m, p.gesture); + WriteParam(m, p.contents_mime_type); + WriteParam(m, p.is_post); + WriteParam(m, p.is_content_filtered); + } + static bool Read(const IPC::Message* m, void** iter, param_type* p) { + return + ReadParam(m, iter, &p->page_id) && + ReadParam(m, iter, &p->url) && + ReadParam(m, iter, &p->referrer) && + ReadParam(m, iter, &p->transition) && + ReadParam(m, iter, &p->redirects) && + ReadParam(m, iter, &p->should_update_history) && + ReadParam(m, iter, &p->searchable_form_url) && + ReadParam(m, iter, &p->searchable_form_element_name) && + ReadParam(m, iter, &p->searchable_form_encoding) && + ReadParam(m, iter, &p->password_form) && + ReadParam(m, iter, &p->security_info) && + ReadParam(m, iter, &p->gesture) && + ReadParam(m, iter, &p->contents_mime_type) && + ReadParam(m, iter, &p->is_post) && + ReadParam(m, iter, &p->is_content_filtered); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"("); + LogParam(p.page_id, l); + l->append(L", "); + LogParam(p.url, l); + l->append(L", "); + LogParam(p.referrer, l); + l->append(L", "); + LogParam(p.transition, l); + l->append(L", "); + LogParam(p.redirects, l); + l->append(L", "); + LogParam(p.should_update_history, l); + l->append(L", "); + LogParam(p.searchable_form_url, l); + l->append(L", "); + LogParam(p.searchable_form_element_name, l); + l->append(L", "); + LogParam(p.searchable_form_encoding, l); + l->append(L", "); + LogParam(p.password_form, l); + l->append(L", "); + LogParam(p.security_info, l); + l->append(L", "); + LogParam(p.gesture, l); + l->append(L", "); + LogParam(p.contents_mime_type, l); + l->append(L", "); + LogParam(p.is_post, l); + l->append(L", "); + LogParam(p.is_content_filtered, l); + l->append(L")"); + } +}; + + // FIXME(beng): This would be more useful in the future and more efficient // if the parameters here weren't so literally mapped to what // they contain for the ContextMenu task. It might be better @@ -176,6 +283,45 @@ struct ViewHostMsg_ContextMenu_Params { std::string security_info; }; +template <> +struct ParamTraits<ViewHostMsg_ContextMenu_Params> { + typedef ViewHostMsg_ContextMenu_Params param_type; + static void Write(IPC::Message* m, const param_type& p) { + WriteParam(m, p.node); + WriteParam(m, p.x); + WriteParam(m, p.y); + WriteParam(m, p.link_url); + WriteParam(m, p.image_url); + WriteParam(m, p.page_url); + WriteParam(m, p.frame_url); + WriteParam(m, p.selection_text); + WriteParam(m, p.misspelled_word); + WriteParam(m, p.dictionary_suggestions); + WriteParam(m, p.spellcheck_enabled); + WriteParam(m, p.edit_flags); + WriteParam(m, p.security_info); + } + static bool Read(const IPC::Message* m, void** iter, param_type* p) { + return + ReadParam(m, iter, &p->node) && + ReadParam(m, iter, &p->x) && + ReadParam(m, iter, &p->y) && + ReadParam(m, iter, &p->link_url) && + ReadParam(m, iter, &p->image_url) && + ReadParam(m, iter, &p->page_url) && + ReadParam(m, iter, &p->frame_url) && + ReadParam(m, iter, &p->selection_text) && + ReadParam(m, iter, &p->misspelled_word) && + ReadParam(m, iter, &p->dictionary_suggestions) && + ReadParam(m, iter, &p->spellcheck_enabled) && + ReadParam(m, iter, &p->edit_flags) && + ReadParam(m, iter, &p->security_info); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"<ViewHostMsg_ContextMenu_Params>"); + } +}; + // Values that may be OR'd together to form the 'flags' parameter of a // ViewHostMsg_PaintRect message. struct ViewHostMsg_PaintRect_Flags { @@ -227,8 +373,40 @@ struct ViewHostMsg_PaintRect_Params { int flags; }; -// Parameters structure for ViewHostMsg_ScrollRect, which has too many data -// parameters to be reasonably put in a predefined IPC message. +template <> +struct ParamTraits<ViewHostMsg_PaintRect_Params> { + typedef ViewHostMsg_PaintRect_Params param_type; + static void Write(IPC::Message* m, const param_type& p) { + WriteParam(m, p.bitmap); + WriteParam(m, p.bitmap_rect); + WriteParam(m, p.view_size); + WriteParam(m, p.plugin_window_moves); + WriteParam(m, p.flags); + } + static bool Read(const IPC::Message* m, void** iter, param_type* p) { + return + ReadParam(m, iter, &p->bitmap) && + ReadParam(m, iter, &p->bitmap_rect) && + ReadParam(m, iter, &p->view_size) && + ReadParam(m, iter, &p->plugin_window_moves) && + ReadParam(m, iter, &p->flags); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"("); + LogParam(p.bitmap, l); + l->append(L", "); + LogParam(p.bitmap_rect, l); + l->append(L", "); + LogParam(p.view_size, l); + l->append(L", "); + LogParam(p.plugin_window_moves, l); + l->append(L", "); + LogParam(p.flags, l); + l->append(L")"); + } +}; + + struct ViewHostMsg_ScrollRect_Params { // The bitmap to be painted into the rect exposed by scrolling. BitmapWireData bitmap; @@ -250,7 +428,48 @@ struct ViewHostMsg_ScrollRect_Params { std::vector<WebPluginGeometry> plugin_window_moves; }; -// Parameters structure for ViewMsg_UploadFile. +template <> +struct ParamTraits<ViewHostMsg_ScrollRect_Params> { + typedef ViewHostMsg_ScrollRect_Params param_type; + static void Write(IPC::Message* m, const param_type& p) { + WriteParam(m, p.bitmap); + WriteParam(m, p.bitmap_rect); + WriteParam(m, p.dx); + WriteParam(m, p.dy); + WriteParam(m, p.clip_rect); + WriteParam(m, p.view_size); + WriteParam(m, p.plugin_window_moves); + } + static bool Read(const IPC::Message* m, void** iter, param_type* p) { + return + ReadParam(m, iter, &p->bitmap) && + ReadParam(m, iter, &p->bitmap_rect) && + ReadParam(m, iter, &p->dx) && + ReadParam(m, iter, &p->dy) && + ReadParam(m, iter, &p->clip_rect) && + ReadParam(m, iter, &p->view_size) && + ReadParam(m, iter, &p->plugin_window_moves); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"("); + LogParam(p.bitmap, l); + l->append(L", "); + LogParam(p.bitmap_rect, l); + l->append(L", "); + LogParam(p.dx, l); + l->append(L", "); + LogParam(p.dy, l); + l->append(L", "); + LogParam(p.clip_rect, l); + l->append(L", "); + LogParam(p.view_size, l); + l->append(L", "); + LogParam(p.plugin_window_moves, l); + l->append(L")"); + } +}; + + struct ViewMsg_UploadFile_Params { // See WebContents::StartFileUpload for a description of these fields. std::wstring file_path; @@ -260,7 +479,30 @@ struct ViewMsg_UploadFile_Params { std::wstring other_values; }; -// Parameters for a resource request. +template <> +struct ParamTraits<ViewMsg_UploadFile_Params> { + typedef ViewMsg_UploadFile_Params param_type; + static void Write(IPC::Message* m, const param_type& p) { + WriteParam(m, p.file_path); + WriteParam(m, p.form); + WriteParam(m, p.file); + WriteParam(m, p.submit); + WriteParam(m, p.other_values); + } + static bool Read(const IPC::Message* m, void** iter, param_type* p) { + return + ReadParam(m, iter, &p->file_path) && + ReadParam(m, iter, &p->form) && + ReadParam(m, iter, &p->file) && + ReadParam(m, iter, &p->submit) && + ReadParam(m, iter, &p->other_values); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"<ViewMsg_UploadFile_Params>"); + } +}; + + struct ViewHostMsg_Resource_Request { // The request method: GET, POST, etc. std::string method; @@ -302,7 +544,58 @@ struct ViewHostMsg_Resource_Request { std::vector<net::UploadData::Element> upload_content; }; -// Parameters for a resource response header. +template <> +struct ParamTraits<ViewHostMsg_Resource_Request> { + typedef ViewHostMsg_Resource_Request param_type; + static void Write(IPC::Message* m, const param_type& p) { + WriteParam(m, p.method); + WriteParam(m, p.url); + WriteParam(m, p.policy_url); + WriteParam(m, p.referrer); + WriteParam(m, p.headers); + WriteParam(m, p.load_flags); + WriteParam(m, p.origin_pid); + WriteParam(m, p.resource_type); + WriteParam(m, p.mixed_content); + WriteParam(m, p.request_context); + WriteParam(m, p.upload_content); + } + static bool Read(const IPC::Message* m, void** iter, param_type* r) { + return + ReadParam(m, iter, &r->method) && + ReadParam(m, iter, &r->url) && + ReadParam(m, iter, &r->policy_url) && + ReadParam(m, iter, &r->referrer) && + ReadParam(m, iter, &r->headers) && + ReadParam(m, iter, &r->load_flags) && + ReadParam(m, iter, &r->origin_pid) && + ReadParam(m, iter, &r->resource_type) && + ReadParam(m, iter, &r->mixed_content) && + ReadParam(m, iter, &r->request_context) && + ReadParam(m, iter, &r->upload_content); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"("); + LogParam(p.method, l); + l->append(L", "); + LogParam(p.url, l); + l->append(L", "); + LogParam(p.referrer, l); + l->append(L", "); + LogParam(p.load_flags, l); + l->append(L", "); + LogParam(p.origin_pid, l); + l->append(L", "); + LogParam(p.resource_type, l); + l->append(L", "); + LogParam(p.mixed_content, l); + l->append(L", "); + LogParam(p.request_context, l); + l->append(L")"); + } +}; + + struct ViewMsg_Resource_ResponseHead : webkit_glue::ResourceLoaderBridge::ResponseInfo { // The response status. @@ -313,7 +606,66 @@ struct ViewMsg_Resource_ResponseHead FilterPolicy::Type filter_policy; }; -// Parameters for a synchronous resource response. +template <> +struct ParamTraits<webkit_glue::ResourceLoaderBridge::ResponseInfo> { + typedef webkit_glue::ResourceLoaderBridge::ResponseInfo param_type; + static void Write(IPC::Message* m, const param_type& p) { + WriteParam(m, p.request_time); + WriteParam(m, p.response_time); + WriteParam(m, p.headers); + WriteParam(m, p.mime_type); + WriteParam(m, p.charset); + WriteParam(m, p.security_info); + WriteParam(m, p.content_length); + } + static bool Read(const IPC::Message* m, void** iter, param_type* r) { + return + ReadParam(m, iter, &r->request_time) && + ReadParam(m, iter, &r->response_time) && + ReadParam(m, iter, &r->headers) && + ReadParam(m, iter, &r->mime_type) && + ReadParam(m, iter, &r->charset) && + ReadParam(m, iter, &r->security_info) && + ReadParam(m, iter, &r->content_length); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"("); + LogParam(p.request_time, l); + l->append(L", "); + LogParam(p.response_time, l); + l->append(L", "); + LogParam(p.headers, l); + l->append(L", "); + LogParam(p.mime_type, l); + l->append(L", "); + LogParam(p.charset, l); + l->append(L", "); + LogParam(p.security_info, l); + l->append(L")"); + } +}; + +template <> +struct ParamTraits<ViewMsg_Resource_ResponseHead> { + typedef ViewMsg_Resource_ResponseHead param_type; + static void Write(IPC::Message* m, const param_type& p) { + ParamTraits<webkit_glue::ResourceLoaderBridge::ResponseInfo>::Write(m, p); + WriteParam(m, p.status); + WriteParam(m, p.filter_policy); + } + static bool Read(const IPC::Message* m, void** iter, param_type* r) { + return + ParamTraits<webkit_glue::ResourceLoaderBridge::ResponseInfo>::Read(m, iter, r) && + ReadParam(m, iter, &r->status) && + ReadParam(m, iter, &r->filter_policy); + } + static void Log(const param_type& p, std::wstring* l) { + // log more? + ParamTraits<webkit_glue::ResourceLoaderBridge::ResponseInfo>::Log(p, l); + } +}; + + struct ViewHostMsg_SyncLoad_Result : ViewMsg_Resource_ResponseHead { // The final URL after any redirects. GURL final_url; @@ -322,7 +674,27 @@ struct ViewHostMsg_SyncLoad_Result : ViewMsg_Resource_ResponseHead { std::string data; }; -// Parameters for a render request. +template <> +struct ParamTraits<ViewHostMsg_SyncLoad_Result> { + typedef ViewHostMsg_SyncLoad_Result param_type; + static void Write(IPC::Message* m, const param_type& p) { + ParamTraits<ViewMsg_Resource_ResponseHead>::Write(m, p); + WriteParam(m, p.final_url); + WriteParam(m, p.data); + } + static bool Read(const IPC::Message* m, void** iter, param_type* r) { + return + ParamTraits<ViewMsg_Resource_ResponseHead>::Read(m, iter, r) && + ReadParam(m, iter, &r->final_url) && + ReadParam(m, iter, &r->data); + } + static void Log(const param_type& p, std::wstring* l) { + // log more? + ParamTraits<webkit_glue::ResourceLoaderBridge::ResponseInfo>::Log(p, l); + } +}; + + struct ViewMsg_Print_Params { // In pixels according to dpi_x and dpi_y. gfx::Size printable_size; @@ -352,6 +724,31 @@ struct ViewMsg_Print_Params { } }; +template <> +struct ParamTraits<ViewMsg_Print_Params> { + typedef ViewMsg_Print_Params param_type; + static void Write(IPC::Message* m, const param_type& p) { + WriteParam(m, p.printable_size); + WriteParam(m, p.dpi); + WriteParam(m, p.min_shrink); + WriteParam(m, p.max_shrink); + WriteParam(m, p.desired_dpi); + WriteParam(m, p.document_cookie); + } + static bool Read(const IPC::Message* m, void** iter, param_type* p) { + return ReadParam(m, iter, &p->printable_size) && + ReadParam(m, iter, &p->dpi) && + ReadParam(m, iter, &p->min_shrink) && + ReadParam(m, iter, &p->max_shrink) && + ReadParam(m, iter, &p->desired_dpi) && + ReadParam(m, iter, &p->document_cookie); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"<ViewMsg_Print_Params>"); + } +}; + + struct ViewMsg_PrintPage_Params { // Parameters to render the page as a printed page. It must always be the same // value for all the document. @@ -362,6 +759,23 @@ struct ViewMsg_PrintPage_Params { int page_number; }; +template <> +struct ParamTraits<ViewMsg_PrintPage_Params> { + typedef ViewMsg_PrintPage_Params param_type; + static void Write(IPC::Message* m, const param_type& p) { + WriteParam(m, p.params); + WriteParam(m, p.page_number); + } + static bool Read(const IPC::Message* m, void** iter, param_type* p) { + return ReadParam(m, iter, &p->params) && + ReadParam(m, iter, &p->page_number); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"<ViewMsg_PrintPage_Params>"); + } +}; + + struct ViewMsg_PrintPages_Params { // Parameters to render the page as a printed page. It must always be the same // value for all the document. @@ -371,6 +785,23 @@ struct ViewMsg_PrintPages_Params { std::vector<int> pages; }; +template <> +struct ParamTraits<ViewMsg_PrintPages_Params> { + typedef ViewMsg_PrintPages_Params param_type; + static void Write(IPC::Message* m, const param_type& p) { + WriteParam(m, p.params); + WriteParam(m, p.pages); + } + static bool Read(const IPC::Message* m, void** iter, param_type* p) { + return ReadParam(m, iter, &p->params) && + ReadParam(m, iter, &p->pages); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"<ViewMsg_PrintPages_Params>"); + } +}; + + // Parameters to describe a rendered page. struct ViewHostMsg_DidPrintPage_Params { // A shared memory handle to the EMF data. This data can be quite large so a @@ -390,6 +821,29 @@ struct ViewHostMsg_DidPrintPage_Params { double actual_shrink; }; +template <> +struct ParamTraits<ViewHostMsg_DidPrintPage_Params> { + typedef ViewHostMsg_DidPrintPage_Params param_type; + static void Write(IPC::Message* m, const param_type& p) { + WriteParam(m, p.emf_data_handle); + WriteParam(m, p.data_size); + WriteParam(m, p.document_cookie); + WriteParam(m, p.page_number); + WriteParam(m, p.actual_shrink); + } + static bool Read(const IPC::Message* m, void** iter, param_type* p) { + return ReadParam(m, iter, &p->emf_data_handle) && + ReadParam(m, iter, &p->data_size) && + ReadParam(m, iter, &p->document_cookie) && + ReadParam(m, iter, &p->page_number) && + ReadParam(m, iter, &p->actual_shrink); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"<ViewHostMsg_DidPrintPage_Params>"); + } +}; + + // Parameters structure to hold a union of the possible IAccessible function // INPUT variables, with the unused fields always set to default value. Used in // ViewMsg_GetAccessibilityInfo, as only parameter. @@ -410,6 +864,40 @@ struct ViewMsg_Accessibility_In_Params { long input_long2; }; +template <> +struct ParamTraits<ViewMsg_Accessibility_In_Params> { + typedef ViewMsg_Accessibility_In_Params param_type; + static void Write(IPC::Message* m, const param_type& p) { + WriteParam(m, p.iaccessible_id); + WriteParam(m, p.iaccessible_function_id); + WriteParam(m, p.input_variant_lval); + WriteParam(m, p.input_long1); + WriteParam(m, p.input_long2); + } + static bool Read(const IPC::Message* m, void** iter, param_type* p) { + return + ReadParam(m, iter, &p->iaccessible_id) && + ReadParam(m, iter, &p->iaccessible_function_id) && + ReadParam(m, iter, &p->input_variant_lval) && + ReadParam(m, iter, &p->input_long1) && + ReadParam(m, iter, &p->input_long2); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"("); + LogParam(p.iaccessible_id, l); + l->append(L", "); + LogParam(p.iaccessible_function_id, l); + l->append(L", "); + LogParam(p.input_variant_lval, l); + l->append(L", "); + LogParam(p.input_long1, l); + l->append(L", "); + LogParam(p.input_long2, l); + l->append(L")"); + } +}; + + // Parameters structure to hold a union of the possible IAccessible function // OUTPUT variables, with the unused fields always set to default value. Used in // ViewHostMsg_GetAccessibilityInfoResponse, as only parameter. @@ -439,6 +927,52 @@ struct ViewHostMsg_Accessibility_Out_Params { bool return_code; }; +template <> +struct ParamTraits<ViewHostMsg_Accessibility_Out_Params> { + typedef ViewHostMsg_Accessibility_Out_Params param_type; + static void Write(IPC::Message* m, const param_type& p) { + WriteParam(m, p.iaccessible_id); + WriteParam(m, p.output_variant_lval); + WriteParam(m, p.output_long1); + WriteParam(m, p.output_long2); + WriteParam(m, p.output_long3); + WriteParam(m, p.output_long4); + WriteParam(m, p.output_string); + WriteParam(m, p.return_code); + } + static bool Read(const IPC::Message* m, void** iter, param_type* p) { + return + ReadParam(m, iter, &p->iaccessible_id) && + ReadParam(m, iter, &p->output_variant_lval) && + ReadParam(m, iter, &p->output_long1) && + ReadParam(m, iter, &p->output_long2) && + ReadParam(m, iter, &p->output_long3) && + ReadParam(m, iter, &p->output_long4) && + ReadParam(m, iter, &p->output_string) && + ReadParam(m, iter, &p->return_code); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"("); + LogParam(p.iaccessible_id, l); + l->append(L", "); + LogParam(p.output_variant_lval, l); + l->append(L", "); + LogParam(p.output_long1, l); + l->append(L", "); + LogParam(p.output_long2, l); + l->append(L", "); + LogParam(p.output_long3, l); + l->append(L", "); + LogParam(p.output_long4, l); + l->append(L", "); + LogParam(p.output_string, l); + l->append(L", "); + LogParam(p.return_code, l); + l->append(L")"); + } +}; + + // The first parameter for the ViewHostMsg_ImeUpdateStatus message. enum ViewHostMsg_ImeControl { IME_DISABLE = 0, @@ -446,38 +980,49 @@ enum ViewHostMsg_ImeControl { IME_COMPLETE_COMPOSITION, }; -// Multi-pass include of render_messages_internal. Preprocessor magic allows -// us to use 1 header to define the enums and classes for our render messages. -#define IPC_MESSAGE_MACROS_ENUMS -#include "chrome/common/render_messages_internal.h" - -#ifdef IPC_MESSAGE_MACROS_LOG_ENABLED -// When we are supposed to create debug strings, we run it through twice, once -// with debug strings on, and once with only CLASSES on to generate both types -// of messages. -# undef IPC_MESSAGE_MACROS_LOG -# define IPC_MESSAGE_MACROS_CLASSES -# include "chrome/common/render_messages_internal.h" - -# undef IPC_MESSAGE_MACROS_CLASSES -# define IPC_MESSAGE_MACROS_LOG -# include "chrome/common/render_messages_internal.h" -#else -// No debug strings requested, just define the classes -# define IPC_MESSAGE_MACROS_CLASSES -# include "chrome/common/render_messages_internal.h" -#endif +template <> +struct ParamTraits<ViewHostMsg_ImeControl> { + typedef ViewHostMsg_ImeControl param_type; + static void Write(IPC::Message* m, const param_type& p) { + m->WriteInt(p); + } + static bool Read(const IPC::Message* m, void** iter, param_type* p) { + int type; + if (!m->ReadInt(iter, &type)) + return false; + *p = static_cast<ViewHostMsg_ImeControl>(type); + return true; + } + static void Log(const param_type& p, std::wstring* l) { + std::wstring control; + switch (p) { + case IME_DISABLE: + control = L"IME_DISABLE"; + break; + case IME_MOVE_WINDOWS: + control = L"IME_MOVE_WINDOWS"; + break; + case IME_COMPLETE_COMPOSITION: + control = L"IME_COMPLETE_COMPOSITION"; + break; + default: + control = L"UNKNOWN"; + break; + } + LogParam(control, l); + } +}; -namespace IPC { +// These traits are for structures that are defined outside of this file. template <> struct ParamTraits<ResourceType::Type> { typedef ResourceType::Type param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { m->WriteInt(p); } - static bool Read(const Message* m, void** iter, param_type* p) { + static bool Read(const IPC::Message* m, void** iter, param_type* p) { int type; if (!m->ReadInt(iter, &type) || !ResourceType::ValidType(type)) return false; @@ -511,10 +1056,10 @@ struct ParamTraits<ResourceType::Type> { template <> struct ParamTraits<FilterPolicy::Type> { typedef FilterPolicy::Type param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { m->WriteInt(p); } - static bool Read(const Message* m, void** iter, param_type* p) { + static bool Read(const IPC::Message* m, void** iter, param_type* p) { int type; if (!m->ReadInt(iter, &type) || !FilterPolicy::ValidType(type)) return false; @@ -545,10 +1090,10 @@ struct ParamTraits<FilterPolicy::Type> { template <> struct ParamTraits<ContextNode> { typedef ContextNode param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { m->WriteInt(p.type); } - static bool Read(const Message* m, void** iter, param_type* p) { + static bool Read(const IPC::Message* m, void** iter, param_type* p) { int type; if (!m->ReadInt(iter, &type)) return false; @@ -586,10 +1131,10 @@ struct ParamTraits<ContextNode> { template <> struct ParamTraits<WebInputEvent::Type> { typedef WebInputEvent::Type param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { m->WriteInt(p); } - static bool Read(const Message* m, void** iter, param_type* p) { + static bool Read(const IPC::Message* m, void** iter, param_type* p) { int type; if (!m->ReadInt(iter, &type)) return false; @@ -632,161 +1177,10 @@ struct ParamTraits<WebInputEvent::Type> { } }; -// Traits for ViewMsg_Accessibility_In_Params structure to pack/unpack. -template <> -struct ParamTraits<ViewMsg_Accessibility_In_Params> { - typedef ViewMsg_Accessibility_In_Params param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.iaccessible_id); - WriteParam(m, p.iaccessible_function_id); - WriteParam(m, p.input_variant_lval); - WriteParam(m, p.input_long1); - WriteParam(m, p.input_long2); - } - static bool Read(const Message* m, void** iter, param_type* p) { - return - ReadParam(m, iter, &p->iaccessible_id) && - ReadParam(m, iter, &p->iaccessible_function_id) && - ReadParam(m, iter, &p->input_variant_lval) && - ReadParam(m, iter, &p->input_long1) && - ReadParam(m, iter, &p->input_long2); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"("); - LogParam(p.iaccessible_id, l); - l->append(L", "); - LogParam(p.iaccessible_function_id, l); - l->append(L", "); - LogParam(p.input_variant_lval, l); - l->append(L", "); - LogParam(p.input_long1, l); - l->append(L", "); - LogParam(p.input_long2, l); - l->append(L")"); - } -}; - -// Traits for ViewHostMsg_Accessibility_Out_Params structure to pack/unpack. -template <> -struct ParamTraits<ViewHostMsg_Accessibility_Out_Params> { - typedef ViewHostMsg_Accessibility_Out_Params param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.iaccessible_id); - WriteParam(m, p.output_variant_lval); - WriteParam(m, p.output_long1); - WriteParam(m, p.output_long2); - WriteParam(m, p.output_long3); - WriteParam(m, p.output_long4); - WriteParam(m, p.output_string); - WriteParam(m, p.return_code); - } - static bool Read(const Message* m, void** iter, param_type* p) { - return - ReadParam(m, iter, &p->iaccessible_id) && - ReadParam(m, iter, &p->output_variant_lval) && - ReadParam(m, iter, &p->output_long1) && - ReadParam(m, iter, &p->output_long2) && - ReadParam(m, iter, &p->output_long3) && - ReadParam(m, iter, &p->output_long4) && - ReadParam(m, iter, &p->output_string) && - ReadParam(m, iter, &p->return_code); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"("); - LogParam(p.iaccessible_id, l); - l->append(L", "); - LogParam(p.output_variant_lval, l); - l->append(L", "); - LogParam(p.output_long1, l); - l->append(L", "); - LogParam(p.output_long2, l); - l->append(L", "); - LogParam(p.output_long3, l); - l->append(L", "); - LogParam(p.output_long4, l); - l->append(L", "); - LogParam(p.output_string, l); - l->append(L", "); - LogParam(p.return_code, l); - l->append(L")"); - } -}; - -template <> -struct ParamTraits<ViewHostMsg_ImeControl> { - typedef ViewHostMsg_ImeControl param_type; - static void Write(Message* m, const param_type& p) { - m->WriteInt(p); - } - static bool Read(const Message* m, void** iter, param_type* p) { - int type; - if (!m->ReadInt(iter, &type)) - return false; - *p = static_cast<ViewHostMsg_ImeControl>(type); - return true; - } - static void Log(const param_type& p, std::wstring* l) { - std::wstring control; - switch (p) { - case IME_DISABLE: - control = L"IME_DISABLE"; - break; - case IME_MOVE_WINDOWS: - control = L"IME_MOVE_WINDOWS"; - break; - case IME_COMPLETE_COMPOSITION: - control = L"IME_COMPLETE_COMPOSITION"; - break; - default: - control = L"UNKNOWN"; - break; - } - - LogParam(control, l); - } -}; - -// Traits for ViewMsg_Navigate_Params structure to pack/unpack. -template <> -struct ParamTraits<ViewMsg_Navigate_Params> { - typedef ViewMsg_Navigate_Params param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.page_id); - WriteParam(m, p.url); - WriteParam(m, p.referrer); - WriteParam(m, p.transition); - WriteParam(m, p.state); - WriteParam(m, p.reload); - } - static bool Read(const Message* m, void** iter, param_type* p) { - return - ReadParam(m, iter, &p->page_id) && - ReadParam(m, iter, &p->url) && - ReadParam(m, iter, &p->referrer) && - ReadParam(m, iter, &p->transition) && - ReadParam(m, iter, &p->state) && - ReadParam(m, iter, &p->reload); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"("); - LogParam(p.page_id, l); - l->append(L", "); - LogParam(p.url, l); - l->append(L", "); - LogParam(p.transition, l); - l->append(L", "); - LogParam(p.state, l); - l->append(L", "); - LogParam(p.reload, l); - l->append(L")"); - } -}; - -// Traits for PasswordForm_Params structure to pack/unpack. template <> struct ParamTraits<PasswordForm> { typedef PasswordForm param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, p.signon_realm); WriteParam(m, p.origin); WriteParam(m, p.action); @@ -801,7 +1195,7 @@ struct ParamTraits<PasswordForm> { WriteParam(m, p.preferred); WriteParam(m, p.blacklisted_by_user); } - static bool Read(const Message* m, void** iter, param_type* p) { + static bool Read(const IPC::Message* m, void** iter, param_type* p) { return ReadParam(m, iter, &p->signon_realm) && ReadParam(m, iter, &p->origin) && @@ -822,11 +1216,10 @@ struct ParamTraits<PasswordForm> { } }; -// Traits for AutofillForm_Params structure to pack/unpack. template <> struct ParamTraits<AutofillForm> { typedef AutofillForm param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, p.elements.size()); for (std::vector<AutofillForm::Element>::const_iterator itr = p.elements.begin(); @@ -836,7 +1229,7 @@ struct ParamTraits<AutofillForm> { WriteParam(m, itr->value); } } - static bool Read(const Message* m, void** iter, param_type* p) { + static bool Read(const IPC::Message* m, void** iter, param_type* p) { bool result = true; size_t elements_size = 0; result = result && ReadParam(m, iter, &elements_size); @@ -853,207 +1246,18 @@ struct ParamTraits<AutofillForm> { } }; -// Traits for ViewHostMsg_FrameNavigate_Params structure to pack/unpack. -template <> -struct ParamTraits<ViewHostMsg_FrameNavigate_Params> { - typedef ViewHostMsg_FrameNavigate_Params param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.page_id); - WriteParam(m, p.url); - WriteParam(m, p.referrer); - WriteParam(m, p.transition); - WriteParam(m, p.redirects); - WriteParam(m, p.should_update_history); - WriteParam(m, p.searchable_form_url); - WriteParam(m, p.searchable_form_element_name); - WriteParam(m, p.searchable_form_encoding); - WriteParam(m, p.password_form); - WriteParam(m, p.security_info); - WriteParam(m, p.gesture); - WriteParam(m, p.contents_mime_type); - WriteParam(m, p.is_post); - WriteParam(m, p.is_content_filtered); - } - static bool Read(const Message* m, void** iter, param_type* p) { - return - ReadParam(m, iter, &p->page_id) && - ReadParam(m, iter, &p->url) && - ReadParam(m, iter, &p->referrer) && - ReadParam(m, iter, &p->transition) && - ReadParam(m, iter, &p->redirects) && - ReadParam(m, iter, &p->should_update_history) && - ReadParam(m, iter, &p->searchable_form_url) && - ReadParam(m, iter, &p->searchable_form_element_name) && - ReadParam(m, iter, &p->searchable_form_encoding) && - ReadParam(m, iter, &p->password_form) && - ReadParam(m, iter, &p->security_info) && - ReadParam(m, iter, &p->gesture) && - ReadParam(m, iter, &p->contents_mime_type) && - ReadParam(m, iter, &p->is_post) && - ReadParam(m, iter, &p->is_content_filtered); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"("); - LogParam(p.page_id, l); - l->append(L", "); - LogParam(p.url, l); - l->append(L", "); - LogParam(p.referrer, l); - l->append(L", "); - LogParam(p.transition, l); - l->append(L", "); - LogParam(p.redirects, l); - l->append(L", "); - LogParam(p.should_update_history, l); - l->append(L", "); - LogParam(p.searchable_form_url, l); - l->append(L", "); - LogParam(p.searchable_form_element_name, l); - l->append(L", "); - LogParam(p.searchable_form_encoding, l); - l->append(L", "); - LogParam(p.password_form, l); - l->append(L", "); - LogParam(p.security_info, l); - l->append(L", "); - LogParam(p.gesture, l); - l->append(L", "); - LogParam(p.contents_mime_type, l); - l->append(L", "); - LogParam(p.is_post, l); - l->append(L", "); - LogParam(p.is_content_filtered, l); - l->append(L")"); - } -}; - -// Traits for ViewHostMsg_ContextMenu_Params structure to pack/unpack. -template <> -struct ParamTraits<ViewHostMsg_ContextMenu_Params> { - typedef ViewHostMsg_ContextMenu_Params param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.node); - WriteParam(m, p.x); - WriteParam(m, p.y); - WriteParam(m, p.link_url); - WriteParam(m, p.image_url); - WriteParam(m, p.page_url); - WriteParam(m, p.frame_url); - WriteParam(m, p.selection_text); - WriteParam(m, p.misspelled_word); - WriteParam(m, p.dictionary_suggestions); - WriteParam(m, p.spellcheck_enabled); - WriteParam(m, p.edit_flags); - WriteParam(m, p.security_info); - } - static bool Read(const Message* m, void** iter, param_type* p) { - return - ReadParam(m, iter, &p->node) && - ReadParam(m, iter, &p->x) && - ReadParam(m, iter, &p->y) && - ReadParam(m, iter, &p->link_url) && - ReadParam(m, iter, &p->image_url) && - ReadParam(m, iter, &p->page_url) && - ReadParam(m, iter, &p->frame_url) && - ReadParam(m, iter, &p->selection_text) && - ReadParam(m, iter, &p->misspelled_word) && - ReadParam(m, iter, &p->dictionary_suggestions) && - ReadParam(m, iter, &p->spellcheck_enabled) && - ReadParam(m, iter, &p->edit_flags) && - ReadParam(m, iter, &p->security_info); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"<ViewHostMsg_ContextMenu_Params>"); - } -}; - -// Traits for ViewHostMsg_PaintRect_Params structure to pack/unpack. -template <> -struct ParamTraits<ViewHostMsg_PaintRect_Params> { - typedef ViewHostMsg_PaintRect_Params param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.bitmap); - WriteParam(m, p.bitmap_rect); - WriteParam(m, p.view_size); - WriteParam(m, p.plugin_window_moves); - WriteParam(m, p.flags); - } - static bool Read(const Message* m, void** iter, param_type* p) { - return - ReadParam(m, iter, &p->bitmap) && - ReadParam(m, iter, &p->bitmap_rect) && - ReadParam(m, iter, &p->view_size) && - ReadParam(m, iter, &p->plugin_window_moves) && - ReadParam(m, iter, &p->flags); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"("); - LogParam(p.bitmap, l); - l->append(L", "); - LogParam(p.bitmap_rect, l); - l->append(L", "); - LogParam(p.view_size, l); - l->append(L", "); - LogParam(p.plugin_window_moves, l); - l->append(L", "); - LogParam(p.flags, l); - l->append(L")"); - } -}; - -// Traits for ViewHostMsg_ScrollRect_Params structure to pack/unpack. -template <> -struct ParamTraits<ViewHostMsg_ScrollRect_Params> { - typedef ViewHostMsg_ScrollRect_Params param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.bitmap); - WriteParam(m, p.bitmap_rect); - WriteParam(m, p.dx); - WriteParam(m, p.dy); - WriteParam(m, p.clip_rect); - WriteParam(m, p.view_size); - WriteParam(m, p.plugin_window_moves); - } - static bool Read(const Message* m, void** iter, param_type* p) { - return - ReadParam(m, iter, &p->bitmap) && - ReadParam(m, iter, &p->bitmap_rect) && - ReadParam(m, iter, &p->dx) && - ReadParam(m, iter, &p->dy) && - ReadParam(m, iter, &p->clip_rect) && - ReadParam(m, iter, &p->view_size) && - ReadParam(m, iter, &p->plugin_window_moves); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"("); - LogParam(p.bitmap, l); - l->append(L", "); - LogParam(p.bitmap_rect, l); - l->append(L", "); - LogParam(p.dx, l); - l->append(L", "); - LogParam(p.dy, l); - l->append(L", "); - LogParam(p.clip_rect, l); - l->append(L", "); - LogParam(p.view_size, l); - l->append(L", "); - LogParam(p.plugin_window_moves, l); - l->append(L")"); - } -}; template <> struct ParamTraits<WebPluginGeometry> { typedef WebPluginGeometry param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, p.window); WriteParam(m, p.window_rect); WriteParam(m, p.clip_rect); WriteParam(m, p.cutout_rects); WriteParam(m, p.visible); } - static bool Read(const Message* m, void** iter, param_type* p) { + static bool Read(const IPC::Message* m, void** iter, param_type* p) { return ReadParam(m, iter, &p->window) && ReadParam(m, iter, &p->window_rect) && @@ -1076,16 +1280,16 @@ struct ParamTraits<WebPluginGeometry> { } }; -// Traits for ViewMsg_GetPlugins_Reply structure to pack/unpack. + template <> struct ParamTraits<WebPluginMimeType> { typedef WebPluginMimeType param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, p.mime_type); WriteParam(m, p.file_extensions); WriteParam(m, p.description); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { return ReadParam(m, iter, &r->mime_type) && ReadParam(m, iter, &r->file_extensions) && @@ -1106,14 +1310,14 @@ struct ParamTraits<WebPluginMimeType> { template <> struct ParamTraits<WebPluginInfo> { typedef WebPluginInfo param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::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); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { return ReadParam(m, iter, &r->name) && ReadParam(m, iter, &r->path) && @@ -1137,35 +1341,10 @@ struct ParamTraits<WebPluginInfo> { } }; -// Traits for ViewMsg_UploadFile_Params structure to pack/unpack. -template <> -struct ParamTraits<ViewMsg_UploadFile_Params> { - typedef ViewMsg_UploadFile_Params param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.file_path); - WriteParam(m, p.form); - WriteParam(m, p.file); - WriteParam(m, p.submit); - WriteParam(m, p.other_values); - } - static bool Read(const Message* m, void** iter, param_type* p) { - return - ReadParam(m, iter, &p->file_path) && - ReadParam(m, iter, &p->form) && - ReadParam(m, iter, &p->file) && - ReadParam(m, iter, &p->submit) && - ReadParam(m, iter, &p->other_values); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"<ViewMsg_UploadFile_Params>"); - } -}; - -// Traits for net::UploadData::Element. template <> struct ParamTraits<net::UploadData::Element> { typedef net::UploadData::Element param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, static_cast<int>(p.type())); if (p.type() == net::UploadData::TYPE_BYTES) { m->WriteData(&p.bytes()[0], static_cast<int>(p.bytes().size())); @@ -1175,7 +1354,7 @@ struct ParamTraits<net::UploadData::Element> { WriteParam(m, p.file_range_length()); } } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { int type; if (!ReadParam(m, iter, &type)) return false; @@ -1204,18 +1383,17 @@ struct ParamTraits<net::UploadData::Element> { } }; -// Traits for CacheManager::UsageStats template <> struct ParamTraits<CacheManager::UsageStats> { typedef CacheManager::UsageStats param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, p.min_dead_capacity); WriteParam(m, p.max_dead_capacity); WriteParam(m, p.capacity); WriteParam(m, p.live_size); WriteParam(m, p.dead_size); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { return ReadParam(m, iter, &r->min_dead_capacity) && ReadParam(m, iter, &r->max_dead_capacity) && @@ -1228,16 +1406,15 @@ struct ParamTraits<CacheManager::UsageStats> { } }; -// Traits for PasswordFormDomManager::FillData. template <> struct ParamTraits<PasswordFormDomManager::FillData> { typedef PasswordFormDomManager::FillData param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, p.basic_data); WriteParam(m, p.additional_logins); WriteParam(m, p.wait_for_username); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { return ReadParam(m, iter, &r->basic_data) && ReadParam(m, iter, &r->additional_logins) && @@ -1251,10 +1428,10 @@ struct ParamTraits<PasswordFormDomManager::FillData> { template<> struct ParamTraits<NavigationGesture> { typedef NavigationGesture param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { m->WriteInt(p); } - static bool Read(const Message* m, void** iter, param_type* p) { + static bool Read(const IPC::Message* m, void** iter, param_type* p) { int type; if (!m->ReadInt(iter, &type)) return false; @@ -1278,67 +1455,14 @@ struct ParamTraits<NavigationGesture> { } }; -// Traits for ViewHostMsg_Resource_Request -template <> -struct ParamTraits<ViewHostMsg_Resource_Request> { - typedef ViewHostMsg_Resource_Request param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.method); - WriteParam(m, p.url); - WriteParam(m, p.policy_url); - WriteParam(m, p.referrer); - WriteParam(m, p.headers); - WriteParam(m, p.load_flags); - WriteParam(m, p.origin_pid); - WriteParam(m, p.resource_type); - WriteParam(m, p.mixed_content); - WriteParam(m, p.request_context); - WriteParam(m, p.upload_content); - } - static bool Read(const Message* m, void** iter, param_type* r) { - return - ReadParam(m, iter, &r->method) && - ReadParam(m, iter, &r->url) && - ReadParam(m, iter, &r->policy_url) && - ReadParam(m, iter, &r->referrer) && - ReadParam(m, iter, &r->headers) && - ReadParam(m, iter, &r->load_flags) && - ReadParam(m, iter, &r->origin_pid) && - ReadParam(m, iter, &r->resource_type) && - ReadParam(m, iter, &r->mixed_content) && - ReadParam(m, iter, &r->request_context) && - ReadParam(m, iter, &r->upload_content); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"("); - LogParam(p.method, l); - l->append(L", "); - LogParam(p.url, l); - l->append(L", "); - LogParam(p.referrer, l); - l->append(L", "); - LogParam(p.load_flags, l); - l->append(L", "); - LogParam(p.origin_pid, l); - l->append(L", "); - LogParam(p.resource_type, l); - l->append(L", "); - LogParam(p.mixed_content, l); - l->append(L", "); - LogParam(p.request_context, l); - l->append(L")"); - } -}; - -// Traits for URLRequestStatus template <> struct ParamTraits<URLRequestStatus> { typedef URLRequestStatus param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, static_cast<int>(p.status())); WriteParam(m, p.os_error()); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { int status, os_error; if (!ReadParam(m, iter, &status) || !ReadParam(m, iter, &os_error)) @@ -1385,14 +1509,14 @@ struct ParamTraits<URLRequestStatus> { template <> struct ParamTraits<scoped_refptr<net::HttpResponseHeaders> > { typedef scoped_refptr<net::HttpResponseHeaders> param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::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); } } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const IPC::Message* m, void** iter, param_type* r) { bool has_object; if (!ReadParam(m, iter, &has_object)) return false; @@ -1405,100 +1529,17 @@ struct ParamTraits<scoped_refptr<net::HttpResponseHeaders> > { } }; -// Traits for webkit_glue::ResourceLoaderBridge::ResponseInfo -template <> -struct ParamTraits<webkit_glue::ResourceLoaderBridge::ResponseInfo> { - typedef webkit_glue::ResourceLoaderBridge::ResponseInfo param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.request_time); - WriteParam(m, p.response_time); - WriteParam(m, p.headers); - WriteParam(m, p.mime_type); - WriteParam(m, p.charset); - WriteParam(m, p.security_info); - WriteParam(m, p.content_length); - } - static bool Read(const Message* m, void** iter, param_type* r) { - return - ReadParam(m, iter, &r->request_time) && - ReadParam(m, iter, &r->response_time) && - ReadParam(m, iter, &r->headers) && - ReadParam(m, iter, &r->mime_type) && - ReadParam(m, iter, &r->charset) && - ReadParam(m, iter, &r->security_info) && - ReadParam(m, iter, &r->content_length); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"("); - LogParam(p.request_time, l); - l->append(L", "); - LogParam(p.response_time, l); - l->append(L", "); - LogParam(p.headers, l); - l->append(L", "); - LogParam(p.mime_type, l); - l->append(L", "); - LogParam(p.charset, l); - l->append(L", "); - LogParam(p.security_info, l); - l->append(L")"); - } -}; - -// Traits for ViewMsg_Resource_ResponseHead -template <> -struct ParamTraits<ViewMsg_Resource_ResponseHead> { - typedef ViewMsg_Resource_ResponseHead param_type; - static void Write(Message* m, const param_type& p) { - ParamTraits<webkit_glue::ResourceLoaderBridge::ResponseInfo>::Write(m, p); - WriteParam(m, p.status); - WriteParam(m, p.filter_policy); - } - static bool Read(const Message* m, void** iter, param_type* r) { - return - ParamTraits<webkit_glue::ResourceLoaderBridge::ResponseInfo>::Read(m, iter, r) && - ReadParam(m, iter, &r->status) && - ReadParam(m, iter, &r->filter_policy); - } - static void Log(const param_type& p, std::wstring* l) { - // log more? - ParamTraits<webkit_glue::ResourceLoaderBridge::ResponseInfo>::Log(p, l); - } -}; - -// Traits for ViewHostMsg_Resource_SyncLoad_Response -template <> -struct ParamTraits<ViewHostMsg_SyncLoad_Result> { - typedef ViewHostMsg_SyncLoad_Result param_type; - static void Write(Message* m, const param_type& p) { - ParamTraits<ViewMsg_Resource_ResponseHead>::Write(m, p); - WriteParam(m, p.final_url); - WriteParam(m, p.data); - } - static bool Read(const Message* m, void** iter, param_type* r) { - return - ParamTraits<ViewMsg_Resource_ResponseHead>::Read(m, iter, r) && - ReadParam(m, iter, &r->final_url) && - ReadParam(m, iter, &r->data); - } - static void Log(const param_type& p, std::wstring* l) { - // log more? - ParamTraits<webkit_glue::ResourceLoaderBridge::ResponseInfo>::Log(p, l); - } -}; - -// Traits for FormData structure to pack/unpack. template <> struct ParamTraits<FormData> { typedef FormData param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, p.origin); WriteParam(m, p.action); WriteParam(m, p.elements); WriteParam(m, p.values); WriteParam(m, p.submit); } - static bool Read(const Message* m, void** iter, param_type* p) { + static bool Read(const IPC::Message* m, void** iter, param_type* p) { return ReadParam(m, iter, &p->origin) && ReadParam(m, iter, &p->action) && @@ -1511,93 +1552,10 @@ struct ParamTraits<FormData> { } }; -// Traits for ViewMsg_Print_Params -template <> -struct ParamTraits<ViewMsg_Print_Params> { - typedef ViewMsg_Print_Params param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.printable_size); - WriteParam(m, p.dpi); - WriteParam(m, p.min_shrink); - WriteParam(m, p.max_shrink); - WriteParam(m, p.desired_dpi); - WriteParam(m, p.document_cookie); - } - static bool Read(const Message* m, void** iter, param_type* p) { - return ReadParam(m, iter, &p->printable_size) && - ReadParam(m, iter, &p->dpi) && - ReadParam(m, iter, &p->min_shrink) && - ReadParam(m, iter, &p->max_shrink) && - ReadParam(m, iter, &p->desired_dpi) && - ReadParam(m, iter, &p->document_cookie); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"<ViewMsg_Print_Params>"); - } -}; - -// Traits for ViewMsg_PrintPage_Params -template <> -struct ParamTraits<ViewMsg_PrintPage_Params> { - typedef ViewMsg_PrintPage_Params param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.params); - WriteParam(m, p.page_number); - } - static bool Read(const Message* m, void** iter, param_type* p) { - return ReadParam(m, iter, &p->params) && - ReadParam(m, iter, &p->page_number); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"<ViewMsg_PrintPage_Params>"); - } -}; - -// Traits for ViewMsg_PrintPages_Params -template <> -struct ParamTraits<ViewMsg_PrintPages_Params> { - typedef ViewMsg_PrintPages_Params param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.params); - WriteParam(m, p.pages); - } - static bool Read(const Message* m, void** iter, param_type* p) { - return ReadParam(m, iter, &p->params) && - ReadParam(m, iter, &p->pages); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"<ViewMsg_PrintPages_Params>"); - } -}; - -// Traits for ViewHostMsg_DidPrintPage_Params -template <> -struct ParamTraits<ViewHostMsg_DidPrintPage_Params> { - typedef ViewHostMsg_DidPrintPage_Params param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.emf_data_handle); - WriteParam(m, p.data_size); - WriteParam(m, p.document_cookie); - WriteParam(m, p.page_number); - WriteParam(m, p.actual_shrink); - } - static bool Read(const Message* m, void** iter, param_type* p) { - return ReadParam(m, iter, &p->emf_data_handle) && - ReadParam(m, iter, &p->data_size) && - ReadParam(m, iter, &p->document_cookie) && - ReadParam(m, iter, &p->page_number) && - ReadParam(m, iter, &p->actual_shrink); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"<ViewHostMsg_DidPrintPage_Params>"); - } -}; - -// Traits for WebPreferences structure to pack/unpack. template <> struct ParamTraits<WebPreferences> { typedef WebPreferences param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, p.standard_font_family); WriteParam(m, p.fixed_font_family); WriteParam(m, p.serif_font_family); @@ -1623,7 +1581,7 @@ struct ParamTraits<WebPreferences> { WriteParam(m, p.user_style_sheet_location); WriteParam(m, p.uses_page_cache); } - static bool Read(const Message* m, void** iter, param_type* p) { + static bool Read(const IPC::Message* m, void** iter, param_type* p) { return ReadParam(m, iter, &p->standard_font_family) && ReadParam(m, iter, &p->fixed_font_family) && @@ -1655,11 +1613,10 @@ struct ParamTraits<WebPreferences> { } }; -// Traits for WebDropData template <> struct ParamTraits<WebDropData> { typedef WebDropData param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, p.url); WriteParam(m, p.url_title); WriteParam(m, p.file_extension); @@ -1670,7 +1627,7 @@ struct ParamTraits<WebDropData> { WriteParam(m, p.file_description_filename); WriteParam(m, p.file_contents); } - static bool Read(const Message* m, void** iter, param_type* p) { + static bool Read(const IPC::Message* m, void** iter, param_type* p) { return ReadParam(m, iter, &p->url) && ReadParam(m, iter, &p->url_title) && @@ -1687,18 +1644,17 @@ struct ParamTraits<WebDropData> { } }; -// Traits for ScreenInfo template <> struct ParamTraits<webkit_glue::ScreenInfo> { typedef webkit_glue::ScreenInfo param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, p.depth); WriteParam(m, p.depth_per_component); WriteParam(m, p.is_monochrome); WriteParam(m, p.rect); WriteParam(m, p.available_rect); } - static bool Read(const Message* m, void** iter, param_type* p) { + static bool Read(const IPC::Message* m, void** iter, param_type* p) { return ReadParam(m, iter, &p->depth) && ReadParam(m, iter, &p->depth_per_component) && @@ -1715,16 +1671,16 @@ template<> struct ParamTraits<ModalDialogEvent> { typedef ModalDialogEvent param_type; #if defined(OS_WIN) - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { WriteParam(m, p.event); } - static bool Read(const Message* m, void** iter, param_type* p) { + static bool Read(const IPC::Message* m, void** iter, param_type* p) { return ReadParam(m, iter, &p->event); } #else - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { } - static bool Read(const Message* m, void** iter, param_type* p) { + static bool Read(const IPC::Message* m, void** iter, param_type* p) { return true; } #endif @@ -1742,11 +1698,11 @@ struct ParamTraits<ModalDialogEvent> { template <> struct ParamTraits<gfx::NativeView> { typedef gfx::NativeView param_type; - static void Write(Message* m, const param_type& p) { + static void Write(IPC::Message* m, const param_type& p) { NOTIMPLEMENTED(); } - static bool Read(const Message* m, void** iter, param_type* p) { + static bool Read(const IPC::Message* m, void** iter, param_type* p) { NOTIMPLEMENTED(); *p = NULL; return true; @@ -1759,6 +1715,8 @@ struct ParamTraits<gfx::NativeView> { #endif // defined(OS_POSIX) -} // namespace IPC + +#define MESSAGES_INTERNAL_FILE "chrome/common/render_messages_internal.h" +#include "chrome/common/ipc_message_macros.h" #endif // CHROME_COMMON_RENDER_MESSAGES_H_ diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index 149dd53..30c23ba 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -25,8 +25,6 @@ #include "webkit/glue/webinputevent.h" #include "webkit/glue/webplugin.h" -void RenderMessagesInit(); - // TODO(mpcomplete): rename ViewMsg and ViewHostMsg to something that makes // more sense with our current design. @@ -34,7 +32,7 @@ void RenderMessagesInit(); // RenderView messages // These are messages sent from the browser to the renderer process. -IPC_BEGIN_MESSAGES(View, 1) +IPC_BEGIN_MESSAGES(View) // Used typically when recovering from a crash. The new rendering process // sets its global "next page id" counter to the given value. IPC_MESSAGE_CONTROL1(ViewMsg_SetNextPageID, @@ -486,7 +484,7 @@ IPC_END_MESSAGES(View) // WebContents messages // These are messages sent from the renderer to the browser process. -IPC_BEGIN_MESSAGES(ViewHost, 2) +IPC_BEGIN_MESSAGES(ViewHost) // Sent by the renderer when it is creating a new window. The browser creates // a tab for it and responds with a ViewMsg_CreatingNew_ACK. If route_id is // MSG_ROUTING_NONE, the view couldn't be created. modal_dialog_event is set @@ -738,9 +736,11 @@ IPC_BEGIN_MESSAGES(ViewHost, 2) IPC_MESSAGE_CONTROL3(ViewHostMsg_PageContents, GURL, int32, std::wstring) // Specifies the URL as the first parameter (a wstring) and thumbnail as - // binary data as the second parameter. Our macros don't handle binary data, - // so this is declared "empty," to be encoded by the caller/receiver. - IPC_MESSAGE_EMPTY(ViewHostMsg_Thumbnail) + // binary data as the second parameter. + IPC_MESSAGE_ROUTED3(ViewHostMsg_Thumbnail, + GURL /* url */, + ThumbnailScore /* score */, + SkBitmap /* bitmap */) // Notification that the url for the favicon of a site has been determined. IPC_MESSAGE_ROUTED2(ViewHostMsg_UpdateFavIconURL, diff --git a/chrome/common/resource_dispatcher_unittest.cc b/chrome/common/resource_dispatcher_unittest.cc index bf9cc51..48cb178 100644 --- a/chrome/common/resource_dispatcher_unittest.cc +++ b/chrome/common/resource_dispatcher_unittest.cc @@ -84,10 +84,10 @@ class ResourceDispatcherTest : public testing::Test, void* iter = NULL; int request_id; - ASSERT_TRUE(IPC::ReadParam(&message_queue_[0], &iter, &request_id)); + ASSERT_TRUE(ReadParam(&message_queue_[0], &iter, &request_id)); ViewHostMsg_Resource_Request request; - ASSERT_TRUE(IPC::ReadParam(&message_queue_[0], &iter, &request)); + ASSERT_TRUE(ReadParam(&message_queue_[0], &iter, &request)); // check values EXPECT_EQ(test_page_url, request.url.spec()); @@ -119,7 +119,7 @@ class ResourceDispatcherTest : public testing::Test, // read the ack message. iter = NULL; int request_ack = -1; - ASSERT_TRUE(IPC::ReadParam(&message_queue_[0], &iter, &request_ack)); + ASSERT_TRUE(ReadParam(&message_queue_[0], &iter, &request_ack)); ASSERT_EQ(request_ack, request_id); diff --git a/chrome/common/security_filter_peer.h b/chrome/common/security_filter_peer.h index ef19b71..ef08426 100644 --- a/chrome/common/security_filter_peer.h +++ b/chrome/common/security_filter_peer.h @@ -6,7 +6,7 @@ #ifndef CHROME_COMMON_SECURITY_FILTER_PEER_H__ #define CHROME_COMMON_SECURITY_FILTER_PEER_H__ -#include "chrome/common/render_messages.h" +#include "chrome/common/filter_policy.h" #include "webkit/glue/resource_loader_bridge.h" // The SecurityFilterPeer is a proxy to a diff --git a/chrome/common/temp_scaffolding_stubs.h b/chrome/common/temp_scaffolding_stubs.h index f3a57e4..350e29c 100644 --- a/chrome/common/temp_scaffolding_stubs.h +++ b/chrome/common/temp_scaffolding_stubs.h @@ -16,6 +16,7 @@ #include "base/logging.h" #include "base/message_loop.h" #include "base/ref_counted.h" +#include "base/gfx/native_widget_types.h" #include "base/gfx/rect.h" #include "chrome/browser/bookmarks/bookmark_service.h" #include "chrome/browser/browser_process.h" @@ -26,12 +27,12 @@ #include "chrome/common/navigation_types.h" #include "chrome/common/notification_service.h" #include "chrome/common/page_transition_types.h" -#include "chrome/common/render_messages.h" #include "googleurl/src/gurl.h" #include "skia/include/SkBitmap.h" #include "webkit/glue/password_form.h" #include "webkit/glue/window_open_disposition.h" +class AutofillForm; class Browser; class BookmarkService; class CommandLine; @@ -60,6 +61,7 @@ class URLRequestContext; class UserScriptMaster; class VisitedLinkMaster; class WebContents; +class WebPreferences; namespace IPC { class Message; @@ -291,11 +293,13 @@ class BrokerServices { class IconManager { }; -struct ViewHostMsg_Resource_Request; +struct ViewHostMsg_DidPrintPage_Params; +struct ViewHostMsg_FrameNavigate_Params; class ResourceDispatcherHost { public: explicit ResourceDispatcherHost(MessageLoop* loop) {} + class Receiver { public: virtual bool Send(IPC::Message* message) = 0; @@ -304,18 +308,22 @@ class ResourceDispatcherHost { void CancelRequestsForRenderView(int, int); void Initialize() { NOTIMPLEMENTED(); } void Shutdown() { NOTIMPLEMENTED(); } + SafeBrowsingService* safe_browsing_service() { NOTIMPLEMENTED(); return const_cast<SafeBrowsingService*>(&safe_browsing_service_); } + DownloadFileManager* download_file_manager() { NOTIMPLEMENTED(); return const_cast<DownloadFileManager*>(&download_file_manager_); } + SaveFileManager* save_file_manager() { NOTIMPLEMENTED(); return const_cast<SaveFileManager*>(&save_file_manager_); } + private: SafeBrowsingService safe_browsing_service_; DownloadFileManager download_file_manager_; @@ -622,7 +630,7 @@ class RenderViewHost : public RenderWidgetHost { return true; } void SetAlternateErrorPageURL(const GURL&) { NOTIMPLEMENTED(); } - void UpdateWebPreferences(WebPreferences) { NOTIMPLEMENTED(); } + void UpdateWebPreferences(const WebPreferences&) { NOTIMPLEMENTED(); } void ReservePageIDRange(int) { NOTIMPLEMENTED(); } }; |