diff options
-rw-r--r-- | chrome/common/common.vcproj | 6 | ||||
-rw-r--r-- | chrome/common/ipc_logging.cc | 3 | ||||
-rw-r--r-- | chrome/common/ipc_logging.h | 8 | ||||
-rw-r--r-- | chrome/common/ipc_message_utils.cc | 239 | ||||
-rw-r--r-- | chrome/common/ipc_message_utils.h | 216 | ||||
-rw-r--r-- | chrome/common/plugin_messages.h | 2 | ||||
-rw-r--r-- | chrome/common/render_messages_internal.h | 4 | ||||
-rw-r--r-- | chrome/test/automation/automation_messages_internal.h | 2 |
8 files changed, 194 insertions, 286 deletions
diff --git a/chrome/common/common.vcproj b/chrome/common/common.vcproj index 5c31f33..d8f2355 100644 --- a/chrome/common/common.vcproj +++ b/chrome/common/common.vcproj @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="Windows-1252"?> <VisualStudioProject ProjectType="Visual C++" - Version="8.00" + Version="8,00" Name="common" ProjectGUID="{899F1280-3441-4D1F-BA04-CCD6208D9146}" RootNamespace="common" @@ -257,10 +257,6 @@ > </File> <File - RelativePath=".\ipc_message_utils.cc" - > - </File> - <File RelativePath=".\ipc_message_utils.h" > </File> diff --git a/chrome/common/ipc_logging.cc b/chrome/common/ipc_logging.cc index 58933e4..34c9274 100644 --- a/chrome/common/ipc_logging.cc +++ b/chrome/common/ipc_logging.cc @@ -27,6 +27,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include <windows.h> + #include "chrome/common/ipc_logging.h" #include "base/command_line.h" @@ -36,7 +38,6 @@ #include "base/time.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/ipc_sync_message.h" -#include "chrome/common/ipc_message_utils.h" #include "chrome/common/render_messages.h" #include "chrome/common/plugin_messages.h" diff --git a/chrome/common/ipc_logging.h b/chrome/common/ipc_logging.h index 7fa2be4..d20a265 100644 --- a/chrome/common/ipc_logging.h +++ b/chrome/common/ipc_logging.h @@ -30,9 +30,13 @@ #ifndef CHROME_COMMON_IPC_LOGGING_H__ #define CHROME_COMMON_IPC_LOGGING_H__ +#include <vector> +#include <windows.h> +#include "base/basictypes.h" #include "base/lock.h" #include "base/message_loop.h" -#include "chrome/common/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. +#include "base/ref_counted.h" +#include "chrome/common/ipc_message_utils.h" #ifdef IPC_MESSAGE_LOG_ENABLED @@ -114,7 +118,7 @@ class Logging : public base::RefCounted<Logging>, static Lock logger_lock_; }; -} // namespace IPC +} #endif // IPC_MESSAGE_LOG_ENABLED diff --git a/chrome/common/ipc_message_utils.cc b/chrome/common/ipc_message_utils.cc deleted file mode 100644 index ad5050c..0000000 --- a/chrome/common/ipc_message_utils.cc +++ /dev/null @@ -1,239 +0,0 @@ -// Copyright 2008, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#include "chrome/common/ipc_message_utils.h" - -#include "base/gfx/rect.h" -#include "googleurl/src/gurl.h" -#include "webkit/glue/dom_operations.h" -#include "webkit/glue/webcursor.h" - -namespace IPC { - -void ParamTraits<GURL>::Write(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) { - std::string s; - if (!m->ReadString(iter, &s)) { - *p = GURL(); - return false; - } - *p = GURL(s); - return true; -} - -void ParamTraits<GURL>::Log(const GURL& p, std::wstring* l) { - l->append(UTF8ToWide(p.spec())); -} - - -void ParamTraits<gfx::Point>::Write(Message* m, const gfx::Point& p) { - m->WriteInt(p.x()); - m->WriteInt(p.y()); -} - -bool ParamTraits<gfx::Point>::Read(const Message* m, void** iter, - gfx::Point* r) { - int x, y; - if (!m->ReadInt(iter, &x) || - !m->ReadInt(iter, &y)) - return false; - r->set_x(x); - r->set_y(y); - return true; -} - -void ParamTraits<gfx::Point>::Log(const gfx::Point& p, std::wstring* l) { - l->append(StringPrintf(L"(%d, %d)", p.x(), p.y())); -} - - - -void ParamTraits<gfx::Rect>::Write(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) { - int x, y, w, h; - if (!m->ReadInt(iter, &x) || - !m->ReadInt(iter, &y) || - !m->ReadInt(iter, &w) || - !m->ReadInt(iter, &h)) - return false; - r->set_x(x); - r->set_y(y); - r->set_width(w); - r->set_height(h); - return true; -} - -void ParamTraits<gfx::Rect>::Log(const gfx::Rect& p, std::wstring* l) { - l->append(StringPrintf(L"(%d, %d, %d, %d)", p.x(), p.y(), p.width(), p.height())); -} - - -void ParamTraits<gfx::Size>::Write(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) { - int w, h; - if (!m->ReadInt(iter, &w) || - !m->ReadInt(iter, &h)) - return false; - r->set_width(w); - r->set_height(h); - return true; -} - -void ParamTraits<gfx::Size>::Log(const gfx::Size& p, std::wstring* l) { - l->append(StringPrintf(L"(%d, %d)", p.width(), p.height())); -} - - -struct WebCursor_Data { - WebCursor::Type cursor_type; - int hotspot_x; - int hotspot_y; - SkBitmap_Data bitmap_info; -}; - -void ParamTraits<WebCursor>::Write(Message* m, const WebCursor& p) { - const SkBitmap& src_bitmap = p.bitmap(); - WebCursor_Data web_cursor_info; - web_cursor_info.cursor_type = p.type(); - web_cursor_info.hotspot_x = p.hotspot_x(); - web_cursor_info.hotspot_y = p.hotspot_y(); - web_cursor_info.bitmap_info.InitSkBitmapDataForTransfer(src_bitmap); - - size_t fixed_data = sizeof(web_cursor_info); - m->WriteData(reinterpret_cast<const char*>(&web_cursor_info), - static_cast<int>(fixed_data)); - size_t pixel_size = src_bitmap.getSize(); - m->WriteBool(pixel_size != 0); - if (pixel_size) { - SkAutoLockPixels src_bitmap_lock(src_bitmap); - m->WriteData(reinterpret_cast<const char*>(src_bitmap.getPixels()), - static_cast<int>(pixel_size)); - } -} - -bool ParamTraits<WebCursor>::Read(const Message* m, void** iter, WebCursor* r) { - const char* fixed_data = NULL; - int fixed_data_size = 0; - if (!m->ReadData(iter, &fixed_data, &fixed_data_size) || - (fixed_data_size <= 0)) { - NOTREACHED(); - return false; - } - DCHECK(fixed_data_size == sizeof(WebCursor_Data)); - - const WebCursor_Data* web_cursor_info = - reinterpret_cast<const WebCursor_Data*>(fixed_data); - - bool variable_data_avail; - if (!m->ReadBool(iter, &variable_data_avail)) { - NOTREACHED(); - return false; - } - - // No variable data indicates that this is not a custom cursor. - if (variable_data_avail) { - const char* variable_data = NULL; - int variable_data_size = 0; - if (!m->ReadData(iter, &variable_data, &variable_data_size) || - variable_data_size <= 0) { - NOTREACHED(); - return false; - } - - SkBitmap dest_bitmap; - web_cursor_info->bitmap_info.InitSkBitmapFromData(&dest_bitmap, - variable_data, - variable_data_size); - r->set_bitmap(dest_bitmap); - r->set_hotspot(web_cursor_info->hotspot_x, web_cursor_info->hotspot_y); - } - - r->set_type(web_cursor_info->cursor_type); - return true; -} - -void ParamTraits<WebCursor>::Log(const WebCursor& p, std::wstring* l) { - l->append(L"<WebCursor>"); -} - - -void ParamTraits<webkit_glue::WebApplicationInfo>::Write( - Message* m, const webkit_glue::WebApplicationInfo& p) { - WriteParam(m, p.title); - WriteParam(m, p.description); - WriteParam(m, p.app_url); - WriteParam(m, p.icons.size()); - for (size_t i = 0; i < p.icons.size(); ++i) { - WriteParam(m, p.icons[i].url); - WriteParam(m, p.icons[i].width); - WriteParam(m, p.icons[i].height); - } -} - -bool ParamTraits<webkit_glue::WebApplicationInfo>::Read( - const Message* m, void** iter, webkit_glue::WebApplicationInfo* r) { - size_t icon_count; - bool result = - ReadParam(m, iter, &r->title) && - ReadParam(m, iter, &r->description) && - ReadParam(m, iter, &r->app_url) && - ReadParam(m, iter, &icon_count); - if (!result) - return false; - for (size_t i = 0; i < icon_count && result; ++i) { - param_type::IconInfo icon_info; - result = - ReadParam(m, iter, &icon_info.url) && - ReadParam(m, iter, &icon_info.width) && - ReadParam(m, iter, &icon_info.height); - r->icons.push_back(icon_info); - } - return result; -} - -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 263a877..7599b4fb 100644 --- a/chrome/common/ipc_message_utils.h +++ b/chrome/common/ipc_message_utils.h @@ -34,28 +34,23 @@ #include <vector> #include <map> +#include "base/basictypes.h" +#include "base/gfx/rect.h" +#include "base/gfx/size.h" +#include "base/logging.h" #include "base/string_util.h" +#include "base/time.h" #include "base/tuple.h" +#include "chrome/common/ipc_message.h" #include "chrome/common/ipc_sync_message.h" #include "chrome/common/thumbnail_score.h" +#include "googleurl/src/gurl.h" #include "skia/include/SkBitmap.h" #include "webkit/glue/cache_manager.h" #include "webkit/glue/console_message_level.h" +#include "webkit/glue/dom_operations.h" #include "webkit/glue/window_open_disposition.h" - -// Forward declarations. -class GURL; -class WebCursor; - -namespace gfx { -class Point; -class Rect; -class Size; -} // namespace gfx - -namespace webkit_glue { -struct WebApplicationInfo; -} // namespace webkit_glue +#include "webkit/glue/webcursor.h" namespace IPC { @@ -561,9 +556,22 @@ 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 Log(const param_type& p, std::wstring* l); + static void Write(Message* m, const param_type& p) { + m->WriteString(p.possibly_invalid_spec()); + // TODO(brettw) bug 684583: Add encoding for query params. + } + static bool Read(const Message* m, void** iter, param_type* p) { + std::string s; + if (!m->ReadString(iter, &s)) { + *p = GURL(); + return false; + } + *p = GURL(s); + return true; + } + static void Log(const param_type& p, std::wstring* l) { + l->append(UTF8ToWide(p.spec())); + } }; // and, a few more useful types... @@ -680,25 +688,70 @@ struct ParamTraits<POINT> { 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 Log(const param_type& p, std::wstring* l); + static void Write(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) { + int x, y; + if (!m->ReadInt(iter, &x) || + !m->ReadInt(iter, &y)) + return false; + r->set_x(x); + r->set_y(y); + return true; + } + static void Log(const param_type& p, std::wstring* l) { + l->append(StringPrintf(L"(%d, %d)", p.x(), p.y())); + } }; 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 Log(const param_type& p, std::wstring* l); + static void Write(Message* m, const param_type& p) { + m->WriteInt(p.x()); + m->WriteInt(p.y()); + m->WriteInt(p.width()); + m->WriteInt(p.height()); + } + static bool Read(const Message* m, void** iter, param_type* r) { + int x, y, w, h; + if (!m->ReadInt(iter, &x) || + !m->ReadInt(iter, &y) || + !m->ReadInt(iter, &w) || + !m->ReadInt(iter, &h)) + return false; + r->set_x(x); + r->set_y(y); + r->set_width(w); + r->set_height(h); + return true; + } + static void Log(const param_type& p, std::wstring* l) { + l->append(StringPrintf(L"(%d, %d, %d, %d)", p.x(), p.y(), p.width(), p.height())); + } }; 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 Log(const param_type& p, std::wstring* l); + static void Write(Message* m, const param_type& p) { + m->WriteInt(p.width()); + m->WriteInt(p.height()); + } + static bool Read(const Message* m, void** iter, param_type* r) { + int w, h; + if (!m->ReadInt(iter, &w) || + !m->ReadInt(iter, &h)) + return false; + r->set_width(w); + r->set_height(h); + return true; + } + static void Log(const param_type& p, std::wstring* l) { + l->append(StringPrintf(L"(%d, %d)", p.width(), p.height())); + } }; template<> @@ -843,12 +896,78 @@ struct ParamTraits<XFORM> { } }; +struct WebCursor_Data { + WebCursor::Type cursor_type; + int hotspot_x; + int hotspot_y; + SkBitmap_Data bitmap_info; +}; + template <> struct ParamTraits<WebCursor> { typedef WebCursor param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); - static void Log(const param_type& p, std::wstring* l); + static void Write(Message* m, const param_type& p) { + const SkBitmap& src_bitmap = p.bitmap(); + WebCursor_Data web_cursor_info; + web_cursor_info.cursor_type = p.type(); + web_cursor_info.hotspot_x = p.hotspot_x(); + web_cursor_info.hotspot_y = p.hotspot_y(); + web_cursor_info.bitmap_info.InitSkBitmapDataForTransfer(src_bitmap); + + size_t fixed_data = sizeof(web_cursor_info); + m->WriteData(reinterpret_cast<const char*>(&web_cursor_info), + static_cast<int>(fixed_data)); + size_t pixel_size = src_bitmap.getSize(); + m->WriteBool(pixel_size != 0); + if (pixel_size) { + SkAutoLockPixels src_bitmap_lock(src_bitmap); + m->WriteData(reinterpret_cast<const char*>(src_bitmap.getPixels()), + static_cast<int>(pixel_size)); + } + } + static bool Read(const Message* m, void** iter, param_type* r) { + const char* fixed_data = NULL; + int fixed_data_size = 0; + if (!m->ReadData(iter, &fixed_data, &fixed_data_size) || + (fixed_data_size <= 0)) { + NOTREACHED(); + return false; + } + DCHECK(fixed_data_size == sizeof(WebCursor_Data)); + + const WebCursor_Data* web_cursor_info = + reinterpret_cast<const WebCursor_Data*>(fixed_data); + + bool variable_data_avail; + if (!m->ReadBool(iter, &variable_data_avail)) { + NOTREACHED(); + return false; + } + + // No variable data indicates that this is not a custom cursor. + if (variable_data_avail) { + const char* variable_data = NULL; + int variable_data_size = 0; + if (!m->ReadData(iter, &variable_data, &variable_data_size) || + variable_data_size <= 0) { + NOTREACHED(); + return false; + } + + SkBitmap dest_bitmap; + web_cursor_info->bitmap_info.InitSkBitmapFromData(&dest_bitmap, + variable_data, + variable_data_size); + r->set_bitmap(dest_bitmap); + r->set_hotspot(web_cursor_info->hotspot_x, web_cursor_info->hotspot_y); + } + + r->set_type(web_cursor_info->cursor_type); + return true; + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"<WebCursor>"); + } }; struct LogData { @@ -1016,9 +1135,39 @@ struct ParamTraits< Tuple5<A, B, C, D, E> > { 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 Log(const param_type& p, std::wstring* l); + static void Write(Message* m, const param_type& p) { + WriteParam(m, p.title); + WriteParam(m, p.description); + WriteParam(m, p.app_url); + WriteParam(m, p.icons.size()); + for (size_t i = 0; i < p.icons.size(); ++i) { + WriteParam(m, p.icons[i].url); + WriteParam(m, p.icons[i].width); + WriteParam(m, p.icons[i].height); + } + } + static bool Read(const Message* m, void** iter, param_type* r) { + size_t icon_count; + bool result = + ReadParam(m, iter, &r->title) && + ReadParam(m, iter, &r->description) && + ReadParam(m, iter, &r->app_url) && + ReadParam(m, iter, &icon_count); + if (!result) + return false; + for (size_t i = 0; i < icon_count && result; ++i) { + param_type::IconInfo icon_info; + result = + ReadParam(m, iter, &icon_info.url) && + ReadParam(m, iter, &icon_info.width) && + ReadParam(m, iter, &icon_info.height); + r->icons.push_back(icon_info); + } + return result; + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"<WebApplicationInfo>"); + } }; @@ -1260,7 +1409,6 @@ class MessageWithReply : public SyncMessage { }; //----------------------------------------------------------------------------- - -} // namespace IPC +} #endif // CHROME_COMMON_IPC_MESSAGE_UTILS_H__ diff --git a/chrome/common/plugin_messages.h b/chrome/common/plugin_messages.h index a06439b..8f9e816 100644 --- a/chrome/common/plugin_messages.h +++ b/chrome/common/plugin_messages.h @@ -38,12 +38,10 @@ #include <string> #include <vector> -#include "base/gfx/rect.h" #include "base/basictypes.h" #include "bindings/npapi.h" #include "chrome/common/ipc_message.h" #include "chrome/common/ipc_message_utils.h" -#include "googleurl/src/gurl.h" void PluginMessagesInit(); diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index a81499e..d52417f 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -35,15 +35,17 @@ #include <vector> #include "base/gfx/rect.h" +#include "base/gfx/size.h" #include "base/shared_memory.h" #include "chrome/common/ipc_message_macros.h" #include "webkit/glue/dom_operations.h" #include "webkit/glue/find_in_page_request.h" +#include "webkit/glue/cache_manager.h" #include "webkit/glue/console_message_level.h" #include "webkit/glue/context_node_types.h" -#include "webkit/glue/webcursor.h" #include "webkit/glue/webplugin.h" #include "webkit/glue/webinputevent.h" +#include "webkit/glue/window_open_disposition.h" void RenderMessagesInit(); diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h index f6efda3..d9136bf 100644 --- a/chrome/test/automation/automation_messages_internal.h +++ b/chrome/test/automation/automation_messages_internal.h @@ -36,11 +36,9 @@ #include <string> #include <vector> -#include "base/gfx/rect.h" #include "chrome/common/ipc_message_macros.h" #include "chrome/common/navigation_types.h" #include "chrome/test/automation/autocomplete_edit_proxy.h" -#include "googleurl/src/gurl.h" // NOTE: All IPC messages have either a routing_id of 0 (for asynchronous // messages), or one that's been assigned by the proxy (for calls |