diff options
61 files changed, 1796 insertions, 1534 deletions
diff --git a/chrome/app/chrome_main_uitest.cc b/chrome/app/chrome_main_uitest.cc index 64b982a..4689d27 100644 --- a/chrome/app/chrome_main_uitest.cc +++ b/chrome/app/chrome_main_uitest.cc @@ -31,7 +31,7 @@ TEST_F(ChromeMainTest, AppTestingInterface) { } // Make sure that the second invocation creates a new window. -TEST_F(ChromeMainTest, DISABLED_SecondLaunch) { +TEST_F(ChromeMainTest, SecondLaunch) { include_testing_id_ = false; use_existing_browser_ = true; diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index f3154a4..a613f78 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -1071,9 +1071,7 @@ void AutomationProvider::GetRedirectsFrom(const IPC::Message& message, IPC::Message* msg = new IPC::Message( message.routing_id(), AutomationMsg_RedirectsFromResponse::ID, IPC::Message::PRIORITY_NORMAL); - msg->WriteBool(false); - std::vector<GURL> empty; - ParamTraits<std::vector<GURL>>::Write(msg, empty); + msg->WriteInt(-1); // Negative string count indicates an error. Send(msg); } @@ -1556,17 +1554,14 @@ void AutomationProvider::OnRedirectQueryComplete( IPC::Message* msg = new IPC::Message(redirect_query_routing_id_, AutomationMsg_RedirectsFromResponse::ID, IPC::Message::PRIORITY_NORMAL); - std::vector<GURL> redirects_gurl; if (success) { - msg->WriteBool(true); + msg->WriteInt(static_cast<int>(redirects->size())); for (size_t i = 0; i < redirects->size(); i++) - redirects_gurl.push_back(redirects->at(i)); + IPC::ParamTraits<GURL>::Write(msg, redirects->at(i)); } else { msg->WriteInt(-1); // Negative count indicates failure. } - ParamTraits<std::vector<GURL>>::Write(msg, redirects_gurl); - Send(msg); redirect_query_ = NULL; } diff --git a/chrome/browser/browser_accessibility.cc b/chrome/browser/browser_accessibility.cc index 8dc85b4..fea5bf2 100644 --- a/chrome/browser/browser_accessibility.cc +++ b/chrome/browser/browser_accessibility.cc @@ -6,7 +6,6 @@ #include "chrome/browser/browser_accessibility_manager.h" #include "chrome/browser/iaccessible_function_ids.h" -#include "chrome/common/render_messages.h" BrowserAccessibility::BrowserAccessibility() : iaccessible_id_(-1), @@ -547,7 +546,7 @@ bool BrowserAccessibility::RequestAccessibilityInfo(int iaccessible_func_id, input2); } -const ViewHostMsg_Accessibility_Out_Params& BrowserAccessibility::response() { +ViewHostMsg_Accessibility_Out_Params BrowserAccessibility::response() { return BrowserAccessibilityManager::GetInstance()->response(); } diff --git a/chrome/browser/browser_accessibility.h b/chrome/browser/browser_accessibility.h index 5f2b40d..5032183 100644 --- a/chrome/browser/browser_accessibility.h +++ b/chrome/browser/browser_accessibility.h @@ -10,9 +10,7 @@ #include <oleacc.h> -#include "base/basictypes.h" - -struct ViewHostMsg_Accessibility_Out_Params; +#include "chrome/common/render_messages.h" //////////////////////////////////////////////////////////////////////////////// // @@ -146,7 +144,7 @@ class ATL_NO_VTABLE BrowserAccessibility LONG input1, LONG input2); // Accessors. - const ViewHostMsg_Accessibility_Out_Params& response(); + ViewHostMsg_Accessibility_Out_Params response(); HWND parent_hwnd(); // Id to uniquely distinguish this instance in the render-side caching, diff --git a/chrome/browser/browser_accessibility_manager.cc b/chrome/browser/browser_accessibility_manager.cc index 69255be..b71ecda 100644 --- a/chrome/browser/browser_accessibility_manager.cc +++ b/chrome/browser/browser_accessibility_manager.cc @@ -116,8 +116,7 @@ bool BrowserAccessibilityManager::RequestAccessibilityInfo( return success; } -const ViewHostMsg_Accessibility_Out_Params& -BrowserAccessibilityManager::response() { +ViewHostMsg_Accessibility_Out_Params BrowserAccessibilityManager::response() { return out_params_; } diff --git a/chrome/browser/browser_accessibility_manager.h b/chrome/browser/browser_accessibility_manager.h index dcda60c..c9c5ad5 100644 --- a/chrome/browser/browser_accessibility_manager.h +++ b/chrome/browser/browser_accessibility_manager.h @@ -15,7 +15,6 @@ class BrowserAccessibility; class RenderProcessHost; class RenderWidgetHost; -struct ViewHostMsg_Accessibility_Out_Params; //////////////////////////////////////////////////////////////////////////////// // @@ -53,7 +52,7 @@ class BrowserAccessibilityManager : public NotificationObserver { LONG input2); // Wrapper function, for cleaner code. - const ViewHostMsg_Accessibility_Out_Params& response(); + ViewHostMsg_Accessibility_Out_Params response(); // Retrieves the parent HWND connected to the provided id. HWND parent_hwnd(int id); diff --git a/chrome/browser/printing/print_view_manager.cc b/chrome/browser/printing/print_view_manager.cc index 4e017e8..bdc9da3 100644 --- a/chrome/browser/printing/print_view_manager.cc +++ b/chrome/browser/printing/print_view_manager.cc @@ -27,6 +27,7 @@ PrintViewManager::PrintViewManager(WebContents& owner) waiting_to_print_(false), inside_inner_message_loop_(false), waiting_to_show_print_dialog_(false) { + memset(&print_params_, 0, sizeof(print_params_)); } PrintViewManager::~PrintViewManager() { @@ -239,6 +240,25 @@ void PrintViewManager::OnNotifyPrintJobEvent( void PrintViewManager::OnNotifyPrintJobInitEvent( const JobEventDetails& event_details) { + ViewMsg_Print_Params old_print_params(print_params_); + + // Backup the print settings relevant to the renderer. + DCHECK_EQ(print_job_->document(), event_details.document()); + event_details.document()->settings().RenderParams(&print_params_); + print_params_.document_cookie = event_details.document()->cookie(); + DCHECK_GT(print_params_.document_cookie, 0); + + // If settings changed + DCHECK(owner_.render_view_host()); + // Equals() doesn't compare the cookie value. + if (owner_.render_view_host() && + owner_.render_view_host()->IsRenderViewLive() && + (!old_print_params.Equals(print_params_) || + !event_details.document()->page_count())) { + // TODO(maruel): Will never happen, this code is about to be deleted. + NOTREACHED(); + } + // Continue even if owner_.render_view_host() is dead because we may already // have buffered all the necessary pages. switch (event_details.type()) { @@ -440,6 +460,7 @@ void PrintViewManager::ReleasePrintJob() { print_job_->DisconnectSource(); // Don't close the worker thread. print_job_ = NULL; + memset(&print_params_, 0, sizeof(print_params_)); } void PrintViewManager::PrintNowInternal() { diff --git a/chrome/browser/printing/print_view_manager.h b/chrome/browser/printing/print_view_manager.h index 3cd0272..405b180 100644 --- a/chrome/browser/printing/print_view_manager.h +++ b/chrome/browser/printing/print_view_manager.h @@ -5,13 +5,12 @@ #ifndef CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ #define CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ -#include "base/ref_counted.h" #include "chrome/browser/printing/printed_pages_source.h" #include "chrome/common/notification_observer.h" +#include "chrome/common/render_messages.h" class RenderViewHost; class WebContents; -struct ViewHostMsg_DidPrintPage_Params; namespace printing { @@ -119,6 +118,9 @@ class PrintViewManager : public NotificationObserver, // print_job_ is initialized. bool OpportunisticallyCreatePrintJob(int cookie); + // Cache the last print settings requested to the renderer. + ViewMsg_Print_Params print_params_; + // Manages the low-level talk to the printer. scoped_refptr<PrintJob> print_job_; diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 1bd7c7f..b6629e9 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -664,7 +664,7 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateTitle, OnMsgUpdateTitle) IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateEncoding, OnMsgUpdateEncoding) IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateTargetURL, OnMsgUpdateTargetURL) - IPC_MESSAGE_HANDLER(ViewHostMsg_Thumbnail, OnMsgThumbnail) + IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_Thumbnail, OnMsgThumbnail(msg)) IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnMsgClose) IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnMsgRequestMove) IPC_MESSAGE_HANDLER(ViewHostMsg_DidStartLoading, OnMsgDidStartLoading) @@ -834,7 +834,7 @@ void RenderViewHost::OnMsgNavigate(const IPC::Message& msg) { // copy when we filter the URLs. void* iter = NULL; ViewHostMsg_FrameNavigate_Params validated_params; - if (!ParamTraits<ViewHostMsg_FrameNavigate_Params>:: + if (!IPC::ParamTraits<ViewHostMsg_FrameNavigate_Params>:: Read(&msg, &iter, &validated_params)) return; @@ -885,9 +885,22 @@ void RenderViewHost::OnMsgUpdateTargetURL(int32 page_id, Send(new ViewMsg_UpdateTargetURL_ACK(routing_id())); } -void RenderViewHost::OnMsgThumbnail(const GURL& url, - const ThumbnailScore& score, - const SkBitmap& bitmap) { +void RenderViewHost::OnMsgThumbnail(const IPC::Message& msg) { + // crack the message + void* iter = NULL; + GURL url; + if (!IPC::ParamTraits<GURL>::Read(&msg, &iter, &url)) + return; + + ThumbnailScore score; + if (!IPC::ParamTraits<ThumbnailScore>::Read(&msg, &iter, &score)) + return; + + // thumbnail data + SkBitmap bitmap; + if (!IPC::ParamTraits<SkBitmap>::Read(&msg, &iter, &bitmap)) + return; + delegate_->UpdateThumbnail(url, bitmap, score); } diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index 49d1949..19bb424 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -436,9 +436,7 @@ class RenderViewHost : public RenderWidgetHost { void OnMsgUpdateTitle(int32 page_id, const std::wstring& title); void OnMsgUpdateEncoding(const std::wstring& encoding); void OnMsgUpdateTargetURL(int32 page_id, const GURL& url); - void OnMsgThumbnail(const GURL& url, - const ThumbnailScore& score, - const SkBitmap& bitmap); + void OnMsgThumbnail(const IPC::Message& msg); void OnMsgClose(); void OnMsgRequestMove(const gfx::Rect& pos); void OnMsgDidRedirectProvisionalLoad(int32 page_id, diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h index 709fde5..5a39b91 100644 --- a/chrome/browser/renderer_host/render_view_host_delegate.h +++ b/chrome/browser/renderer_host/render_view_host_delegate.h @@ -10,9 +10,9 @@ #include "base/basictypes.h" #include "chrome/browser/autofill_manager.h" +#include "chrome/common/render_messages.h" #include "net/base/load_states.h" #include "webkit/glue/webpreferences.h" -#include "webkit/glue/window_open_disposition.h" class NavigationEntry; class Profile; @@ -20,12 +20,8 @@ class RenderProcessHost; class RenderViewHost; class SkBitmap; class WebContents; -class WebKeyboardEvent; -struct ThumbnailScore; -struct ViewHostMsg_ContextMenu_Params; -struct ViewHostMsg_DidPrintPage_Params; -struct ViewHostMsg_FrameNavigate_Params; struct WebDropData; +enum WindowOpenDisposition; namespace base { class WaitableEvent; @@ -39,10 +35,6 @@ namespace gfx { class Rect; } -namespace webkit_glue { -struct WebApplicationInfo; -} - // // RenderViewHostDelegate // diff --git a/chrome/browser/renderer_host/render_widget_host.cc b/chrome/browser/renderer_host/render_widget_host.cc index a6d289b..50a6ef3 100644 --- a/chrome/browser/renderer_host/render_widget_host.cc +++ b/chrome/browser/renderer_host/render_widget_host.cc @@ -11,7 +11,6 @@ #include "chrome/browser/renderer_host/render_widget_helper.h" #include "chrome/browser/renderer_host/render_widget_host_view.h" #include "chrome/common/notification_service.h" -#include "chrome/common/render_messages.h" #include "chrome/views/view.h" #include "webkit/glue/webcursor.h" #include "webkit/glue/webinputevent.h" @@ -550,7 +549,7 @@ void RenderWidgetHost::OnMsgSetCursor(const WebCursor& cursor) { view_->UpdateCursor(cursor); } -void RenderWidgetHost::OnMsgImeUpdateStatus(int control, +void RenderWidgetHost::OnMsgImeUpdateStatus(ViewHostMsg_ImeControl control, const gfx::Rect& caret_rect) { if (view_) { view_->IMEUpdateStatus(control, caret_rect); diff --git a/chrome/browser/renderer_host/render_widget_host.h b/chrome/browser/renderer_host/render_widget_host.h index 06b9fb0..08f20f0 100644 --- a/chrome/browser/renderer_host/render_widget_host.h +++ b/chrome/browser/renderer_host/render_widget_host.h @@ -11,6 +11,7 @@ #include "base/timer.h" #include "chrome/common/bitmap_wire_data.h" #include "chrome/common/ipc_channel.h" +#include "chrome/common/render_messages.h" #include "testing/gtest/include/gtest/gtest_prod.h" namespace gfx { @@ -254,9 +255,8 @@ class RenderWidgetHost : public IPC::Channel::Listener { void OnMsgFocus(); void OnMsgBlur(); void OnMsgSetCursor(const WebCursor& cursor); - // Using int instead of ViewHostMsg_ImeControl for control's type to avoid - // having to bring in render_messages.h in a header file. - void OnMsgImeUpdateStatus(int control, const gfx::Rect& caret_rect); + void OnMsgImeUpdateStatus(ViewHostMsg_ImeControl control, + const gfx::Rect& caret_rect); // Paints the given bitmap to the current backing store at the given location. void PaintBackingStoreRect(BitmapWireData bitmap, diff --git a/chrome/browser/renderer_host/render_widget_host_view.h b/chrome/browser/renderer_host/render_widget_host_view.h index b2edf58..76316b4 100644 --- a/chrome/browser/renderer_host/render_widget_host_view.h +++ b/chrome/browser/renderer_host/render_widget_host_view.h @@ -7,7 +7,7 @@ #include "base/gfx/native_widget_types.h" #include "base/shared_memory.h" -#include "webkit/glue/webplugin.h" +#include "chrome/common/render_messages.h" namespace gfx { class Rect; @@ -20,6 +20,7 @@ class Message; class RenderProcessHost; class RenderWidgetHost; class WebCursor; + // RenderWidgetHostView is an interface implemented by an object that acts as // the "View" portion of a RenderWidgetHost. The RenderWidgetHost and its // associated RenderProcessHost own the "Model" in this case which is the @@ -84,7 +85,8 @@ class RenderWidgetHostView { virtual void SetIsLoading(bool is_loading) = 0; // Enable or disable IME for the view. - virtual void IMEUpdateStatus(int control, const gfx::Rect& caret_rect) = 0; + virtual void IMEUpdateStatus(ViewHostMsg_ImeControl control, + const gfx::Rect& caret_rect) = 0; // Informs the view that a portion of the widget's backing store was painted. // The view should copy the given rect from the backing store of the render diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.cc b/chrome/browser/renderer_host/render_widget_host_view_win.cc index 1d86045..2c19e7e 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_win.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_win.cc @@ -271,7 +271,7 @@ void RenderWidgetHostViewWin::SetIsLoading(bool is_loading) { UpdateCursorIfOverSelf(); } -void RenderWidgetHostViewWin::IMEUpdateStatus(int control, +void RenderWidgetHostViewWin::IMEUpdateStatus(ViewHostMsg_ImeControl control, const gfx::Rect& caret_rect) { if (control == IME_DISABLE) { ime_input_.DisableIME(m_hWnd); diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.h b/chrome/browser/renderer_host/render_widget_host_view_win.h index c4d08d3..0c8e6c3 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_win.h +++ b/chrome/browser/renderer_host/render_widget_host_view_win.h @@ -136,7 +136,8 @@ class RenderWidgetHostViewWin : virtual void UpdateCursor(const WebCursor& cursor); virtual void UpdateCursorIfOverSelf(); virtual void SetIsLoading(bool is_loading); - virtual void IMEUpdateStatus(int control, const gfx::Rect& caret_rect); + virtual void IMEUpdateStatus(ViewHostMsg_ImeControl control, + const gfx::Rect& caret_rect); virtual void DidPaintRect(const gfx::Rect& rect); virtual void DidScrollRect(const gfx::Rect& rect, int dx, int dy); virtual void RendererGone(); diff --git a/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc b/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc index f09a5af..ae8ae7d 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc @@ -173,11 +173,11 @@ void CheckSuccessfulRequest(const std::vector<IPC::Message>& messages, void* iter = NULL; int request_id; - ASSERT_TRUE(ReadParam(&messages[1], &iter, &request_id)); + ASSERT_TRUE(IPC::ReadParam(&messages[1], &iter, &request_id)); base::SharedMemoryHandle shm_handle; - ASSERT_TRUE(ReadParam(&messages[1], &iter, &shm_handle)); + ASSERT_TRUE(IPC::ReadParam(&messages[1], &iter, &shm_handle)); int data_len; - ASSERT_TRUE(ReadParam(&messages[1], &iter, &data_len)); + ASSERT_TRUE(IPC::ReadParam(&messages[1], &iter, &data_len)); ASSERT_EQ(reference_data.size(), data_len); base::SharedMemory shared_mem(shm_handle, true); // read only diff --git a/chrome/browser/renderer_host/test_render_view_host.h b/chrome/browser/renderer_host/test_render_view_host.h index b74a56f..8618ea9 100644 --- a/chrome/browser/renderer_host/test_render_view_host.h +++ b/chrome/browser/renderer_host/test_render_view_host.h @@ -54,7 +54,8 @@ class TestRenderWidgetHostView : public RenderWidgetHostView { virtual void SetIsLoading(bool is_loading) {} virtual void UpdateCursor(const WebCursor& cursor) {} virtual void UpdateCursorIfOverSelf() {} - virtual void IMEUpdateStatus(int control, const gfx::Rect& caret_rect) {} + virtual void IMEUpdateStatus(ViewHostMsg_ImeControl control, + const gfx::Rect& caret_rect) {} virtual void DidPaintRect(const gfx::Rect& rect) {} virtual void DidScrollRect(const gfx::Rect& rect, int dx, int dy) {} virtual void RendererGone() {} diff --git a/chrome/browser/resource_message_filter.cc b/chrome/browser/resource_message_filter.cc index 89c2bf8..02e6230 100644 --- a/chrome/browser/resource_message_filter.cc +++ b/chrome/browser/resource_message_filter.cc @@ -24,6 +24,7 @@ #include "chrome/common/notification_service.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" +#include "chrome/common/ipc_message_macros.h" #include "chrome/common/render_messages.h" #include "net/base/cookie_monster.h" #include "net/base/mime_util.h" @@ -232,7 +233,7 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& message) { void ResourceMessageFilter::OnReceiveContextMenuMsg(const IPC::Message& msg) { void* iter = NULL; ViewHostMsg_ContextMenu_Params params; - if (!ParamTraits<ViewHostMsg_ContextMenu_Params>:: + if (!IPC::ParamTraits<ViewHostMsg_ContextMenu_Params>:: Read(&msg, &iter, ¶ms)) return; diff --git a/chrome/browser/resource_message_filter.h b/chrome/browser/resource_message_filter.h index af9d604..43034b6 100644 --- a/chrome/browser/resource_message_filter.h +++ b/chrome/browser/resource_message_filter.h @@ -28,7 +28,6 @@ class ClipboardService; class Profile; class RenderWidgetHelper; class SpellChecker; -struct ViewHostMsg_Resource_Request; struct WebPluginInfo; namespace printing { diff --git a/chrome/browser/ssl/ssl_uitest.cc b/chrome/browser/ssl/ssl_uitest.cc index f31d8f2..1819010 100644 --- a/chrome/browser/ssl/ssl_uitest.cc +++ b/chrome/browser/ssl/ssl_uitest.cc @@ -7,7 +7,6 @@ #include <string> -#include "chrome/common/filter_policy.h" #include "chrome/common/pref_names.h" #include "chrome/test/automation/browser_proxy.h" #include "chrome/test/automation/tab_proxy.h" diff --git a/chrome/browser/tab_contents/interstitial_page.h b/chrome/browser/tab_contents/interstitial_page.h index 5d39546..eb18b60 100644 --- a/chrome/browser/tab_contents/interstitial_page.h +++ b/chrome/browser/tab_contents/interstitial_page.h @@ -7,7 +7,6 @@ #include <string> -#include "base/gfx/size.h" #include "chrome/browser/renderer_host/render_view_host_delegate.h" #include "chrome/common/notification_registrar.h" #include "googleurl/src/gurl.h" diff --git a/chrome/browser/tab_contents/ipc_status_view.cc b/chrome/browser/tab_contents/ipc_status_view.cc index a317aac..cd85ee0 100644 --- a/chrome/browser/tab_contents/ipc_status_view.cc +++ b/chrome/browser/tab_contents/ipc_status_view.cc @@ -2,13 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Need to include this before any other file because it defines -// IPC_MESSAGE_LOG_ENABLED. -#include "chrome/common/ipc_message.h" - -#ifdef IPC_MESSAGE_LOG_ENABLED -#define IPC_MESSAGE_MACROS_LOG_ENABLED - #include "chrome/browser/tab_contents/ipc_status_view.h" #include <stdio.h> @@ -24,6 +17,8 @@ #include "chrome/common/pref_service.h" #include "chrome/common/render_messages.h" +#ifdef IPC_MESSAGE_LOG_ENABLED + using base::Time; namespace { @@ -44,6 +39,19 @@ enum { kParamsColumn, }; +// This class ensures that we have a link dependency on render_messages.cc and +// plugin_messages.cc, and at the same time sets up the message logger function +// mappings. +class RegisterLoggerFuncs { + public: + RegisterLoggerFuncs() { + RenderMessagesInit(); + PluginMessagesInit(); + } +}; + +RegisterLoggerFuncs g_register_logger_funcs; + } // namespace IPCStatusView* IPCStatusView::current_; @@ -62,16 +70,7 @@ IPCStatusView::IPCStatusView() plugin_process_ = NULL; plugin_process_host_ = NULL; - IPC::Logging* log = IPC::Logging::current(); - log->RegisterMessageLogger(ViewStart, ViewMsgLog); - log->RegisterMessageLogger(ViewHostStart, ViewHostMsgLog); - log->RegisterMessageLogger(PluginProcessStart, PluginProcessMsgLog); - log->RegisterMessageLogger(PluginProcessHostStart, PluginProcessHostMsgLog); - log->RegisterMessageLogger(PluginStart, PluginMsgLog); - log->RegisterMessageLogger(PluginHostStart, PluginHostMsgLog); - log->RegisterMessageLogger(NPObjectStart, NPObjectMsgLog); - - log->SetConsumer(this); + IPC::Logging::current()->SetConsumer(this); } IPCStatusView::~IPCStatusView() { diff --git a/chrome/browser/tab_contents/web_contents.cc b/chrome/browser/tab_contents/web_contents.cc index f6a8666..849ba2a 100644 --- a/chrome/browser/tab_contents/web_contents.cc +++ b/chrome/browser/tab_contents/web_contents.cc @@ -24,7 +24,6 @@ #include "chrome/common/notification_service.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" -#include "chrome/common/render_messages.h" #include "net/base/mime_util.h" #include "net/base/net_errors.h" #include "net/base/registry_controlled_domain.h" diff --git a/chrome/chrome.xcodeproj/project.pbxproj b/chrome/chrome.xcodeproj/project.pbxproj index 9be3cd6..82dbf46 100644 --- a/chrome/chrome.xcodeproj/project.pbxproj +++ b/chrome/chrome.xcodeproj/project.pbxproj @@ -253,6 +253,7 @@ B562E2FC0F05845100FB1A4F /* property_bag_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = B562E2F40F05843C00FB1A4F /* property_bag_unittest.cc */; }; B56E281B0F057F2800447108 /* message_router.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BFBD10E9D4C9F009A6919 /* message_router.cc */; }; B5DBEA900EFC60E200C95176 /* ipc_channel_proxy.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BFBAB0E9D4C9F009A6919 /* ipc_channel_proxy.cc */; }; + B5E98B140F0574A8000A37D6 /* render_messages.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BFBF10E9D4C9F009A6919 /* render_messages.cc */; }; B5FCDE5C0F269E9B0099BFAF /* visitedlink_master.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BF95F0E9D4839009A6919 /* visitedlink_master.cc */; }; B5FDC0580EE488E500BEC6E6 /* ipc_channel_posix.cc in Sources */ = {isa = PBXBuildFile; fileRef = B5FDC0570EE488E500BEC6E6 /* ipc_channel_posix.cc */; }; B5FDC1CA0EE48ADB00BEC6E6 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D7BFDD10E9D5295009A6919 /* CoreFoundation.framework */; }; @@ -1778,6 +1779,7 @@ 4D7BFBEE0E9D4C9F009A6919 /* process_watcher.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = process_watcher.cc; sourceTree = "<group>"; }; 4D7BFBEF0E9D4C9F009A6919 /* process_watcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = process_watcher.h; sourceTree = "<group>"; }; 4D7BFBF00E9D4C9F009A6919 /* ref_counted_util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ref_counted_util.h; sourceTree = "<group>"; }; + 4D7BFBF10E9D4C9F009A6919 /* render_messages.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = render_messages.cc; sourceTree = "<group>"; }; 4D7BFBF20E9D4C9F009A6919 /* render_messages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = render_messages.h; sourceTree = "<group>"; }; 4D7BFBF30E9D4C9F009A6919 /* render_messages_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = render_messages_internal.h; sourceTree = "<group>"; }; 4D7BFBF40E9D4C9F009A6919 /* resource_bundle.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = resource_bundle.cc; sourceTree = "<group>"; }; @@ -3064,6 +3066,7 @@ B562E2F50F05843C00FB1A4F /* property_bag.h */, B562E2F60F05843C00FB1A4F /* property_bag.cc */, 4D7BFBF00E9D4C9F009A6919 /* ref_counted_util.h */, + 4D7BFBF10E9D4C9F009A6919 /* render_messages.cc */, 4D7BFBF20E9D4C9F009A6919 /* render_messages.h */, 4D7BFBF30E9D4C9F009A6919 /* render_messages_internal.h */, 4D7BFBF40E9D4C9F009A6919 /* resource_bundle.cc */, @@ -4715,6 +4718,7 @@ 4D7BFC7A0E9D4D2B009A6919 /* pref_names.cc in Sources */, E45076850F1530CD003BE099 /* pref_service.cc in Sources */, B562E2F80F05843C00FB1A4F /* property_bag.cc in Sources */, + B5E98B140F0574A8000A37D6 /* render_messages.cc in Sources */, E45076A90F153619003BE099 /* resource_dispatcher.cc in Sources */, E43A78750F17A95400ABD5D1 /* sandbox_init_wrapper.cc in Sources */, E40CC5FE0F2E35A800708647 /* security_filter_peer.cc in Sources */, diff --git a/chrome/common/common.scons b/chrome/common/common.scons index 7e5cc14..ae4c0bf 100644 --- a/chrome/common/common.scons +++ b/chrome/common/common.scons @@ -94,8 +94,10 @@ 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', ]), @@ -227,6 +229,7 @@ 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 c3986d2b..c0f6af6 100644 --- a/chrome/common/common.vcproj +++ b/chrome/common/common.vcproj @@ -285,6 +285,10 @@ > </File> <File + RelativePath=".\plugin_messages.cc" + > + </File> + <File RelativePath=".\plugin_messages.h" > </File> @@ -293,6 +297,10 @@ > </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 6e67844..cbd2bd3 100644 --- a/chrome/common/ipc_fuzzing_tests.cc +++ b/chrome/common/ipc_fuzzing_tests.cc @@ -96,9 +96,10 @@ TEST(IPCMessageIntegrity, ReadVectorTooLarge2) { EXPECT_FALSE(ReadParam(&m, &iter, &vec)); } -// 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" +// 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 #include "chrome/common/ipc_message_macros.h" enum IPCMessageIds { diff --git a/chrome/common/ipc_logging.cc b/chrome/common/ipc_logging.cc index 2946093..ec2fe82 100644 --- a/chrome/common/ipc_logging.cc +++ b/chrome/common/ipc_logging.cc @@ -41,8 +41,6 @@ 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; @@ -90,18 +88,8 @@ 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 current()->GetEventName(GetCurrentProcessId(), enabled); + return Logging::current()->GetEventName(GetCurrentProcessId(), enabled); } std::wstring Logging::GetEventName(int browser_pid, bool enabled) { @@ -200,12 +188,24 @@ 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 (current()->log_function_mapping_[message_class] != NULL) { - current()->log_function_mapping_[message_class](type, name, message, params); + if (g_log_function_mapping[message_class] != NULL) { + g_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 bf49595..567ba84 100644 --- a/chrome/common/ipc_logging.h +++ b/chrome/common/ipc_logging.h @@ -12,7 +12,6 @@ #include "base/lock.h" #include "base/object_watcher.h" #include "base/singleton.h" -#include "chrome/common/ipc_message_utils.h" class MessageLoop; @@ -28,7 +27,7 @@ class Logging : public base::ObjectWatcher::Delegate { // Implemented by consumers of log messages. class Consumer { public: - virtual void Log(const LogData& data) = 0; + virtual void Log(const IPC::LogData& data) = 0; }; void SetConsumer(Consumer* consumer); @@ -42,7 +41,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(Message::Sender* sender); + void SetIPCSender(IPC::Message::Sender* sender); // Called in the browser process when logging data from a child process is // received. @@ -67,14 +66,8 @@ 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<Logging>; + friend struct DefaultSingletonTraits<IPC::Logging>; Logging(); std::wstring GetEventName(int browser_pid, bool enabled); @@ -92,12 +85,10 @@ class Logging : public base::ObjectWatcher::Delegate { std::vector<LogData> queued_logs_; bool queue_invoke_later_pending_; - Message::Sender* sender_; + IPC::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 49c15b5..e724e2e 100644 --- a/chrome/common/ipc_message_macros.h +++ b/chrome/common/ipc_message_macros.h @@ -41,33 +41,6 @@ #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 @@ -84,6 +57,7 @@ #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 @@ -120,7 +94,6 @@ #undef IPC_SYNC_MESSAGE_ROUTED4_0 #undef IPC_SYNC_MESSAGE_ROUTED4_1 - #if defined(IPC_MESSAGE_MACROS_ENUMS) #undef IPC_MESSAGE_MACROS_ENUMS @@ -129,11 +102,10 @@ // 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) \ +#define IPC_BEGIN_MESSAGES(label, start) \ enum label##MsgType { \ - label##Start = label##MsgStart << 12, \ - label##PreStart = (label##MsgStart << 12) - 1, // Do this so that automation messages keep the same id as before + label##Start = start << 12, \ + label##PreStart = (start << 12) - 1, // Do this so that automation messages keep the same id as before #define IPC_END_MESSAGES(label) \ label##End \ @@ -178,6 +150,9 @@ #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, @@ -366,7 +341,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) \ +#define IPC_BEGIN_MESSAGES(label, start) \ void label##MsgLog(uint16 type, std::wstring* name, const IPC::Message* msg, std::wstring* params) { \ switch (type) { @@ -424,6 +399,9 @@ 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) @@ -532,7 +510,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) +#define IPC_BEGIN_MESSAGES(label, start) #define IPC_END_MESSAGES(label) #define IPC_MESSAGE_CONTROL0(msg_class) \ @@ -677,6 +655,14 @@ 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 d6ff045..8596185 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); - ParamTraits<GURL>::Write(&msg, input); + IPC::ParamTraits<GURL>::Write(&msg, input); GURL output; void* iter = NULL; - EXPECT_TRUE(ParamTraits<GURL>::Read(&msg, &iter, &output)); + EXPECT_TRUE(IPC::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(ParamTraits<GURL>::Read(&msg, &iter, &output)); + EXPECT_FALSE(IPC::ParamTraits<GURL>::Read(&msg, &iter, &output)); } diff --git a/chrome/common/ipc_message_utils.cc b/chrome/common/ipc_message_utils.cc index cf82dc8..2512ff4 100644 --- a/chrome/common/ipc_message_utils.cc +++ b/chrome/common/ipc_message_utils.cc @@ -9,6 +9,8 @@ #include "SkBitmap.h" #include "webkit/glue/dom_operations.h" +namespace IPC { + namespace { struct SkBitmap_Data { @@ -44,7 +46,7 @@ struct SkBitmap_Data { } // namespace -void ParamTraits<SkBitmap>::Write(IPC::Message* m, const SkBitmap& p) { +void ParamTraits<SkBitmap>::Write(Message* m, const SkBitmap& p) { size_t fixed_size = sizeof(SkBitmap_Data); SkBitmap_Data bmp_data; bmp_data.InitSkBitmapDataForTransfer(p); @@ -56,7 +58,7 @@ void ParamTraits<SkBitmap>::Write(IPC::Message* m, const SkBitmap& p) { static_cast<int>(pixel_size)); } -bool ParamTraits<SkBitmap>::Read(const IPC::Message* m, void** iter, SkBitmap* r) { +bool ParamTraits<SkBitmap>::Read(const Message* m, void** iter, SkBitmap* r) { const char* fixed_data; int fixed_data_size = 0; if (!m->ReadData(iter, &fixed_data, &fixed_data_size) || @@ -85,12 +87,12 @@ void ParamTraits<SkBitmap>::Log(const SkBitmap& p, std::wstring* l) { } -void ParamTraits<GURL>::Write(IPC::Message* m, const GURL& p) { +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 IPC::Message* m, void** iter, GURL* p) { +bool ParamTraits<GURL>::Read(const Message* m, void** iter, GURL* p) { std::string s; if (!m->ReadString(iter, &s)) { *p = GURL(); @@ -105,12 +107,12 @@ void ParamTraits<GURL>::Log(const GURL& p, std::wstring* l) { } -void ParamTraits<gfx::Point>::Write(IPC::Message* m, const gfx::Point& p) { +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 IPC::Message* m, void** iter, +bool ParamTraits<gfx::Point>::Read(const Message* m, void** iter, gfx::Point* r) { int x, y; if (!m->ReadInt(iter, &x) || @@ -126,14 +128,14 @@ void ParamTraits<gfx::Point>::Log(const gfx::Point& p, std::wstring* l) { } -void ParamTraits<gfx::Rect>::Write(IPC::Message* m, const gfx::Rect& p) { +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 IPC::Message* m, void** iter, gfx::Rect* r) { +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) || @@ -153,12 +155,12 @@ void ParamTraits<gfx::Rect>::Log(const gfx::Rect& p, std::wstring* l) { } -void ParamTraits<gfx::Size>::Write(IPC::Message* m, const gfx::Size& p) { +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 IPC::Message* m, void** iter, gfx::Size* r) { +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)) @@ -173,7 +175,7 @@ void ParamTraits<gfx::Size>::Log(const gfx::Size& p, std::wstring* l) { } void ParamTraits<webkit_glue::WebApplicationInfo>::Write( - IPC::Message* m, const webkit_glue::WebApplicationInfo& p) { + Message* m, const webkit_glue::WebApplicationInfo& p) { WriteParam(m, p.title); WriteParam(m, p.description); WriteParam(m, p.app_url); @@ -186,7 +188,7 @@ void ParamTraits<webkit_glue::WebApplicationInfo>::Write( } bool ParamTraits<webkit_glue::WebApplicationInfo>::Read( - const IPC::Message* m, void** iter, webkit_glue::WebApplicationInfo* r) { + const Message* m, void** iter, webkit_glue::WebApplicationInfo* r) { size_t icon_count; bool result = ReadParam(m, iter, &r->title) && @@ -210,3 +212,6 @@ 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 35146ee..39bb231 100644 --- a/chrome/common/ipc_message_utils.h +++ b/chrome/common/ipc_message_utils.h @@ -34,30 +34,57 @@ namespace webkit_glue { struct WebApplicationInfo; } // namespace webkit_glue -// 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 -}; +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. -COMPILE_ASSERT(LastMsgIndex <= 16, need_to_update_IPC_MESSAGE_MACRO); +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_; +}; //----------------------------------------------------------------------------- // ParamTraits specializations, etc. @@ -65,12 +92,12 @@ COMPILE_ASSERT(LastMsgIndex <= 16, need_to_update_IPC_MESSAGE_MACRO); template <class P> struct ParamTraits {}; template <class P> -static inline void WriteParam(IPC::Message* m, const P& p) { +static inline void WriteParam(Message* m, const P& p) { ParamTraits<P>::Write(m, p); } template <class P> -static inline bool ReadParam(const IPC::Message* m, void** iter, P* p) { +static inline bool ReadParam(const Message* m, void** iter, P* p) { return ParamTraits<P>::Read(m, iter, p); } @@ -82,10 +109,10 @@ static inline void LogParam(const P& p, std::wstring* l) { template <> struct ParamTraits<bool> { typedef bool param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { m->WriteBool(p); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { return m->ReadBool(iter, r); } static void Log(const param_type& p, std::wstring* l) { @@ -96,10 +123,10 @@ struct ParamTraits<bool> { template <> struct ParamTraits<int> { typedef int param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { m->WriteInt(p); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { return m->ReadInt(iter, r); } static void Log(const param_type& p, std::wstring* l) { @@ -110,10 +137,10 @@ struct ParamTraits<int> { template <> struct ParamTraits<long> { typedef long param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { m->WriteLong(p); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { return m->ReadLong(iter, r); } static void Log(const param_type& p, std::wstring* l) { @@ -124,10 +151,10 @@ struct ParamTraits<long> { template <> struct ParamTraits<size_t> { typedef size_t param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { m->WriteSize(p); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { return m->ReadSize(iter, r); } static void Log(const param_type& p, std::wstring* l) { @@ -141,10 +168,10 @@ struct ParamTraits<size_t> { template <> struct ParamTraits<uint32> { typedef uint32 param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { m->WriteUInt32(p); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { return m->ReadUInt32(iter, r); } static void Log(const param_type& p, std::wstring* l) { @@ -156,10 +183,10 @@ struct ParamTraits<uint32> { template <> struct ParamTraits<int64> { typedef int64 param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { m->WriteInt64(p); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { return m->ReadInt64(iter, r); } static void Log(const param_type& p, std::wstring* l) { @@ -170,10 +197,10 @@ struct ParamTraits<int64> { template <> struct ParamTraits<uint64> { typedef uint64 param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { m->WriteInt64(static_cast<int64>(p)); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const 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) { @@ -184,10 +211,10 @@ struct ParamTraits<uint64> { template <> struct ParamTraits<double> { typedef double param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { m->WriteData(reinterpret_cast<const char*>(&p), sizeof(param_type)); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + 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); @@ -208,10 +235,10 @@ struct ParamTraits<double> { template <> struct ParamTraits<wchar_t> { typedef wchar_t param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { m->WriteData(reinterpret_cast<const char*>(&p), sizeof(param_type)); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + 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); @@ -232,10 +259,10 @@ struct ParamTraits<wchar_t> { template <> struct ParamTraits<base::Time> { typedef base::Time param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { ParamTraits<int64>::Write(m, p.ToInternalValue()); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { int64 value; if (!ParamTraits<int64>::Read(m, iter, &value)) return false; @@ -251,10 +278,10 @@ struct ParamTraits<base::Time> { template <> struct ParamTraits<LOGFONT> { typedef LOGFONT param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { m->WriteData(reinterpret_cast<const char*>(&p), sizeof(LOGFONT)); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + 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); @@ -275,10 +302,10 @@ struct ParamTraits<LOGFONT> { template <> struct ParamTraits<MSG> { typedef MSG param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { m->WriteData(reinterpret_cast<const char*>(&p), sizeof(MSG)); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + 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); @@ -297,11 +324,11 @@ struct ParamTraits<MSG> { template <> struct ParamTraits<SkBitmap> { typedef SkBitmap param_type; - static void Write(IPC::Message* m, const param_type& p); + static void Write(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 IPC::Message* m, void** iter, param_type* r); + static bool Read(const Message* m, void** iter, param_type* r); static void Log(const param_type& p, std::wstring* l); }; @@ -309,10 +336,10 @@ struct ParamTraits<SkBitmap> { template <> struct ParamTraits<std::string> { typedef std::string param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { m->WriteString(p); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { return m->ReadString(iter, r); } static void Log(const param_type& p, std::wstring* l) { @@ -323,7 +350,7 @@ struct ParamTraits<std::string> { template <> struct ParamTraits<std::vector<unsigned char> > { typedef std::vector<unsigned char> param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { if (p.size() == 0) { m->WriteData(NULL, 0); } else { @@ -331,7 +358,7 @@ struct ParamTraits<std::vector<unsigned char> > { static_cast<int>(p.size())); } } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { const char *data; int data_size = 0; if (!m->ReadData(iter, &data, &data_size) || data_size < 0) @@ -350,14 +377,14 @@ struct ParamTraits<std::vector<unsigned char> > { template <> struct ParamTraits<std::vector<char> > { typedef std::vector<char> param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(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 IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { const char *data; int data_size = 0; if (!m->ReadData(iter, &data, &data_size) || data_size < 0) @@ -376,12 +403,12 @@ struct ParamTraits<std::vector<char> > { template <class P> struct ParamTraits<std::vector<P> > { typedef std::vector<P> param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(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 IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { int size; if (!m->ReadLength(iter, &size)) return false; @@ -415,7 +442,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(IPC::Message* m, const param_type& p) { + static void Write(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) { @@ -423,7 +450,7 @@ struct ParamTraits<std::map<K, V> > { WriteParam(m, iter->second); } } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { int size; if (!ReadParam(m, iter, &size) || size < 0) return false; @@ -445,10 +472,10 @@ struct ParamTraits<std::map<K, V> > { template <> struct ParamTraits<std::wstring> { typedef std::wstring param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { m->WriteWString(p); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { return m->ReadWString(iter, r); } static void Log(const param_type& p, std::wstring* l) { @@ -459,8 +486,8 @@ struct ParamTraits<std::wstring> { template <> struct ParamTraits<GURL> { typedef GURL param_type; - static void Write(IPC::Message* m, const param_type& p); - static bool Read(const IPC::Message* m, void** iter, param_type* p); + 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); }; @@ -469,10 +496,10 @@ struct ParamTraits<GURL> { template <> struct ParamTraits<HANDLE> { typedef HANDLE param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { m->WriteIntPtr(reinterpret_cast<intptr_t>(p)); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { DCHECK_EQ(sizeof(param_type), sizeof(intptr_t)); return m->ReadIntPtr(iter, reinterpret_cast<intptr_t*>(r)); } @@ -484,10 +511,10 @@ struct ParamTraits<HANDLE> { template <> struct ParamTraits<HCURSOR> { typedef HCURSOR param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { m->WriteIntPtr(reinterpret_cast<intptr_t>(p)); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { DCHECK_EQ(sizeof(param_type), sizeof(intptr_t)); return m->ReadIntPtr(iter, reinterpret_cast<intptr_t*>(r)); } @@ -499,10 +526,10 @@ struct ParamTraits<HCURSOR> { template <> struct ParamTraits<HWND> { typedef HWND param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { m->WriteIntPtr(reinterpret_cast<intptr_t>(p)); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { DCHECK_EQ(sizeof(param_type), sizeof(intptr_t)); return m->ReadIntPtr(iter, reinterpret_cast<intptr_t*>(r)); } @@ -514,7 +541,7 @@ struct ParamTraits<HWND> { template <> struct ParamTraits<HRGN> { typedef HRGN param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { int data_size = GetRegionData(p, 0, NULL); if (data_size) { char* bytes = new char[data_size]; @@ -525,7 +552,7 @@ struct ParamTraits<HRGN> { m->WriteData(NULL, 0); } } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { bool res = FALSE; const char *data; int data_size = 0; @@ -547,10 +574,10 @@ struct ParamTraits<HRGN> { template <> struct ParamTraits<HACCEL> { typedef HACCEL param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { m->WriteIntPtr(reinterpret_cast<intptr_t>(p)); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { DCHECK_EQ(sizeof(param_type), sizeof(intptr_t)); return m->ReadIntPtr(iter, reinterpret_cast<intptr_t*>(r)); } @@ -559,11 +586,11 @@ struct ParamTraits<HACCEL> { template <> struct ParamTraits<POINT> { typedef POINT param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { m->WriteInt(p.x); m->WriteInt(p.y); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + 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; @@ -580,10 +607,10 @@ struct ParamTraits<POINT> { template <> struct ParamTraits<FilePath> { typedef FilePath param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { ParamTraits<FilePath::StringType>::Write(m, p.value()); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { FilePath::StringType value; if (!ParamTraits<FilePath::StringType>::Read(m, iter, &value)) return false; @@ -598,44 +625,44 @@ struct ParamTraits<FilePath> { template <> struct ParamTraits<gfx::Point> { typedef gfx::Point param_type; - static void Write(IPC::Message* m, const param_type& p); - static bool Read(const IPC::Message* m, void** iter, param_type* r); + 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); }; template <> struct ParamTraits<gfx::Rect> { typedef gfx::Rect param_type; - static void Write(IPC::Message* m, const param_type& p); - static bool Read(const IPC::Message* m, void** iter, param_type* r); + 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); }; template <> struct ParamTraits<gfx::Size> { typedef gfx::Size param_type; - static void Write(IPC::Message* m, const param_type& p); - static bool Read(const IPC::Message* m, void** iter, param_type* r); + 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); }; template<> struct ParamTraits<ThumbnailScore> { typedef ThumbnailScore param_type; - 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 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 bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { double boring_score; bool good_clipping, at_top; base::Time 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)) + 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)) return false; r->boring_score = boring_score; @@ -653,10 +680,10 @@ struct ParamTraits<ThumbnailScore> { template <> struct ParamTraits<WindowOpenDisposition> { typedef WindowOpenDisposition param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { m->WriteInt(p); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { int temp; bool res = m->ReadInt(iter, &temp); *r = static_cast<WindowOpenDisposition>(temp); @@ -670,10 +697,10 @@ struct ParamTraits<WindowOpenDisposition> { template <> struct ParamTraits<ConsoleMessageLevel> { typedef ConsoleMessageLevel param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { m->WriteInt(p); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { int temp; bool res = m->ReadInt(iter, &temp); *r = static_cast<ConsoleMessageLevel>(temp); @@ -687,13 +714,13 @@ struct ParamTraits<ConsoleMessageLevel> { template <> struct ParamTraits<CacheManager::ResourceTypeStat> { typedef CacheManager::ResourceTypeStat param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(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 IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { bool result = ReadParam(m, iter, &r->count) && ReadParam(m, iter, &r->size) && @@ -710,14 +737,14 @@ struct ParamTraits<CacheManager::ResourceTypeStat> { template <> struct ParamTraits<CacheManager::ResourceTypeStats> { typedef CacheManager::ResourceTypeStats param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(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 IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { bool result = ReadParam(m, iter, &r->images) && ReadParam(m, iter, &r->css_stylesheets) && @@ -741,10 +768,10 @@ struct ParamTraits<CacheManager::ResourceTypeStats> { template <> struct ParamTraits<XFORM> { typedef XFORM param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { m->WriteData(reinterpret_cast<const char*>(&p), sizeof(XFORM)); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + 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); @@ -766,10 +793,10 @@ struct ParamTraits<XFORM> { template <> struct ParamTraits<WebCursor> { typedef WebCursor param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { p.Serialize(m); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { return r->Deserialize(m, iter); } static void Log(const param_type& p, std::wstring* l) { @@ -777,8 +804,6 @@ struct ParamTraits<WebCursor> { } }; -namespace IPC { - struct LogData { std::wstring channel; uint16 type; @@ -791,12 +816,10 @@ struct LogData { std::wstring params; }; -} - template <> -struct ParamTraits<IPC::LogData> { - typedef IPC::LogData param_type; - static void Write(IPC::Message* m, const param_type& p) { +struct ParamTraits<LogData> { + typedef LogData param_type; + static void Write(Message* m, const param_type& p) { WriteParam(m, p.channel); WriteParam(m, static_cast<int>(p.type)); WriteParam(m, p.flags); @@ -805,7 +828,7 @@ struct ParamTraits<IPC::LogData> { WriteParam(m, p.dispatch); WriteParam(m, p.params); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { int type; bool result = ReadParam(m, iter, &r->channel) && @@ -826,9 +849,9 @@ struct ParamTraits<IPC::LogData> { template <> struct ParamTraits<Tuple0> { typedef Tuple0 param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { return true; } static void Log(const param_type& p, std::wstring* l) { @@ -838,10 +861,10 @@ struct ParamTraits<Tuple0> { template <class A> struct ParamTraits< Tuple1<A> > { typedef Tuple1<A> param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { WriteParam(m, p.a); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { return ReadParam(m, iter, &r->a); } static void Log(const param_type& p, std::wstring* l) { @@ -852,11 +875,11 @@ struct ParamTraits< Tuple1<A> > { template <class A, class B> struct ParamTraits< Tuple2<A, B> > { typedef Tuple2<A, B> param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { WriteParam(m, p.a); WriteParam(m, p.b); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { return (ReadParam(m, iter, &r->a) && ReadParam(m, iter, &r->b)); } @@ -870,12 +893,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(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { WriteParam(m, p.a); WriteParam(m, p.b); WriteParam(m, p.c); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { return (ReadParam(m, iter, &r->a) && ReadParam(m, iter, &r->b) && ReadParam(m, iter, &r->c)); @@ -892,13 +915,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(IPC::Message* m, const param_type& p) { + static void Write(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 IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { return (ReadParam(m, iter, &r->a) && ReadParam(m, iter, &r->b) && ReadParam(m, iter, &r->c) && @@ -918,14 +941,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(IPC::Message* m, const param_type& p) { + static void Write(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 IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { return (ReadParam(m, iter, &r->a) && ReadParam(m, iter, &r->b) && ReadParam(m, iter, &r->c) && @@ -948,7 +971,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(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { WriteParam(m, p.a); WriteParam(m, p.b); WriteParam(m, p.c); @@ -956,7 +979,7 @@ struct ParamTraits< Tuple6<A, B, C, D, E, F> > { WriteParam(m, p.e); WriteParam(m, p.f); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { return (ReadParam(m, iter, &r->a) && ReadParam(m, iter, &r->b) && ReadParam(m, iter, &r->c) && @@ -982,77 +1005,11 @@ struct ParamTraits< Tuple6<A, B, C, D, E, F> > { template <> struct ParamTraits<webkit_glue::WebApplicationInfo> { typedef webkit_glue::WebApplicationInfo param_type; - static void Write(IPC::Message* m, const param_type& p); - static bool Read(const IPC::Message* m, void** iter, param_type* r); + 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); }; -// 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 @@ -1068,7 +1025,7 @@ class MessageWithTuple : public Message { WriteParam(this, p); } - static bool Read(const IPC::Message* msg, Param* p) { + static bool Read(const Message* msg, Param* p) { void* iter = NULL; bool rv = ReadParam(msg, &iter, p); DCHECK(rv) << "Error deserializing message " << msg->type(); @@ -1077,7 +1034,7 @@ class MessageWithTuple : public Message { // Generic dispatcher. Should cover most cases. template<class T, class Method> - static bool Dispatch(const IPC::Message* msg, T* obj, Method func) { + static bool Dispatch(const Message* msg, T* obj, Method func) { Param p; if (Read(msg, &p)) { DispatchToMethod(obj, func, p); @@ -1090,7 +1047,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 IPC::Message* msg, T* obj, + static bool Dispatch(const Message* msg, T* obj, void (T::*func)(const Message&, TA)) { Param p; if (Read(msg, &p)) { @@ -1101,7 +1058,7 @@ class MessageWithTuple : public Message { } template<class T, typename TA, typename TB> - static bool Dispatch(const IPC::Message* msg, T* obj, + static bool Dispatch(const Message* msg, T* obj, void (T::*func)(const Message&, TA, TB)) { Param p; if (Read(msg, &p)) { @@ -1112,7 +1069,7 @@ class MessageWithTuple : public Message { } template<class T, typename TA, typename TB, typename TC> - static bool Dispatch(const IPC::Message* msg, T* obj, + static bool Dispatch(const Message* msg, T* obj, void (T::*func)(const Message&, TA, TB, TC)) { Param p; if (Read(msg, &p)) { @@ -1123,7 +1080,7 @@ class MessageWithTuple : public Message { } template<class T, typename TA, typename TB, typename TC, typename TD> - static bool Dispatch(const IPC::Message* msg, T* obj, + static bool Dispatch(const Message* msg, T* obj, void (T::*func)(const Message&, TA, TB, TC, TD)) { Param p; if (Read(msg, &p)) { @@ -1135,7 +1092,7 @@ class MessageWithTuple : public Message { template<class T, typename TA, typename TB, typename TC, typename TD, typename TE> - static bool Dispatch(const IPC::Message* msg, T* obj, + static bool Dispatch(const Message* msg, T* obj, void (T::*func)(const Message&, TA, TB, TC, TD, TE)) { Param p; if (Read(msg, &p)) { @@ -1145,59 +1102,11 @@ class MessageWithTuple : public Message { return false; } - static void Log(const IPC::Message* msg, std::wstring* l) { + static void Log(const 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 @@ -1229,7 +1138,7 @@ class MessageWithReply : public SyncMessage { WriteParam(this, send); } - static void Log(const IPC::Message* msg, std::wstring* l) { + static void Log(const Message* msg, std::wstring* l) { if (msg->is_sync()) { SendParam p; void* iter = SyncMessage::GetDataIterator(msg); @@ -1254,7 +1163,7 @@ class MessageWithReply : public SyncMessage { } template<class T, class Method> - static bool Dispatch(const IPC::Message* msg, T* obj, Method func) { + static bool Dispatch(const Message* msg, T* obj, Method func) { SendParam send_params; void* iter = GetDataIterator(msg); Message* reply = GenerateReply(msg); @@ -1282,7 +1191,7 @@ class MessageWithReply : public SyncMessage { } template<class T, class Method> - static bool DispatchDelayReply(const IPC::Message* msg, T* obj, Method func) { + static bool DispatchDelayReply(const Message* msg, T* obj, Method func) { SendParam send_params; void* iter = GetDataIterator(msg); Message* reply = GenerateReply(msg); @@ -1343,6 +1252,32 @@ 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 2ccbd96..53d3f2a 100644 --- a/chrome/common/ipc_sync_channel_unittest.cc +++ b/chrome/common/ipc_sync_channel_unittest.cc @@ -20,9 +20,12 @@ #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 MESSAGES_INTERNAL_FILE "chrome/common/ipc_sync_message_unittest.h" -#include "chrome/common/ipc_message_macros.h" +// define the classes +#define IPC_MESSAGE_MACROS_CLASSES +#include "chrome/common/ipc_sync_channel_unittest.h" using namespace IPC; using base::WaitableEvent; diff --git a/chrome/common/ipc_sync_message_unittest.cc b/chrome/common/ipc_sync_message_unittest.cc index 6508eaf..ae44acb 100644 --- a/chrome/common/ipc_sync_message_unittest.cc +++ b/chrome/common/ipc_sync_message_unittest.cc @@ -14,9 +14,13 @@ #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 3b32c10..8393533 100644 --- a/chrome/common/ipc_sync_message_unittest.h +++ b/chrome/common/ipc_sync_message_unittest.h @@ -4,16 +4,7 @@ #include "chrome/common/ipc_message_macros.h" -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 */) - +IPC_BEGIN_MESSAGES(TestMsg, 8) // out1 is false IPC_SYNC_MESSAGE_CONTROL0_1(Msg_C_0_1, bool) diff --git a/chrome/common/plugin_messages.h b/chrome/common/plugin_messages.h index 793dde3..025acc2 100644 --- a/chrome/common/plugin_messages.h +++ b/chrome/common/plugin_messages.h @@ -15,11 +15,14 @@ #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" @@ -35,11 +38,95 @@ 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(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { WriteParam(m, p.containing_window); WriteParam(m, p.url); DCHECK(p.arg_names.size() == p.arg_values.size()); @@ -48,7 +135,7 @@ struct ParamTraits<PluginMsg_Init_Params> { WriteParam(m, p.load_manually); WriteParam(m, p.modal_dialog_event); } - static bool Read(const IPC::Message* m, void** iter, param_type* p) { + static bool Read(const 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) && @@ -73,23 +160,10 @@ 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(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { WriteParam(m, p.method); WriteParam(m, p.is_javascript_url); WriteParam(m, p.target); @@ -100,7 +174,7 @@ struct ParamTraits<PluginHostMsg_URLRequest_Params> { WriteParam(m, p.notify_data); WriteParam(m, p.popups_allowed); } - static bool Read(const IPC::Message* m, void** iter, param_type* p) { + static bool Read(const Message* m, void** iter, param_type* p) { return ReadParam(m, iter, &p->method) && ReadParam(m, iter, &p->is_javascript_url) && @@ -135,26 +209,17 @@ 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(IPC::Message* m, const param_type& p) { + static void Write(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 IPC::Message* m, void** iter, param_type* p) { + static bool Read(const Message* m, void** iter, param_type* p) { return ReadParam(m, iter, &p->resource_id) && ReadParam(m, iter, &p->url) && @@ -177,20 +242,14 @@ 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(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { WriteParam(m, p.shared_memory); WriteParam(m, p.size); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { return ReadParam(m, iter, &r->shared_memory) && ReadParam(m, iter, &r->size); @@ -199,20 +258,10 @@ 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(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { WriteParam(m, p.id); WriteParam(m, p.mime_type); WriteParam(m, p.headers); @@ -220,7 +269,7 @@ struct ParamTraits<PluginMsg_DidReceiveResponseParams> { WriteParam(m, p.last_modified); WriteParam(m, p.request_is_seekable); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { return ReadParam(m, iter, &r->id) && ReadParam(m, iter, &r->mime_type) && @@ -246,18 +295,97 @@ 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; + } -struct NPIdentifier_Param { - NPIdentifier identifier; + 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")"); + } }; template <> struct ParamTraits<NPIdentifier_Param> { typedef NPIdentifier_Param param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { webkit_glue::SerializeNPIdentifier(p.identifier, m); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const 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) { @@ -271,37 +399,10 @@ 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(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { WriteParam(m, static_cast<int>(p.type)); if (p.type == NPVARIANT_PARAM_BOOL) { WriteParam(m, p.bool_value); @@ -324,7 +425,7 @@ struct ParamTraits<NPVariant_Param> { DCHECK(p.type == NPVARIANT_PARAM_VOID || p.type == NPVARIANT_PARAM_NULL); } } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { int type; if (!ReadParam(m, iter, &type)) return false; @@ -372,94 +473,7 @@ struct ParamTraits<NPVariant_Param> { } }; - -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" +} // namespace IPC #endif // CHROME_COMMON_PLUGIN_MESSAGES_H__ diff --git a/chrome/common/plugin_messages_internal.h b/chrome/common/plugin_messages_internal.h index d8561d0..85093d5 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) +IPC_BEGIN_MESSAGES(PluginProcess, 3) // 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) +IPC_BEGIN_MESSAGES(PluginProcessHost, 4) // 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) +IPC_BEGIN_MESSAGES(Plugin, 5) // 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) +IPC_BEGIN_MESSAGES(PluginHost, 6) // 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) +IPC_BEGIN_MESSAGES(NPObject, 7) IPC_SYNC_MESSAGE_ROUTED0_0(NPObjectMsg_Release) IPC_SYNC_MESSAGE_ROUTED1_1(NPObjectMsg_HasMethod, diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index c33d63e..95c7e6d 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -15,6 +15,7 @@ #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" @@ -30,7 +31,6 @@ #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,43 +66,8 @@ struct ViewMsg_Navigate_Params { bool reload; }; -// 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")"); - } -}; - - +// Parameters structure for ViewHostMsg_FrameNavigate, which has too many data +// parameters to be reasonably put in a predefined IPC message. 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 @@ -156,80 +121,8 @@ struct ViewHostMsg_FrameNavigate_Params { bool is_content_filtered; }; -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")"); - } -}; - - +// Parameters structure for ViewHostMsg_ContextMenu, which has too many data +// parameters to be reasonably put in a predefined IPC message. // 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 @@ -283,45 +176,6 @@ 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 { @@ -373,40 +227,8 @@ struct ViewHostMsg_PaintRect_Params { int flags; }; -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")"); - } -}; - - +// Parameters structure for ViewHostMsg_ScrollRect, which has too many data +// parameters to be reasonably put in a predefined IPC message. struct ViewHostMsg_ScrollRect_Params { // The bitmap to be painted into the rect exposed by scrolling. BitmapWireData bitmap; @@ -428,48 +250,7 @@ struct ViewHostMsg_ScrollRect_Params { std::vector<WebPluginGeometry> plugin_window_moves; }; -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")"); - } -}; - - +// Parameters structure for ViewMsg_UploadFile. struct ViewMsg_UploadFile_Params { // See WebContents::StartFileUpload for a description of these fields. std::wstring file_path; @@ -479,30 +260,7 @@ struct ViewMsg_UploadFile_Params { std::wstring other_values; }; -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>"); - } -}; - - +// Parameters for a resource request. struct ViewHostMsg_Resource_Request { // The request method: GET, POST, etc. std::string method; @@ -544,58 +302,7 @@ struct ViewHostMsg_Resource_Request { std::vector<net::UploadData::Element> upload_content; }; -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")"); - } -}; - - +// Parameters for a resource response header. struct ViewMsg_Resource_ResponseHead : webkit_glue::ResourceLoaderBridge::ResponseInfo { // The response status. @@ -606,66 +313,7 @@ struct ViewMsg_Resource_ResponseHead FilterPolicy::Type filter_policy; }; -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); - } -}; - - +// Parameters for a synchronous resource response. struct ViewHostMsg_SyncLoad_Result : ViewMsg_Resource_ResponseHead { // The final URL after any redirects. GURL final_url; @@ -674,27 +322,7 @@ struct ViewHostMsg_SyncLoad_Result : ViewMsg_Resource_ResponseHead { std::string data; }; -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); - } -}; - - +// Parameters for a render request. struct ViewMsg_Print_Params { // In pixels according to dpi_x and dpi_y. gfx::Size printable_size; @@ -724,31 +352,6 @@ 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. @@ -759,23 +362,6 @@ 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. @@ -785,23 +371,6 @@ 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 @@ -821,29 +390,6 @@ 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. @@ -864,40 +410,6 @@ 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. @@ -927,52 +439,6 @@ 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, @@ -980,49 +446,38 @@ enum ViewHostMsg_ImeControl { IME_COMPLETE_COMPOSITION, }; -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; - } +// 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 - 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(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { m->WriteInt(p); } - static bool Read(const IPC::Message* m, void** iter, param_type* p) { + static bool Read(const Message* m, void** iter, param_type* p) { int type; if (!m->ReadInt(iter, &type) || !ResourceType::ValidType(type)) return false; @@ -1056,10 +511,10 @@ struct ParamTraits<ResourceType::Type> { template <> struct ParamTraits<FilterPolicy::Type> { typedef FilterPolicy::Type param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { m->WriteInt(p); } - static bool Read(const IPC::Message* m, void** iter, param_type* p) { + static bool Read(const Message* m, void** iter, param_type* p) { int type; if (!m->ReadInt(iter, &type) || !FilterPolicy::ValidType(type)) return false; @@ -1090,10 +545,10 @@ struct ParamTraits<FilterPolicy::Type> { template <> struct ParamTraits<ContextNode> { typedef ContextNode param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { m->WriteInt(p.type); } - static bool Read(const IPC::Message* m, void** iter, param_type* p) { + static bool Read(const Message* m, void** iter, param_type* p) { int type; if (!m->ReadInt(iter, &type)) return false; @@ -1131,10 +586,10 @@ struct ParamTraits<ContextNode> { template <> struct ParamTraits<WebInputEvent::Type> { typedef WebInputEvent::Type param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { m->WriteInt(p); } - static bool Read(const IPC::Message* m, void** iter, param_type* p) { + static bool Read(const Message* m, void** iter, param_type* p) { int type; if (!m->ReadInt(iter, &type)) return false; @@ -1177,10 +632,161 @@ 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(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { WriteParam(m, p.signon_realm); WriteParam(m, p.origin); WriteParam(m, p.action); @@ -1195,7 +801,7 @@ struct ParamTraits<PasswordForm> { WriteParam(m, p.preferred); WriteParam(m, p.blacklisted_by_user); } - static bool Read(const IPC::Message* m, void** iter, param_type* p) { + static bool Read(const Message* m, void** iter, param_type* p) { return ReadParam(m, iter, &p->signon_realm) && ReadParam(m, iter, &p->origin) && @@ -1216,10 +822,11 @@ struct ParamTraits<PasswordForm> { } }; +// Traits for AutofillForm_Params structure to pack/unpack. template <> struct ParamTraits<AutofillForm> { typedef AutofillForm param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { WriteParam(m, p.elements.size()); for (std::vector<AutofillForm::Element>::const_iterator itr = p.elements.begin(); @@ -1229,7 +836,7 @@ struct ParamTraits<AutofillForm> { WriteParam(m, itr->value); } } - static bool Read(const IPC::Message* m, void** iter, param_type* p) { + static bool Read(const Message* m, void** iter, param_type* p) { bool result = true; size_t elements_size = 0; result = result && ReadParam(m, iter, &elements_size); @@ -1246,18 +853,207 @@ 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(IPC::Message* m, const param_type& p) { + static void Write(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 IPC::Message* m, void** iter, param_type* p) { + static bool Read(const Message* m, void** iter, param_type* p) { return ReadParam(m, iter, &p->window) && ReadParam(m, iter, &p->window_rect) && @@ -1280,16 +1076,16 @@ struct ParamTraits<WebPluginGeometry> { } }; - +// Traits for ViewMsg_GetPlugins_Reply structure to pack/unpack. template <> struct ParamTraits<WebPluginMimeType> { typedef WebPluginMimeType param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { WriteParam(m, p.mime_type); WriteParam(m, p.file_extensions); WriteParam(m, p.description); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { return ReadParam(m, iter, &r->mime_type) && ReadParam(m, iter, &r->file_extensions) && @@ -1310,14 +1106,14 @@ struct ParamTraits<WebPluginMimeType> { template <> struct ParamTraits<WebPluginInfo> { typedef WebPluginInfo param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { WriteParam(m, p.name); WriteParam(m, p.path); WriteParam(m, p.version); WriteParam(m, p.desc); WriteParam(m, p.mime_types); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { return ReadParam(m, iter, &r->name) && ReadParam(m, iter, &r->path) && @@ -1341,10 +1137,35 @@ 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(IPC::Message* m, const param_type& p) { + static void Write(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())); @@ -1354,7 +1175,7 @@ struct ParamTraits<net::UploadData::Element> { WriteParam(m, p.file_range_length()); } } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { int type; if (!ReadParam(m, iter, &type)) return false; @@ -1383,17 +1204,18 @@ struct ParamTraits<net::UploadData::Element> { } }; +// Traits for CacheManager::UsageStats template <> struct ParamTraits<CacheManager::UsageStats> { typedef CacheManager::UsageStats param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(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 IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { return ReadParam(m, iter, &r->min_dead_capacity) && ReadParam(m, iter, &r->max_dead_capacity) && @@ -1406,15 +1228,16 @@ struct ParamTraits<CacheManager::UsageStats> { } }; +// Traits for PasswordFormDomManager::FillData. template <> struct ParamTraits<PasswordFormDomManager::FillData> { typedef PasswordFormDomManager::FillData param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(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 IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { return ReadParam(m, iter, &r->basic_data) && ReadParam(m, iter, &r->additional_logins) && @@ -1428,10 +1251,10 @@ struct ParamTraits<PasswordFormDomManager::FillData> { template<> struct ParamTraits<NavigationGesture> { typedef NavigationGesture param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { m->WriteInt(p); } - static bool Read(const IPC::Message* m, void** iter, param_type* p) { + static bool Read(const Message* m, void** iter, param_type* p) { int type; if (!m->ReadInt(iter, &type)) return false; @@ -1455,14 +1278,67 @@ 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(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { WriteParam(m, static_cast<int>(p.status())); WriteParam(m, p.os_error()); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { int status, os_error; if (!ReadParam(m, iter, &status) || !ReadParam(m, iter, &os_error)) @@ -1509,14 +1385,14 @@ struct ParamTraits<URLRequestStatus> { template <> struct ParamTraits<scoped_refptr<net::HttpResponseHeaders> > { typedef scoped_refptr<net::HttpResponseHeaders> param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { WriteParam(m, p.get() != NULL); if (p) { // Do not disclose Set-Cookie headers over IPC. p->Persist(m, net::HttpResponseHeaders::PERSIST_SANS_COOKIES); } } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { bool has_object; if (!ReadParam(m, iter, &has_object)) return false; @@ -1529,17 +1405,100 @@ 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(IPC::Message* m, const param_type& p) { + static void Write(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 IPC::Message* m, void** iter, param_type* p) { + static bool Read(const Message* m, void** iter, param_type* p) { return ReadParam(m, iter, &p->origin) && ReadParam(m, iter, &p->action) && @@ -1552,10 +1511,93 @@ 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(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { WriteParam(m, p.standard_font_family); WriteParam(m, p.fixed_font_family); WriteParam(m, p.serif_font_family); @@ -1581,7 +1623,7 @@ struct ParamTraits<WebPreferences> { WriteParam(m, p.user_style_sheet_location); WriteParam(m, p.uses_page_cache); } - static bool Read(const IPC::Message* m, void** iter, param_type* p) { + static bool Read(const Message* m, void** iter, param_type* p) { return ReadParam(m, iter, &p->standard_font_family) && ReadParam(m, iter, &p->fixed_font_family) && @@ -1613,10 +1655,11 @@ struct ParamTraits<WebPreferences> { } }; +// Traits for WebDropData template <> struct ParamTraits<WebDropData> { typedef WebDropData param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { WriteParam(m, p.url); WriteParam(m, p.url_title); WriteParam(m, p.file_extension); @@ -1627,7 +1670,7 @@ struct ParamTraits<WebDropData> { WriteParam(m, p.file_description_filename); WriteParam(m, p.file_contents); } - static bool Read(const IPC::Message* m, void** iter, param_type* p) { + static bool Read(const Message* m, void** iter, param_type* p) { return ReadParam(m, iter, &p->url) && ReadParam(m, iter, &p->url_title) && @@ -1644,17 +1687,18 @@ struct ParamTraits<WebDropData> { } }; +// Traits for ScreenInfo template <> struct ParamTraits<webkit_glue::ScreenInfo> { typedef webkit_glue::ScreenInfo param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(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 IPC::Message* m, void** iter, param_type* p) { + static bool Read(const Message* m, void** iter, param_type* p) { return ReadParam(m, iter, &p->depth) && ReadParam(m, iter, &p->depth_per_component) && @@ -1671,16 +1715,16 @@ template<> struct ParamTraits<ModalDialogEvent> { typedef ModalDialogEvent param_type; #if defined(OS_WIN) - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { WriteParam(m, p.event); } - static bool Read(const IPC::Message* m, void** iter, param_type* p) { + static bool Read(const Message* m, void** iter, param_type* p) { return ReadParam(m, iter, &p->event); } #else - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { } - static bool Read(const IPC::Message* m, void** iter, param_type* p) { + static bool Read(const Message* m, void** iter, param_type* p) { return true; } #endif @@ -1698,11 +1742,11 @@ struct ParamTraits<ModalDialogEvent> { template <> struct ParamTraits<gfx::NativeView> { typedef gfx::NativeView param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { NOTIMPLEMENTED(); } - static bool Read(const IPC::Message* m, void** iter, param_type* p) { + static bool Read(const Message* m, void** iter, param_type* p) { NOTIMPLEMENTED(); *p = NULL; return true; @@ -1715,8 +1759,6 @@ struct ParamTraits<gfx::NativeView> { #endif // defined(OS_POSIX) - -#define MESSAGES_INTERNAL_FILE "chrome/common/render_messages_internal.h" -#include "chrome/common/ipc_message_macros.h" +} // namespace IPC #endif // CHROME_COMMON_RENDER_MESSAGES_H_ diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index 30c23ba..149dd53 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -25,6 +25,8 @@ #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. @@ -32,7 +34,7 @@ // RenderView messages // These are messages sent from the browser to the renderer process. -IPC_BEGIN_MESSAGES(View) +IPC_BEGIN_MESSAGES(View, 1) // 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, @@ -484,7 +486,7 @@ IPC_END_MESSAGES(View) // WebContents messages // These are messages sent from the renderer to the browser process. -IPC_BEGIN_MESSAGES(ViewHost) +IPC_BEGIN_MESSAGES(ViewHost, 2) // 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 @@ -736,11 +738,9 @@ IPC_BEGIN_MESSAGES(ViewHost) 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. - IPC_MESSAGE_ROUTED3(ViewHostMsg_Thumbnail, - GURL /* url */, - ThumbnailScore /* score */, - SkBitmap /* bitmap */) + // 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) // Notification that the url for the favicon of a site has been determined. IPC_MESSAGE_ROUTED2(ViewHostMsg_UpdateFavIconURL, diff --git a/chrome/common/resource_bundle.h b/chrome/common/resource_bundle.h index 54d99b2..7af3ac8 100644 --- a/chrome/common/resource_bundle.h +++ b/chrome/common/resource_bundle.h @@ -119,9 +119,6 @@ class ResourceBundle { #elif defined(OS_LINUX) // Linux will use base::DataPack. TODO(evanm): finish this. typedef base::DataPack* DataHandle; -#elif defined(OS_MACOSX) - // TODO(port): figure this out - typedef void* DataHandle; #endif // Ctor/dtor are private, since we're a singleton. diff --git a/chrome/common/resource_dispatcher_unittest.cc b/chrome/common/resource_dispatcher_unittest.cc index 48cb178..bf9cc51 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(ReadParam(&message_queue_[0], &iter, &request_id)); + ASSERT_TRUE(IPC::ReadParam(&message_queue_[0], &iter, &request_id)); ViewHostMsg_Resource_Request request; - ASSERT_TRUE(ReadParam(&message_queue_[0], &iter, &request)); + ASSERT_TRUE(IPC::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(ReadParam(&message_queue_[0], &iter, &request_ack)); + ASSERT_TRUE(IPC::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 ef08426..ef19b71 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/filter_policy.h" +#include "chrome/common/render_messages.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 350e29c..09ba200 100644 --- a/chrome/common/temp_scaffolding_stubs.h +++ b/chrome/common/temp_scaffolding_stubs.h @@ -16,7 +16,6 @@ #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" @@ -27,12 +26,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; @@ -61,7 +60,6 @@ class URLRequestContext; class UserScriptMaster; class VisitedLinkMaster; class WebContents; -class WebPreferences; namespace IPC { class Message; @@ -293,8 +291,7 @@ class BrokerServices { class IconManager { }; -struct ViewHostMsg_DidPrintPage_Params; -struct ViewHostMsg_FrameNavigate_Params; +struct ViewHostMsg_Resource_Request; class ResourceDispatcherHost { public: @@ -630,7 +627,7 @@ class RenderViewHost : public RenderWidgetHost { return true; } void SetAlternateErrorPageURL(const GURL&) { NOTIMPLEMENTED(); } - void UpdateWebPreferences(const WebPreferences&) { NOTIMPLEMENTED(); } + void UpdateWebPreferences(WebPreferences) { NOTIMPLEMENTED(); } void ReservePageIDRange(int) { NOTIMPLEMENTED(); } }; diff --git a/chrome/plugin/chrome_plugin_host.cc b/chrome/plugin/chrome_plugin_host.cc index 482a669..42d15ef 100644 --- a/chrome/plugin/chrome_plugin_host.cc +++ b/chrome/plugin/chrome_plugin_host.cc @@ -11,7 +11,6 @@ #include "chrome/common/chrome_plugin_lib.h" #include "chrome/common/chrome_plugin_util.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/plugin_messages.h" #include "chrome/plugin/plugin_process.h" #include "chrome/plugin/plugin_thread.h" #include "chrome/plugin/webplugin_proxy.h" diff --git a/chrome/plugin/webplugin_delegate_stub.h b/chrome/plugin/webplugin_delegate_stub.h index d5e8270..1cc21631 100644 --- a/chrome/plugin/webplugin_delegate_stub.h +++ b/chrome/plugin/webplugin_delegate_stub.h @@ -9,9 +9,9 @@ #include "base/gfx/rect.h" #include "base/ref_counted.h" -#include "base/shared_memory.h" #include "base/task.h" #include "chrome/common/ipc_channel.h" +#include "chrome/common/plugin_messages.h" #include "third_party/npapi/bindings/npapi.h" class GURL; @@ -20,8 +20,6 @@ class WebPluginProxy; class WebPluginDelegateImpl; struct PluginMsg_Init_Params; struct PluginMsg_DidReceiveResponseParams; -struct PluginMsg_PrintResponse_Params; -struct PluginMsg_URLRequestReply_Params; class WebCursor; // Converts the IPC messages from WebPluginDelegateProxy into calls to the diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 8026718..932e042 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -454,7 +454,12 @@ void RenderView::SendThumbnail() { return; // send the thumbnail message to the browser process - Send(new ViewHostMsg_Thumbnail(routing_id_, url, score, thumbnail)); + IPC::Message* thumbnail_msg = new IPC::Message(routing_id_, + ViewHostMsg_Thumbnail::ID, IPC::Message::PRIORITY_NORMAL); + IPC::ParamTraits<GURL>::Write(thumbnail_msg, url); + IPC::ParamTraits<ThumbnailScore>::Write(thumbnail_msg, score); + IPC::ParamTraits<SkBitmap>::Write(thumbnail_msg, thumbnail); + Send(thumbnail_msg); } int RenderView::SwitchFrameToPrintMediaType(const ViewMsg_Print_Params& params, diff --git a/chrome/renderer/render_widget.cc b/chrome/renderer/render_widget.cc index 82ca86c..1e14993 100644 --- a/chrome/renderer/render_widget.cc +++ b/chrome/renderer/render_widget.cc @@ -10,7 +10,6 @@ #include "base/message_loop.h" #include "base/scoped_ptr.h" #include "build/build_config.h" -#include "chrome/common/render_messages.h" #include "chrome/renderer/render_process.h" #include "skia/ext/platform_canvas.h" @@ -728,26 +727,6 @@ void RenderWidget::OnMsgRepaint(const gfx::Size& size_to_paint) { DidInvalidateRect(webwidget_, repaint_rect); } -bool RenderWidget::next_paint_is_resize_ack() const { - return ViewHostMsg_PaintRect_Flags::is_resize_ack(next_paint_flags_); -} - -bool RenderWidget::next_paint_is_restore_ack() const { - return ViewHostMsg_PaintRect_Flags::is_restore_ack(next_paint_flags_); -} - -void RenderWidget::set_next_paint_is_resize_ack() { - next_paint_flags_ |= ViewHostMsg_PaintRect_Flags::IS_RESIZE_ACK; -} - -void RenderWidget::set_next_paint_is_restore_ack() { - next_paint_flags_ |= ViewHostMsg_PaintRect_Flags::IS_RESTORE_ACK; -} - -void RenderWidget::set_next_paint_is_repaint_ack() { - next_paint_flags_ |= ViewHostMsg_PaintRect_Flags::IS_REPAINT_ACK; -} - void RenderWidget::UpdateIME() { // If a browser process does not have IMEs, its IMEs are not active, or there // are not any attached widgets. diff --git a/chrome/renderer/render_widget.h b/chrome/renderer/render_widget.h index 8e37b83..df193bd 100644 --- a/chrome/renderer/render_widget.h +++ b/chrome/renderer/render_widget.h @@ -12,8 +12,8 @@ #include "base/gfx/rect.h" #include "base/gfx/size.h" #include "base/ref_counted.h" -#include "base/shared_memory.h" #include "chrome/common/ipc_channel.h" +#include "chrome/common/render_messages.h" #include "skia/ext/platform_canvas.h" #include "webkit/glue/webwidget_delegate.h" @@ -144,11 +144,25 @@ class RenderWidget : public IPC::Channel::Listener, return current_scroll_buf_ != NULL; } - bool next_paint_is_resize_ack() const; - bool next_paint_is_restore_ack() const; - void set_next_paint_is_resize_ack(); - void set_next_paint_is_restore_ack(); - void set_next_paint_is_repaint_ack(); + bool next_paint_is_resize_ack() const { + return ViewHostMsg_PaintRect_Flags::is_resize_ack(next_paint_flags_); + } + + bool next_paint_is_restore_ack() const { + return ViewHostMsg_PaintRect_Flags::is_restore_ack(next_paint_flags_); + } + + void set_next_paint_is_resize_ack() { + next_paint_flags_ |= ViewHostMsg_PaintRect_Flags::IS_RESIZE_ACK; + } + + void set_next_paint_is_restore_ack() { + next_paint_flags_ |= ViewHostMsg_PaintRect_Flags::IS_RESTORE_ACK; + } + + void set_next_paint_is_repaint_ack() { + next_paint_flags_ |= ViewHostMsg_PaintRect_Flags::IS_REPAINT_ACK; + } // Called when a renderer process moves an input focus or updates the // position of its caret. diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc index 94185d8..705a65d 100644 --- a/chrome/renderer/webplugin_delegate_proxy.cc +++ b/chrome/renderer/webplugin_delegate_proxy.cc @@ -18,7 +18,6 @@ #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/gfx/emf.h" #include "chrome/common/l10n_util.h" -#include "chrome/common/plugin_messages.h" #include "chrome/common/resource_bundle.h" #include "chrome/common/win_util.h" #include "chrome/plugin/npobject_proxy.h" diff --git a/chrome/renderer/webplugin_delegate_proxy.h b/chrome/renderer/webplugin_delegate_proxy.h index 745db46..65b1edb 100644 --- a/chrome/renderer/webplugin_delegate_proxy.h +++ b/chrome/renderer/webplugin_delegate_proxy.h @@ -12,6 +12,7 @@ #include "base/ref_counted.h" #include "base/scoped_handle.h" #include "chrome/common/ipc_message.h" +#include "chrome/common/plugin_messages.h" #include "chrome/plugin/npobject_stub.h" #include "chrome/renderer/plugin_channel_host.h" #include "webkit/glue/webplugin.h" @@ -19,12 +20,10 @@ class GURL; struct PluginHostMsg_RouteToFrame_Params; -struct PluginHostMsg_URLRequest_Params; class RenderView; class SkBitmap; namespace base { -class SharedMemory; class WaitableEvent; } diff --git a/chrome/test/automation/autocomplete_edit_proxy.h b/chrome/test/automation/autocomplete_edit_proxy.h index bd7c87a..85172d3 100644 --- a/chrome/test/automation/autocomplete_edit_proxy.h +++ b/chrome/test/automation/autocomplete_edit_proxy.h @@ -49,10 +49,12 @@ struct AutocompleteMatchData { }; typedef std::vector<AutocompleteMatchData> Matches; +namespace IPC { + template <> struct ParamTraits<AutocompleteMatchData> { typedef AutocompleteMatchData param_type; - static void Write(IPC::Message* m, const param_type& p) { + static void Write(Message* m, const param_type& p) { m->WriteString(p.provider_name); m->WriteInt(p.relevance); m->WriteBool(p.deletable); @@ -66,7 +68,7 @@ struct ParamTraits<AutocompleteMatchData> { m->WriteBool(p.starred); } - static bool Read(const IPC::Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, void** iter, param_type* r) { std::string destination_url; if (!m->ReadString(iter, &r->provider_name) || !m->ReadInt(iter, &r->relevance) || @@ -110,6 +112,7 @@ struct ParamTraits<AutocompleteMatchData> { l->append(L"]"); } }; +} // namespace IPC class AutocompleteEditProxy : public AutomationResourceProxy { public: diff --git a/chrome/test/automation/automation_messages.h b/chrome/test/automation/automation_messages.h index d4e916c..e1fdf80 100644 --- a/chrome/test/automation/automation_messages.h +++ b/chrome/test/automation/automation_messages.h @@ -8,6 +8,7 @@ #include <string> #include "base/basictypes.h" +#include "chrome/common/ipc_message.h" #include "chrome/common/ipc_message_utils.h" enum AutomationMsg_NavigationResponseValues { @@ -16,9 +17,25 @@ enum AutomationMsg_NavigationResponseValues { AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED, }; -#define MESSAGES_INTERNAL_FILE \ - "chrome/test/automation/automation_messages_internal.h" -#include "chrome/common/ipc_message_macros.h" +// Two-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/test/automation/automation_messages_internal.h" + +#ifdef IPC_MESSAGE_MACROS_LOG_ENABLED +# undef IPC_MESSAGE_MACROS_LOG +# define IPC_MESSAGE_MACROS_CLASSES +#include "chrome/test/automation/automation_messages_internal.h" + +# undef IPC_MESSAGE_MACROS_CLASSES +# define IPC_MESSAGE_MACROS_LOG +#include "chrome/test/automation/automation_messages_internal.h" +#else +// No debug strings requested, just define the classes +# define IPC_MESSAGE_MACROS_CLASSES +#include "chrome/test/automation/automation_messages_internal.h" +#endif + #endif // CHROME_TEST_AUTOMATION_AUTOMATION_MESSAGES_H__ diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h index 05290d0d..a22818c 100644 --- a/chrome/test/automation/automation_messages_internal.h +++ b/chrome/test/automation/automation_messages_internal.h @@ -31,7 +31,9 @@ // since the PageCyclerReferenceTest depends on the correctness of the // message IDs across the builds. -IPC_BEGIN_MESSAGES(Automation) +// By using a start value of 0 for automation messages, we keep backward +// compatability with old builds. +IPC_BEGIN_MESSAGES(Automation, 0) // This message is fired when the AutomationProvider is up and running // in the app (the app is not fully up at this point). @@ -204,9 +206,7 @@ IPC_BEGIN_MESSAGES(Automation) IPC_MESSAGE_ROUTED2(AutomationMsg_RedirectsFromRequest, int, // tab handle GURL) // source URL - IPC_MESSAGE_ROUTED2(AutomationMsg_RedirectsFromResponse, - bool /* succeeded */, - std::vector<GURL> /* redirects */) + IPC_MESSAGE_EMPTY(AutomationMsg_RedirectsFromResponse) // This message asks the AutomationProvider whether a tab is waiting for // login info. diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc index d0a5d69..f8d4b93 100644 --- a/chrome/test/automation/automation_proxy.cc +++ b/chrome/test/automation/automation_proxy.cc @@ -8,6 +8,7 @@ #include "base/logging.h" #include "base/ref_counted.h" +#include "chrome/common/ipc_message_macros.h" #include "chrome/test/automation/automation_constants.h" #include "chrome/test/automation/automation_messages.h" #include "chrome/test/automation/browser_proxy.h" @@ -553,7 +554,7 @@ TabProxy* AutomationProxy::CreateExternalTab(HWND parent, void* iter = NULL; int handle = 0; TabProxy* tab_proxy = NULL; - if (ReadParam(response, &iter, external_tab_container) && + if (IPC::ReadParam(response, &iter, external_tab_container) && IsWindow(*external_tab_container)) { if (response->ReadInt(&iter, &handle) && (handle >= 0)) { diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc index 2d689ac..5673e69 100644 --- a/chrome/test/automation/tab_proxy.cc +++ b/chrome/test/automation/tab_proxy.cc @@ -24,15 +24,23 @@ bool TabProxy::GetTabTitle(std::wstring* title) const { } IPC::Message* response = NULL; - int tab_title_size_response; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_TabTitleRequest(0, handle_), &response, - AutomationMsg_TabTitleResponse::ID) && - AutomationMsg_TabTitleResponse::Read(response, &tab_title_size_response, title) && - tab_title_size_response >= 0; - scoped_ptr<IPC::Message> auto_deleter(response); + new AutomationMsg_TabTitleRequest(0, handle_), &response, + AutomationMsg_TabTitleResponse::ID); + + if (!succeeded) + return false; + void* iter = NULL; + int tab_title_size_response = -1; + if (response->ReadInt(&iter, &tab_title_size_response) && + (tab_title_size_response >= 0)) { + response->ReadWString(&iter, title); + } else { + succeeded = false; + } + + delete response; return succeeded; } @@ -47,18 +55,24 @@ bool TabProxy::IsShelfVisible(bool* is_visible) { IPC::Message* response = NULL; bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_ShelfVisibilityRequest(0, handle_), - &response, AutomationMsg_ShelfVisibilityResponse::ID) && - AutomationMsg_ShelfVisibilityResponse::Read(response, is_visible); - scoped_ptr<IPC::Message> auto_deleter(response); - return succeeded; + new AutomationMsg_ShelfVisibilityRequest(0, handle_), + &response, + AutomationMsg_ShelfVisibilityResponse::ID); + if (!succeeded) + return false; + + void* iter = NULL; + response->ReadBool(&iter, is_visible); + delete response; + return true; } bool TabProxy::OpenFindInPage() { if (!is_valid()) return false; - return sender_->Send(new AutomationMsg_OpenFindInPageRequest(0, handle_)); + return sender_->Send( + new AutomationMsg_OpenFindInPageRequest(0, handle_)); // This message expects no response. } @@ -74,10 +88,15 @@ bool TabProxy::IsFindWindowFullyVisible(bool* is_visible) { IPC::Message* response = NULL; bool succeeded = sender_->SendAndWaitForResponse( new AutomationMsg_FindWindowVisibilityRequest(0, handle_), - &response, AutomationMsg_FindWindowVisibilityResponse::ID) && - AutomationMsg_FindWindowVisibilityResponse::Read(response, is_visible); - scoped_ptr<IPC::Message> auto_deleter(response); - return succeeded; + &response, + AutomationMsg_FindWindowVisibilityResponse::ID); + if (!succeeded) + return false; + + void* iter = NULL; + response->ReadBool(&iter, is_visible); + delete response; + return true; } bool TabProxy::GetFindWindowLocation(int* x, int* y) { @@ -87,17 +106,23 @@ bool TabProxy::GetFindWindowLocation(int* x, int* y) { IPC::Message* response = NULL; bool succeeded = sender_->SendAndWaitForResponse( new AutomationMsg_FindWindowLocationRequest(0, handle_), - &response, AutomationMsg_FindWindowLocationResponse::ID) && - AutomationMsg_FindWindowLocationResponse::Read(response, x, y); - scoped_ptr<IPC::Message> auto_deleter(response); - return succeeded; + &response, + AutomationMsg_FindWindowLocationResponse::ID); + if (!succeeded) + return false; + + void* iter = NULL; + response->ReadInt(&iter, x); + response->ReadInt(&iter, y); + delete response; + return true; } int TabProxy::FindInPage(const std::wstring& search_string, FindInPageDirection forward, FindInPageCase match_case, bool find_next, - int* ordinal) { + int* active_ordinal) { if (!is_valid()) return -1; @@ -109,15 +134,22 @@ int TabProxy::FindInPage(const std::wstring& search_string, request.forward = forward == TRUE; IPC::Message* response = NULL; - int matches; bool succeeded = sender_->SendAndWaitForResponse( new AutomationMsg_FindRequest(0, handle_, request), - &response, AutomationMsg_FindInPageResponse2::ID) && - AutomationMsg_FindInPageResponse2::Read(response, ordinal, &matches); - scoped_ptr<IPC::Message> auto_deleter(response); + &response, + AutomationMsg_FindInPageResponse2::ID); if (!succeeded) return -1; - return matches; + + void* iter = NULL; + int ordinal; + int matches_found; + response->ReadInt(&iter, &ordinal); + response->ReadInt(&iter, &matches_found); + if (active_ordinal) + *active_ordinal = ordinal; + delete response; + return matches_found; } int TabProxy::NavigateToURL(const GURL& url) { @@ -131,13 +163,18 @@ int TabProxy::NavigateToURLWithTimeout(const GURL& url, return AUTOMATION_MSG_NAVIGATION_ERROR; IPC::Message* response = NULL; + bool succeeded = sender_->SendAndWaitForResponseWithTimeout( + new AutomationMsg_NavigateToURLRequest(0, handle_, url), &response, + AutomationMsg_NavigateToURLResponse::ID, timeout_ms, is_timeout); + + if (!succeeded) + return AUTOMATION_MSG_NAVIGATION_ERROR; + + void* iter = NULL; int navigate_response = AUTOMATION_MSG_NAVIGATION_ERROR; - if (sender_->SendAndWaitForResponseWithTimeout( - new AutomationMsg_NavigateToURLRequest(0, handle_, url), &response, - AutomationMsg_NavigateToURLResponse::ID, timeout_ms, is_timeout)) { - AutomationMsg_NavigateToURLResponse::Read(response, &navigate_response); - } - scoped_ptr<IPC::Message> auto_deleter(response); + response->ReadInt(&iter, &navigate_response); + + delete response; return navigate_response; } @@ -147,15 +184,19 @@ int TabProxy::NavigateInExternalTab(const GURL& url) { IPC::Message* response = NULL; bool is_timeout = false; - int rv = AUTOMATION_MSG_NAVIGATION_ERROR; - if (sender_->SendAndWaitForResponseWithTimeout( - new AutomationMsg_NavigateInExternalTabRequest(0, handle_, url), - &response, AutomationMsg_NavigateInExternalTabResponse::ID, INFINITE, - &is_timeout)) { - AutomationMsg_NavigateInExternalTabResponse::Read(response, &rv); - } - scoped_ptr<IPC::Message> auto_deleter(response); - return rv; + bool succeeded = sender_->SendAndWaitForResponseWithTimeout( + new AutomationMsg_NavigateInExternalTabRequest(0, handle_, url), &response, + AutomationMsg_NavigateInExternalTabResponse::ID, INFINITE, &is_timeout); + + if (!succeeded) + return AUTOMATION_MSG_NAVIGATION_ERROR; + + void* iter = NULL; + int navigate_response = AUTOMATION_MSG_NAVIGATION_ERROR; + response->ReadInt(&iter, &navigate_response); + + delete response; + return navigate_response; } bool TabProxy::SetAuth(const std::wstring& username, @@ -164,13 +205,19 @@ bool TabProxy::SetAuth(const std::wstring& username, return false; IPC::Message* response = NULL; - int navigate_response = -1; bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_SetAuthRequest(0, handle_, username, password), - &response, AutomationMsg_SetAuthResponse::ID) && - AutomationMsg_SetAuthResponse::Read(response, &navigate_response) && - navigate_response >= 0; - scoped_ptr<IPC::Message> auto_deleter(response); + new AutomationMsg_SetAuthRequest(0, handle_, username, password), &response, + AutomationMsg_SetAuthResponse::ID); + + if (!succeeded) + return false; + + void* iter = NULL; + int navigate_response = -1; + succeeded = (response->ReadInt(&iter, &navigate_response) && + navigate_response >= 0); + + delete response; return succeeded; } @@ -179,13 +226,19 @@ bool TabProxy::CancelAuth() { return false; IPC::Message* response = NULL; - int navigate_response = -1; bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_CancelAuthRequest(0, handle_), &response, - AutomationMsg_CancelAuthResponse::ID) && - AutomationMsg_CancelAuthResponse::Read(response, &navigate_response) && - navigate_response >= 0; - scoped_ptr<IPC::Message> auto_deleter(response); + new AutomationMsg_CancelAuthRequest(0, handle_), &response, + AutomationMsg_CancelAuthResponse::ID); + + if (!succeeded) + return false; + + void* iter = NULL; + int navigate_response = -1; + succeeded = (response->ReadInt(&iter, &navigate_response) && + navigate_response >= 0); + + delete response; return succeeded; } @@ -194,12 +247,18 @@ bool TabProxy::NeedsAuth() const { return false; IPC::Message* response = NULL; - bool needs_auth = false; bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_NeedsAuthRequest(0, handle_), &response, - AutomationMsg_NeedsAuthResponse::ID) && - AutomationMsg_NeedsAuthResponse::Read(response, &needs_auth); - scoped_ptr<IPC::Message> auto_deleter(response); + new AutomationMsg_NeedsAuthRequest(0, handle_), &response, + AutomationMsg_NeedsAuthResponse::ID); + + if (!succeeded) + return false; + + void* iter = NULL; + bool needs_auth = false; + response->ReadBool(&iter, &needs_auth); + + delete response; return needs_auth; } @@ -208,13 +267,18 @@ int TabProxy::GoBack() { return AUTOMATION_MSG_NAVIGATION_ERROR; IPC::Message* response = NULL; + bool succeeded = sender_->SendAndWaitForResponse( + new AutomationMsg_GoBackRequest(0, handle_), &response, + AutomationMsg_GoBackResponse::ID); + + if (!succeeded) + return AUTOMATION_MSG_NAVIGATION_ERROR; + + void* iter = NULL; int navigate_response = AUTOMATION_MSG_NAVIGATION_ERROR; - if (sender_->SendAndWaitForResponse( - new AutomationMsg_GoBackRequest(0, handle_), &response, - AutomationMsg_GoBackResponse::ID)) { - AutomationMsg_GoBackResponse::Read(response, &navigate_response); - } - scoped_ptr<IPC::Message> auto_deleter(response); + response->ReadInt(&iter, &navigate_response); + + delete response; return navigate_response; } @@ -223,13 +287,18 @@ int TabProxy::GoForward() { return AUTOMATION_MSG_NAVIGATION_ERROR; IPC::Message* response = NULL; + bool succeeded = sender_->SendAndWaitForResponse( + new AutomationMsg_GoForwardRequest(0, handle_), &response, + AutomationMsg_GoForwardResponse::ID); + + if (!succeeded) + return AUTOMATION_MSG_NAVIGATION_ERROR; + + void* iter = NULL; int navigate_response = AUTOMATION_MSG_NAVIGATION_ERROR; - if (sender_->SendAndWaitForResponse( - new AutomationMsg_GoForwardRequest(0, handle_), &response, - AutomationMsg_GoForwardResponse::ID)) { - AutomationMsg_GoForwardResponse::Read(response, &navigate_response); - } - scoped_ptr<IPC::Message> auto_deleter(response); + response->ReadInt(&iter, &navigate_response); + + delete response; return navigate_response; } @@ -238,30 +307,48 @@ int TabProxy::Reload() { return AUTOMATION_MSG_NAVIGATION_ERROR; IPC::Message* response = NULL; + bool succeeded = sender_->SendAndWaitForResponse( + new AutomationMsg_ReloadRequest(0, handle_), &response, + AutomationMsg_ReloadResponse::ID); + + if (!succeeded) + return AUTOMATION_MSG_NAVIGATION_ERROR; + + void* iter = NULL; int navigate_response = AUTOMATION_MSG_NAVIGATION_ERROR; - if (sender_->SendAndWaitForResponse( - new AutomationMsg_ReloadRequest(0, handle_), &response, - AutomationMsg_ReloadResponse::ID)) { - AutomationMsg_ReloadResponse::Read(response, &navigate_response); - } - scoped_ptr<IPC::Message> auto_deleter(response); + response->ReadInt(&iter, &navigate_response); + + delete response; return navigate_response; } bool TabProxy::GetRedirectsFrom(const GURL& source_url, std::vector<GURL>* redirects) { + std::vector<GURL> output; + IPC::Message* response = NULL; bool succeeded = sender_->SendAndWaitForResponse( new AutomationMsg_RedirectsFromRequest(0, handle_, source_url), &response, AutomationMsg_RedirectsFromResponse::ID); + if (!succeeded) + return false; scoped_ptr<IPC::Message> auto_deleter(response); - if (succeeded) { - succeeded = AutomationMsg_RedirectsFromResponse::Read( - response, &succeeded, redirects) && - succeeded; - } - return succeeded; + void* iter = NULL; + int num_redirects; + if (!response->ReadInt(&iter, &num_redirects)) + return false; + if (num_redirects < 0) + return false; // Negative redirect counts indicate failure. + + for (int i = 0; i < num_redirects; i++) { + GURL cur; + if (!IPC::ParamTraits<GURL>::Read(response, &iter, &cur)) + return false; + output.push_back(cur); + } + redirects->swap(output); + return true; } bool TabProxy::GetCurrentURL(GURL* url) const { @@ -274,12 +361,23 @@ bool TabProxy::GetCurrentURL(GURL* url) const { } IPC::Message* response = NULL; - bool succeeded; - succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_TabURLRequest(0, handle_), &response, - AutomationMsg_TabURLResponse::ID) && - AutomationMsg_TabURLResponse::Read(response, &succeeded, url); - scoped_ptr<IPC::Message> auto_deleter(response); + bool succeeded = sender_->SendAndWaitForResponse( + new AutomationMsg_TabURLRequest(0, handle_), &response, + AutomationMsg_TabURLResponse::ID); + + if (!succeeded) + return false; + + void* iter = NULL; + bool tab_url_success = false; + if (response->ReadBool(&iter, &tab_url_success) && tab_url_success) { + if (!IPC::ParamTraits<GURL>::Read(response, &iter, url)) + succeeded = false; + } else { + succeeded = false; + } + + delete response; return succeeded; } @@ -288,14 +386,21 @@ bool TabProxy::NavigateToURLAsync(const GURL& url) { return false; IPC::Message* response = NULL; - bool status = false; - if (sender_->SendAndWaitForResponse( - new AutomationMsg_NavigationAsyncRequest(0, handle_, url), &response, - AutomationMsg_NavigationAsyncResponse::ID)) { - AutomationMsg_NavigationAsyncResponse::Read(response, &status); + bool succeeded = sender_->SendAndWaitForResponse( + new AutomationMsg_NavigationAsyncRequest(0, handle_, url), &response, + AutomationMsg_NavigationAsyncResponse::ID); + + if (!succeeded) + return false; + + bool status; + if (AutomationMsg_NavigationAsyncResponse::Read(response, &status) && + status) { + succeeded = true; } - scoped_ptr<IPC::Message> auto_deleter(response); - return status; + + delete response; + return succeeded; } bool TabProxy::GetHWND(HWND* hwnd) const { @@ -306,13 +411,20 @@ bool TabProxy::GetHWND(HWND* hwnd) const { return false; } IPC::Message* response = NULL; - bool succeeded = false; - if (sender_->SendAndWaitForResponse( - new AutomationMsg_TabHWNDRequest(0, handle_), &response, - AutomationMsg_TabHWNDResponse::ID)) { - succeeded = AutomationMsg_TabHWNDResponse::Read(response, hwnd); + bool succeeded = sender_->SendAndWaitForResponse( + new AutomationMsg_TabHWNDRequest(0, handle_), &response, + AutomationMsg_TabHWNDResponse::ID); + if (!succeeded) + return false; + void* iter = NULL; + HWND tab_hwnd = NULL; + if (AutomationMsg_TabHWNDResponse::Read(response, &tab_hwnd) && tab_hwnd) { + *hwnd = tab_hwnd; + } else { + succeeded = false; } - scoped_ptr<IPC::Message> auto_deleter(response); + + delete response; return succeeded; } @@ -326,13 +438,22 @@ bool TabProxy::GetProcessID(int* process_id) const { } IPC::Message* response = NULL; - bool succeeded = false; - if (sender_->SendAndWaitForResponse( - new AutomationMsg_TabProcessIDRequest(0, handle_), &response, - AutomationMsg_TabProcessIDResponse::ID)) { - succeeded = AutomationMsg_TabProcessIDResponse::Read(response, process_id); + bool succeeded = sender_->SendAndWaitForResponse( + new AutomationMsg_TabProcessIDRequest(0, handle_), &response, + AutomationMsg_TabProcessIDResponse::ID); + + if (!succeeded) + return false; + + void* iter = NULL; + int pid; + if (AutomationMsg_TabProcessIDResponse::Read(response, &pid) && (pid >= 0)) { + *process_id = pid; + } else { + succeeded = false; } - scoped_ptr<IPC::Message> auto_deleter(response); + + delete response; return succeeded; } @@ -420,12 +541,14 @@ bool TabProxy::ExecuteAndExtractValue(const std::wstring& frame_xpath, bool succeeded = sender_->SendAndWaitForResponse( new AutomationMsg_DomOperationRequest(0, handle_, frame_xpath, jscript), &response, AutomationMsg_DomOperationResponse::ID); + + void* iter = NULL; std::string json; - if (succeeded) - succeeded = AutomationMsg_DomOperationResponse::Read(response, &json); - scoped_ptr<IPC::Message> auto_deleter(response); - if (!succeeded) + succeeded = response->ReadString(&iter, &json); + if (!succeeded) { + delete response; return false; + } // Wrap |json| in an array before deserializing because valid JSON has an // array or an object as the root. json.insert(0, "["); @@ -433,6 +556,8 @@ bool TabProxy::ExecuteAndExtractValue(const std::wstring& frame_xpath, JSONStringValueSerializer deserializer(json); *value = deserializer.Deserialize(NULL); + + delete response; return *value != NULL; } @@ -447,10 +572,19 @@ bool TabProxy::GetConstrainedWindowCount(int* count) const { IPC::Message* response = NULL; bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_ConstrainedWindowCountRequest(0, handle_), - &response, AutomationMsg_ConstrainedWindowCountResponse::ID) && - AutomationMsg_ConstrainedWindowCountResponse::Read(response, count); - scoped_ptr<IPC::Message> auto_deleter(response); + new AutomationMsg_ConstrainedWindowCountRequest(0, handle_), + &response, AutomationMsg_ConstrainedWindowCountResponse::ID); + + void* iter = NULL; + int count_response = -1; + if (response->ReadInt(&iter, &count_response) && + (count_response >= 0)) { + *count = count_response; + } else { + succeeded = false; + } + + delete response; return succeeded; } @@ -460,14 +594,18 @@ ConstrainedWindowProxy* TabProxy::GetConstrainedWindow( return NULL; IPC::Message* response = NULL; + bool succeeded = sender_->SendAndWaitForResponse( + new AutomationMsg_ConstrainedWindowRequest(0, handle_, window_index), + &response, AutomationMsg_ConstrainedWindowResponse::ID); + if (!succeeded) + return NULL; + + void* iter = NULL; int handle; - if (sender_->SendAndWaitForResponse( - new AutomationMsg_ConstrainedWindowRequest(0, handle_, window_index), - &response, AutomationMsg_ConstrainedWindowResponse::ID)) { - scoped_ptr<IPC::Message> response_deleter(response); - if (AutomationMsg_ConstrainedWindowResponse::Read(response, &handle)) - return new ConstrainedWindowProxy(sender_, tracker_, handle); - } + + scoped_ptr<IPC::Message> response_deleter(response); // Ensure deleted. + if (response->ReadInt(&iter, &handle) && (handle != 0)) + return new ConstrainedWindowProxy(sender_, tracker_, handle); return NULL; } @@ -489,13 +627,25 @@ bool TabProxy::GetCookies(const GURL& url, std::string* cookies) { return false; IPC::Message* response = NULL; - int size; bool succeeded = sender_->SendAndWaitForResponse( new AutomationMsg_GetCookiesRequest(0, url, handle_), &response, - AutomationMsg_GetCookiesResponse::ID) && - AutomationMsg_GetCookiesResponse::Read(response, &size, cookies) && - size >= 0; - scoped_ptr<IPC::Message> response_deleter(response); + AutomationMsg_GetCookiesResponse::ID); + + if (succeeded) { + void* iter = NULL; + int size; + std::string local_value; + + if (response->ReadInt(&iter, &size) && size >=0) { + if (!response->ReadString(&iter, cookies)) { + succeeded = false; + } + } else { + succeeded = false; + } + } + + delete response; return succeeded; } @@ -520,13 +670,20 @@ bool TabProxy::GetCookieByName(const GURL& url, bool TabProxy::SetCookie(const GURL& url, const std::string& value) { IPC::Message* response = NULL; - int response_value; bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_SetCookieRequest(0, url, value, handle_), &response, - AutomationMsg_SetCookieResponse::ID) && - AutomationMsg_SetCookieResponse::Read(response, &response_value) && - response_value >= 0; - scoped_ptr<IPC::Message> response_deleter(response); + new AutomationMsg_SetCookieRequest(0, url, value, handle_), &response, + AutomationMsg_SetCookieResponse::ID); + if (!succeeded) + return false; + + void* iter = NULL; + int response_value; + + if (!response->ReadInt(&iter, &response_value) || response_value < 0) { + succeeded = false; + } + + delete response; return succeeded; } @@ -535,28 +692,35 @@ int TabProxy::InspectElement(int x, int y) { return -1; IPC::Message* response = NULL; - int ret = -1; - if (sender_->SendAndWaitForResponse( + bool succeeded = sender_->SendAndWaitForResponse( new AutomationMsg_InspectElementRequest(0, handle_, x, y), - &response, AutomationMsg_InspectElementResponse::ID)) { - AutomationMsg_InspectElementResponse::Read(response, &ret); - } - scoped_ptr<IPC::Message> response_deleter(response); + &response, AutomationMsg_InspectElementResponse::ID); + if (!succeeded) + return -1; + + int ret; + AutomationMsg_InspectElementResponse::Read(response, &ret); return ret; } -bool TabProxy::GetDownloadDirectory(std::wstring* directory) { - DCHECK(directory); +bool TabProxy::GetDownloadDirectory(std::wstring* download_directory) { + DCHECK(download_directory); if (!is_valid()) return false; IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_DownloadDirectoryRequest(0, handle_), &response, - AutomationMsg_DownloadDirectoryResponse::ID) && - AutomationMsg_DownloadDirectoryResponse::Read(response, directory); - scoped_ptr<IPC::Message> response_deleter(response); - return succeeded; + bool succeeded = + sender_->SendAndWaitForResponse( + new AutomationMsg_DownloadDirectoryRequest(0, handle_), + &response, + AutomationMsg_DownloadDirectoryResponse::ID); + if (!succeeded) + return false; + + void* iter = NULL; + response->ReadWString(&iter, download_directory); + delete response; + return true; } bool TabProxy::ShowInterstitialPage(const std::string& html_text, @@ -568,12 +732,18 @@ bool TabProxy::ShowInterstitialPage(const std::string& html_text, IPC::Message* response = NULL; bool succeeded = sender_->SendAndWaitForResponseWithTimeout( new AutomationMsg_ShowInterstitialPageRequest(0, handle_, html_text), - &response, AutomationMsg_ShowInterstitialPageResponse::ID, timeout_ms, - &is_timeout) && - AutomationMsg_ShowInterstitialPageResponse::Read(response, &succeeded) && - succeeded; - scoped_ptr<IPC::Message> response_deleter(response); - return succeeded; + &response, + AutomationMsg_ShowInterstitialPageResponse::ID, timeout_ms, &is_timeout); + + if (!succeeded || !is_timeout) + return false; + + void* iter = NULL; + bool result = true; + response->ReadBool(&iter, &result); + + delete response; + return result; } bool TabProxy::HideInterstitialPage() { @@ -581,14 +751,21 @@ bool TabProxy::HideInterstitialPage() { return false; IPC::Message* response = NULL; - bool result; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_HideInterstitialPageRequest(0, handle_), - &response, AutomationMsg_HideInterstitialPageResponse::ID) && - AutomationMsg_HideInterstitialPageResponse::Read(response, &result) && - result; - scoped_ptr<IPC::Message> response_deleter(response); - return succeeded; + bool succeeded = + sender_->SendAndWaitForResponse( + new AutomationMsg_HideInterstitialPageRequest(0, handle_), + &response, + AutomationMsg_HideInterstitialPageResponse::ID); + + if (!succeeded) + return false; + + void* iter = NULL; + bool result = true; + response->ReadBool(&iter, &result); + + delete response; + return result; } bool TabProxy::Close() { @@ -600,13 +777,21 @@ bool TabProxy::Close(bool wait_until_closed) { return false; IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_CloseTabRequest(0, handle_, wait_until_closed), - &response, AutomationMsg_CloseTabResponse::ID) && - AutomationMsg_CloseTabResponse::Read(response, &succeeded) && - succeeded; - scoped_ptr<IPC::Message> response_deleter(response); - return succeeded; + bool succeeded = + sender_->SendAndWaitForResponse( + new AutomationMsg_CloseTabRequest(0, handle_, wait_until_closed), + &response, + AutomationMsg_CloseTabResponse::ID); + + if (!succeeded) + return false; + + void* iter = NULL; + bool result = true; + response->ReadBool(&iter, &result); + + delete response; + return result; } bool TabProxy::SetAccelerators(HACCEL accel_table, @@ -617,14 +802,20 @@ bool TabProxy::SetAccelerators(HACCEL accel_table, IPC::Message* response = NULL; bool is_timeout = false; bool succeeded = sender_->SendAndWaitForResponseWithTimeout( - new AutomationMsg_SetAcceleratorsForTab( - 0, handle_, accel_table, accel_table_entry_count), - &response, AutomationMsg_SetAcceleratorsForTabResponse::ID, INFINITE, - &is_timeout) && - AutomationMsg_SetAcceleratorsForTabResponse::Read(response, &succeeded) && - succeeded; - scoped_ptr<IPC::Message> response_deleter(response); - return succeeded; + new AutomationMsg_SetAcceleratorsForTab(0, handle_, accel_table, + accel_table_entry_count), + &response, + AutomationMsg_SetAcceleratorsForTabResponse::ID, INFINITE, &is_timeout); + + if (!succeeded) + return AUTOMATION_MSG_NAVIGATION_ERROR; + + void* iter = NULL; + bool set_accel_response = false; + response->ReadBool(&iter, &set_accel_response); + + delete response; + return set_accel_response; } bool TabProxy::ProcessUnhandledAccelerator(const MSG& msg) { @@ -640,11 +831,9 @@ bool TabProxy::WaitForTabToBeRestored(uint32 timeout_ms) { return false; IPC::Message* response = NULL; bool is_timeout; - bool succeeded = sender_->SendAndWaitForResponseWithTimeout( + return sender_->SendAndWaitForResponseWithTimeout( new AutomationMsg_WaitForTabToBeRestored(0, handle_), &response, AutomationMsg_TabFinishedRestoring::ID, timeout_ms, &is_timeout); - scoped_ptr<IPC::Message> response_deleter(response); - return succeeded; } bool TabProxy::GetSecurityState(SecurityStyle* security_style, @@ -657,18 +846,27 @@ bool TabProxy::GetSecurityState(SecurityStyle* security_style, IPC::Message* response = NULL; bool is_timeout = false; - int value; - bool succeeded; - succeeded = sender_->SendAndWaitForResponseWithTimeout( + bool succeeded = sender_->SendAndWaitForResponseWithTimeout( new AutomationMsg_GetSecurityState(0, handle_), &response, - AutomationMsg_GetSecurityStateResponse::ID, INFINITE, &is_timeout) && - AutomationMsg_GetSecurityStateResponse::Read( - response, &succeeded, &value, ssl_cert_status, mixed_content_state); - if (succeeded) - *security_style = static_cast<SecurityStyle>(value); + AutomationMsg_GetSecurityStateResponse::ID, INFINITE, &is_timeout); scoped_ptr<IPC::Message> auto_deleter(response); - return succeeded; + + if (!succeeded) + return false; + + void* iter = NULL; + int value; + + response->ReadBool(&iter, &succeeded); + if (!succeeded) + return false; + response->ReadInt(&iter, &value); + *security_style = static_cast<SecurityStyle>(value); + response->ReadInt(&iter, ssl_cert_status); + response->ReadInt(&iter, mixed_content_state); + + return true; } bool TabProxy::GetPageType(NavigationEntry::PageType* page_type) { @@ -679,17 +877,23 @@ bool TabProxy::GetPageType(NavigationEntry::PageType* page_type) { IPC::Message* response = NULL; bool is_timeout = false; - int value; - bool succeeded; - succeeded = sender_->SendAndWaitForResponseWithTimeout( + bool succeeded = sender_->SendAndWaitForResponseWithTimeout( new AutomationMsg_GetPageType(0, handle_), &response, - AutomationMsg_GetPageTypeResponse::ID, INFINITE, &is_timeout) && - AutomationMsg_GetPageTypeResponse::Read(response, &succeeded, &value); + AutomationMsg_GetPageTypeResponse::ID, INFINITE, &is_timeout); scoped_ptr<IPC::Message> auto_deleter(response); - if (succeeded) - *page_type = static_cast<NavigationEntry::PageType>(value); - return succeeded; + + if (!succeeded) + return false; + + void* iter = NULL; + int value; + response->ReadBool(&iter, &succeeded); + if (!succeeded) + return false; + response->ReadInt(&iter, &value); + *page_type = static_cast<NavigationEntry::PageType>(value); + return true; } bool TabProxy::TakeActionOnSSLBlockingPage(bool proceed) { @@ -697,15 +901,21 @@ bool TabProxy::TakeActionOnSSLBlockingPage(bool proceed) { return false; IPC::Message* response = NULL; - bool timeout = false; - bool success = sender_->SendAndWaitForResponseWithTimeout( + bool is_timeout = false; + bool succeeded = sender_->SendAndWaitForResponseWithTimeout( new AutomationMsg_ActionOnSSLBlockingPage(0, handle_, proceed), &response, - AutomationMsg_ActionOnSSLBlockingPageResponse::ID, INFINITE, &timeout) && - AutomationMsg_ActionOnSSLBlockingPageResponse::Read(response, &success) && - success; + AutomationMsg_ActionOnSSLBlockingPageResponse::ID, INFINITE, &is_timeout); scoped_ptr<IPC::Message> auto_deleter(response); - return success; + + if (!succeeded) + return false; + + void* iter = NULL; + bool status = false; + response->ReadBool(&iter, &status); + + return status; } bool TabProxy::PrintNow() { @@ -714,12 +924,15 @@ bool TabProxy::PrintNow() { IPC::Message* response = NULL; bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_PrintNowRequest(0, handle_), &response, - AutomationMsg_PrintNowResponse::ID) && - AutomationMsg_PrintNowResponse::Read(response, &succeeded) && - succeeded; + new AutomationMsg_PrintNowRequest(0, handle_), &response, + AutomationMsg_PrintNowResponse::ID); scoped_ptr<IPC::Message> auto_deleter(response); - return succeeded; + if (!succeeded) + return false; + + void* iter = NULL; + succeeded = false; + return response->ReadBool(&iter, &succeeded) && succeeded; } bool TabProxy::SavePage(const std::wstring& file_name, @@ -730,12 +943,18 @@ bool TabProxy::SavePage(const std::wstring& file_name, IPC::Message* response = NULL; bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_SavePageRequest( - 0, handle_, file_name, dir_path, static_cast<int>(type)), - &response, AutomationMsg_SavePageResponse::ID) && - AutomationMsg_SavePageResponse::Read(response, &succeeded) && - succeeded; - scoped_ptr<IPC::Message> auto_deleter(response); + new AutomationMsg_SavePageRequest(0, handle_, file_name, + dir_path, static_cast<int>(type)), + &response, + AutomationMsg_SavePageResponse::ID); + + if (!succeeded) + return false; + + void* iter = NULL; + response->ReadBool(&iter, &succeeded); + delete response; + return succeeded; } @@ -759,11 +978,15 @@ bool TabProxy::GetSSLInfoBarCount(int* count) { IPC::Message* response = NULL; bool success = sender_->SendAndWaitForResponse( new AutomationMsg_GetSSLInfoBarCountRequest(0, handle_), - &response, AutomationMsg_GetSSLInfoBarCountResponse::ID) && - AutomationMsg_GetSSLInfoBarCountResponse::Read(response, count) && - count >= 0; + &response, + AutomationMsg_GetSSLInfoBarCountResponse::ID); scoped_ptr<IPC::Message> auto_deleter(response); - return success; + if (!success) + return false; + + void* iter = NULL; + response->ReadInt(&iter, count); + return true; } bool TabProxy::ClickSSLInfoBarLink(int info_bar_index, @@ -773,26 +996,36 @@ bool TabProxy::ClickSSLInfoBarLink(int info_bar_index, IPC::Message* response = NULL; bool success = sender_->SendAndWaitForResponse( - new AutomationMsg_ClickSSLInfoBarLinkRequest( - 0, handle_, info_bar_index, wait_for_navigation), - &response, AutomationMsg_ClickSSLInfoBarLinkResponse::ID) && - AutomationMsg_ClickSSLInfoBarLinkResponse::Read(response, &success) && - success; + new AutomationMsg_ClickSSLInfoBarLinkRequest(0, handle_, + info_bar_index, + wait_for_navigation), + &response, + AutomationMsg_ClickSSLInfoBarLinkResponse::ID); scoped_ptr<IPC::Message> auto_deleter(response); + if (!success) + return false; + + void* iter = NULL; + response->ReadBool(&iter, &success); return success; } -bool TabProxy::GetLastNavigationTime(int64* nav_time) { +bool TabProxy::GetLastNavigationTime(int64* last_navigation_time) { if (!is_valid()) return false; IPC::Message* response = NULL; bool success = sender_->SendAndWaitForResponse( new AutomationMsg_GetLastNavigationTimeRequest(0, handle_), - &response, AutomationMsg_GetLastNavigationTimeResponse::ID) && - AutomationMsg_GetLastNavigationTimeResponse::Read(response, nav_time); + &response, + AutomationMsg_GetLastNavigationTimeResponse::ID); scoped_ptr<IPC::Message> auto_deleter(response); - return success; + if (!success) + return false; + + void* iter = NULL; + response->ReadInt64(&iter, last_navigation_time); + return true; } bool TabProxy::WaitForNavigation(int64 last_navigation_time) { @@ -801,12 +1034,17 @@ bool TabProxy::WaitForNavigation(int64 last_navigation_time) { IPC::Message* response = NULL; bool success = sender_->SendAndWaitForResponse( - new AutomationMsg_WaitForNavigationRequest( - 0, handle_, last_navigation_time), - &response, AutomationMsg_WaitForNavigationResponse::ID) && - AutomationMsg_WaitForNavigationResponse::Read(response, &success) && - success; + new AutomationMsg_WaitForNavigationRequest(0, + handle_, + last_navigation_time), + &response, + AutomationMsg_WaitForNavigationResponse::ID); scoped_ptr<IPC::Message> auto_deleter(response); + if (!success) + return false; + + void* iter = NULL; + response->ReadBool(&iter, &success); return success; } @@ -817,9 +1055,15 @@ bool TabProxy::GetPageCurrentEncoding(std::wstring* encoding) { IPC::Message* response; bool succeeded = sender_->SendAndWaitForResponse( new AutomationMsg_GetPageCurrentEncodingRequest(0, handle_), - &response, AutomationMsg_GetPageCurrentEncodingResponse::ID) && - AutomationMsg_GetPageCurrentEncodingResponse::Read(response, encoding); - scoped_ptr<IPC::Message> response_deleter(response); + &response, + AutomationMsg_GetPageCurrentEncodingResponse::ID); + + scoped_ptr<IPC::Message> response_deleter(response); // Delete on return. + if (!succeeded) + return false; + + void* iter = NULL; + succeeded = response->ReadWString(&iter, encoding); return succeeded; } @@ -830,9 +1074,15 @@ bool TabProxy::OverrideEncoding(const std::wstring& encoding) { IPC::Message* response; bool succeeded = sender_->SendAndWaitForResponse( new AutomationMsg_OverrideEncodingRequest(0, handle_, encoding), - &response, AutomationMsg_OverrideEncodingResponse::ID) && - AutomationMsg_OverrideEncodingResponse::Read(response, &succeeded) && - succeeded; - scoped_ptr<IPC::Message> response_deleter(response); - return succeeded; + &response, + AutomationMsg_OverrideEncodingResponse::ID); + + scoped_ptr<IPC::Message> response_deleter(response); // Delete on return. + if (!succeeded) + return false; + + void* iter = NULL; + bool successed_set_value = false; + succeeded = response->ReadBool(&iter, &successed_set_value); + return succeeded && successed_set_value; } diff --git a/chrome/test/unit/unit_tests.scons b/chrome/test/unit/unit_tests.scons index d0a06fe..d51503b 100644 --- a/chrome/test/unit/unit_tests.scons +++ b/chrome/test/unit/unit_tests.scons @@ -207,6 +207,7 @@ input_files = ChromeFileList([ '$CHROME_DIR/common/gfx/icon_util_unittest.cc', '$CHROME_DIR/common/ipc_message_unittest.cc', '$CHROME_DIR/common/ipc_sync_channel_unittest.cc', + '$CHROME_DIR/common/ipc_sync_channel_unittest.h', '$CHROME_DIR/common/ipc_sync_message_unittest.cc', '$CHROME_DIR/common/ipc_sync_message_unittest.h', '$CHROME_DIR/common/json_value_serializer_unittest.cc', diff --git a/chrome/test/unit/unittests.vcproj b/chrome/test/unit/unittests.vcproj index 0dfb9f3..fbd1da5 100644 --- a/chrome/test/unit/unittests.vcproj +++ b/chrome/test/unit/unittests.vcproj @@ -879,6 +879,10 @@ > </File> <File + RelativePath="..\..\common\ipc_sync_channel_unittest.h" + > + </File> + <File RelativePath="..\..\common\ipc_sync_message_unittest.cc" > </File> diff --git a/webkit/glue/glue_accessibility.cc b/webkit/glue/glue_accessibility.cc index 86c00f9..2d0c8f4 100644 --- a/webkit/glue/glue_accessibility.cc +++ b/webkit/glue/glue_accessibility.cc @@ -17,7 +17,6 @@ #include "webkit/glue/glue_accessibility.h" #include "base/ref_counted.h" -#include "chrome/common/render_messages.h" #include "webkit/glue/webframe_impl.h" #include "webkit/glue/webview_impl.h" diff --git a/webkit/glue/glue_accessibility.h b/webkit/glue/glue_accessibility.h index 1a97857..b801582 100644 --- a/webkit/glue/glue_accessibility.h +++ b/webkit/glue/glue_accessibility.h @@ -14,11 +14,9 @@ class IAccessible; #endif #include "base/hash_tables.h" -#include "base/ref_counted.h" +#include "chrome/common/render_messages.h" class WebView; -struct ViewMsg_Accessibility_In_Params; -struct ViewHostMsg_Accessibility_Out_Params; template <typename T> class COMPtr; |