From 946d1b2c806795351598aeb9faaed797284a8ee3 Mon Sep 17 00:00:00 2001 From: "agl@chromium.org" Date: Wed, 22 Jul 2009 23:57:21 +0000 Subject: [PATCH] Split the IPC code into ipc/ This splits the ipc code from the common project. The 'common' project pulls in all of webkit, the v8 bindings, skia, googleurl, and a number of other projects which makes it very difficult to deal with especially for external projects wanting just to use some of Chromium's infrastructure. This puts the ipc code into its top-level ipc/ directory with a dependency only on base. The common project depends on the new ipc/ipc.gyp:ipc target so that all projects currently pulling common in to get the IPC code still have it available. This mostly follows agl's pre-gyp attempt to do this which was r13062. Known issues: - Currently a number of projects depend on chrome/chrome.gyp:common in order to use the IPC infrastructure. Rather than fixing all of these dependencies I have made common depend on ipc/ipc.gyp:ipc and added "ipc" to the include_rules section of DEPS so that checkdeps.py doesn't complain. Over time projects that need IPC should depend on the IPC project themselves and dependencies on common removed, although I don't think many projects that need IPC will be able to get away without common currently. - ipc/ipc_message_macros.h still has #include "chrome/common/..." inside of a ipc/ should not refer to files in chrome/... now. I'm not sure how to resolve this since it's really an IDE bug - the named pipe name (windows+linux) and the logging event name (all) + env variable (posix) refer explicitly to 'Chrome' which somewhat hurts the illusion of ipc/ being an independent library. I think this should be examined in a subsequent, much smaller patch. - I've eliminated the IPC.SendMsgCount counter since it was implemented in a way to create a dependency from ipc/ to chrome/common/chrome_counters. This is the same approach that r13062 took. http://codereview.chromium.org/155905 (Patch from James Robinson) git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21342 0039d316-1c4b-4281-b951-d872f2087c98 --- DEPS | 1 + WATCHLISTS | 2 +- base/file_descriptor_posix.h | 2 +- build/all.gyp | 1 + chrome/app/breakpad_linux.cc | 2 +- chrome/browser/app_modal_dialog.cc | 2 +- .../browser/automation/automation_provider.h | 4 +- .../automation_resource_message_filter.h | 2 +- .../automation/automation_resource_tracker.h | 2 +- .../automation/extension_port_container.h | 2 +- .../extensions/extension_message_service.h | 2 +- .../dom_storage_dispatcher_host.h | 2 +- chrome/browser/jsmessage_box_handler.h | 2 +- chrome/browser/modal_html_dialog_delegate.h | 2 +- chrome/browser/net/resolve_proxy_msg_helper.h | 4 +- chrome/browser/plugin_process_host.cc | 6 +- chrome/browser/plugin_process_host.h | 2 +- .../renderer_host/audio_renderer_host.cc | 2 +- .../renderer_host/audio_renderer_host.h | 2 +- .../browser_render_process_host.cc | 2 +- .../renderer_host/render_process_host.h | 2 +- .../renderer_host/render_widget_host.h | 2 +- .../renderer_host/resource_dispatcher_host.h | 2 +- .../renderer_host/resource_message_filter.h | 2 +- chrome/browser/sandbox_policy.cc | 2 +- .../render_view_host_manager_unittest.cc | 2 +- .../tab_contents/web_contents_unittest.cc | 2 +- chrome/browser/utility_process_host.cc | 2 +- chrome/browser/utility_process_host.h | 2 +- chrome/browser/views/about_ipc_dialog.cc | 2 +- chrome/browser/views/about_ipc_dialog.h | 2 +- .../worker_host/worker_process_host.cc | 2 +- .../browser/worker_host/worker_process_host.h | 2 +- chrome/browser/worker_host/worker_service.h | 2 +- chrome/chrome.gyp | 62 +---- .../common/app_cache/app_cache_context_impl.h | 2 +- .../common/app_cache/app_cache_dispatcher.h | 2 +- .../app_cache/app_cache_dispatcher_host.h | 2 +- chrome/common/child_process_host.cc | 2 +- chrome/common/child_process_host.h | 2 +- chrome/common/child_thread.cc | 2 +- chrome/common/child_thread.h | 2 +- chrome/common/chrome_counters.cc | 5 - chrome/common/chrome_counters.h | 3 - chrome/common/chrome_descriptors.h | 6 +- ...essage_utils.cc => common_param_traits.cc} | 227 +--------------- chrome/common/common_param_traits.h | 251 ++++++++++++++++++ ...est.cc => common_param_traits_unittest.cc} | 5 +- chrome/common/devtools_messages.h | 2 +- chrome/common/devtools_messages_internal.h | 2 +- .../common/extensions/extension_unpacker.cc | 3 +- chrome/common/ipc_maybe.h | 19 -- chrome/common/ipc_test_sink.h | 2 +- chrome/common/logging_chrome.cc | 4 + chrome/common/message_router.h | 2 +- chrome/common/plugin_messages.h | 5 +- chrome/common/plugin_messages_internal.h | 2 +- chrome/common/render_messages.h | 5 +- chrome/common/render_messages_internal.h | 4 +- chrome/common/resource_dispatcher.h | 2 +- chrome/common/webkit_param_traits.h | 2 +- chrome/common/worker_messages.h | 5 +- chrome/common/worker_messages_internal.h | 2 +- chrome/plugin/npobject_proxy.h | 2 +- chrome/plugin/npobject_stub.h | 2 +- chrome/plugin/plugin_channel.cc | 2 +- chrome/plugin/plugin_channel_base.cc | 2 +- chrome/plugin/plugin_channel_base.h | 2 +- chrome/plugin/plugin_main.cc | 2 +- chrome/plugin/webplugin_delegate_stub.h | 2 +- chrome/plugin/webplugin_proxy.h | 2 +- chrome/renderer/audio_message_filter.cc | 2 +- chrome/renderer/audio_message_filter.h | 2 +- .../automation/dom_automation_controller.h | 2 +- chrome/renderer/devtools_agent_filter.h | 2 +- chrome/renderer/dom_ui_bindings.h | 2 +- chrome/renderer/external_host_bindings.h | 2 +- chrome/renderer/mock_printer.cc | 2 +- chrome/renderer/mock_render_thread.cc | 2 +- chrome/renderer/plugin_channel_host.cc | 2 +- chrome/renderer/render_process.cc | 4 +- chrome/renderer/render_thread_unittest.cc | 2 +- chrome/renderer/render_widget.h | 2 +- chrome/renderer/renderer_main_unittest.cc | 2 +- chrome/renderer/webplugin_delegate_proxy.cc | 2 +- chrome/renderer/webplugin_delegate_proxy.h | 2 +- chrome/renderer/webworker_proxy.h | 2 +- .../test/automation/autocomplete_edit_proxy.h | 4 +- chrome/test/automation/automation_messages.h | 5 +- .../automation/automation_messages_internal.h | 2 +- chrome/test/automation/automation_proxy.cc | 2 +- chrome/test/automation/automation_proxy.h | 6 +- chrome/worker/webworkerclient_proxy.cc | 2 +- chrome/worker/webworkerclient_proxy.h | 2 +- .../file_descriptor_set_posix.cc | 2 +- .../file_descriptor_set_posix.h | 6 +- .../file_descriptor_set_unittest.cc | 2 +- ipc/ipc.gyp | 108 ++++++++ {chrome/common => ipc}/ipc_channel.h | 8 +- {chrome/common => ipc}/ipc_channel_handle.h | 6 +- {chrome/common => ipc}/ipc_channel_posix.cc | 16 +- {chrome/common => ipc}/ipc_channel_posix.h | 10 +- {chrome/common => ipc}/ipc_channel_proxy.cc | 6 +- {chrome/common => ipc}/ipc_channel_proxy.h | 8 +- {chrome/common => ipc}/ipc_channel_win.cc | 8 +- {chrome/common => ipc}/ipc_channel_win.h | 8 +- ipc/ipc_descriptors.h | 14 + {chrome/common => ipc}/ipc_fuzzing_tests.cc | 12 +- {chrome/common => ipc}/ipc_logging.cc | 16 +- {chrome/common => ipc}/ipc_logging.h | 8 +- {chrome/common => ipc}/ipc_message.cc | 4 +- {chrome/common => ipc}/ipc_message.h | 6 +- {chrome/common => ipc}/ipc_message_macros.h | 4 +- ipc/ipc_message_unittest.cc | 67 +++++ ipc/ipc_message_utils.cc | 235 ++++++++++++++++ {chrome/common => ipc}/ipc_message_utils.h | 243 +---------------- {chrome/common => ipc}/ipc_send_fds_test.cc | 6 +- ipc/ipc_switches.cc | 28 ++ ipc/ipc_switches.h | 20 ++ {chrome/common => ipc}/ipc_sync_channel.cc | 4 +- {chrome/common => ipc}/ipc_sync_channel.h | 8 +- .../ipc_sync_channel_unittest.cc | 8 +- {chrome/common => ipc}/ipc_sync_message.cc | 2 +- {chrome/common => ipc}/ipc_sync_message.h | 8 +- .../ipc_sync_message_unittest.cc | 8 +- .../ipc_sync_message_unittest.h | 2 +- {chrome/common => ipc}/ipc_tests.cc | 12 +- {chrome/common => ipc}/ipc_tests.h | 6 +- 128 files changed, 945 insertions(+), 745 deletions(-) rename chrome/common/{ipc_message_utils.cc => common_param_traits.cc} (51%) create mode 100644 chrome/common/common_param_traits.h rename chrome/common/{ipc_message_unittest.cc => common_param_traits_unittest.cc} (97%) delete mode 100644 chrome/common/ipc_maybe.h rename {chrome/common => ipc}/file_descriptor_set_posix.cc (98%) rename {chrome/common => ipc}/file_descriptor_set_posix.h (96%) rename {chrome/common => ipc}/file_descriptor_set_unittest.cc (98%) create mode 100644 ipc/ipc.gyp rename {chrome/common => ipc}/ipc_channel.h (96%) rename {chrome/common => ipc}/ipc_channel_handle.h (90%) rename {chrome/common => ipc}/ipc_channel_posix.cc (98%) rename {chrome/common => ipc}/ipc_channel_posix.h (95%) rename {chrome/common => ipc}/ipc_channel_proxy.cc (98%) rename {chrome/common => ipc}/ipc_channel_proxy.h (98%) rename {chrome/common => ipc}/ipc_channel_win.cc (98%) rename {chrome/common => ipc}/ipc_channel_win.h (93%) create mode 100644 ipc/ipc_descriptors.h rename {chrome/common => ipc}/ipc_fuzzing_tests.cc (97%) rename {chrome/common => ipc}/ipc_logging.cc (93%) rename {chrome/common => ipc}/ipc_logging.h (94%) rename {chrome/common => ipc}/ipc_message.cc (97%) rename {chrome/common => ipc}/ipc_message.h (98%) rename {chrome/common => ipc}/ipc_message_macros.h (99%) create mode 100644 ipc/ipc_message_unittest.cc create mode 100644 ipc/ipc_message_utils.cc rename {chrome/common => ipc}/ipc_message_utils.h (83%) rename {chrome/common => ipc}/ipc_send_fds_test.cc (97%) create mode 100644 ipc/ipc_switches.cc create mode 100644 ipc/ipc_switches.h rename {chrome/common => ipc}/ipc_sync_channel.cc (99%) rename {chrome/common => ipc}/ipc_sync_channel.h (96%) rename {chrome/common => ipc}/ipc_sync_channel_unittest.cc (99%) rename {chrome/common => ipc}/ipc_sync_message.cc (98%) rename {chrome/common => ipc}/ipc_sync_message.h (94%) rename {chrome/common => ipc}/ipc_sync_message_unittest.cc (96%) rename {chrome/common => ipc}/ipc_sync_message_unittest.h (98%) rename {chrome/common => ipc}/ipc_tests.cc (98%) rename {chrome/common => ipc}/ipc_tests.h (91%) diff --git a/DEPS b/DEPS index 8b471b36f68744..b384d791e34191 100644 --- a/DEPS +++ b/DEPS @@ -101,6 +101,7 @@ include_rules = [ # Everybody can use some things. "+base", "+build", + "+ipc", # For now, we allow ICU to be included by specifying "unicode/...", although # this should probably change. diff --git a/WATCHLISTS b/WATCHLISTS index 475218cbdb65bf..a348fefcaa1adc 100644 --- a/WATCHLISTS +++ b/WATCHLISTS @@ -70,7 +70,7 @@ 'filepath': 'media|Media|^third_party/ffmpeg/', }, 'ipc': { - 'filepath': 'chrome/common/ipc.*', + 'filepath': 'ipc/ipc.*', }, 'linux-sandboxing': { 'filepath': 'sandbox/linux/.*', diff --git a/base/file_descriptor_posix.h b/base/file_descriptor_posix.h index 0bcd4b6c695566..e9199eda342e7c 100644 --- a/base/file_descriptor_posix.h +++ b/base/file_descriptor_posix.h @@ -12,7 +12,7 @@ namespace base { // able to use template specialisation to special-case their handling. // // WARNING: (Chromium only) There are subtleties to consider if serialising -// these objects over IPC. See comments in chrome/common/ipc_message_utils.h +// these objects over IPC. See comments in ipc/ipc_message_utils.h // above the template specialisation for this structure. // ----------------------------------------------------------------------------- struct FileDescriptor { diff --git a/build/all.gyp b/build/all.gyp index 14befd5b01d9b8..d33d1f62b73b8d 100644 --- a/build/all.gyp +++ b/build/all.gyp @@ -15,6 +15,7 @@ '../app/app.gyp:*', '../base/base.gyp:*', '../chrome/chrome.gyp:*', + '../ipc/ipc.gyp:*', '../media/media.gyp:*', '../net/net.gyp:*', '../printing/printing.gyp:*', diff --git a/chrome/app/breakpad_linux.cc b/chrome/app/breakpad_linux.cc index d9c41fd0ded36a..199371e9e9d00c 100644 --- a/chrome/app/breakpad_linux.cc +++ b/chrome/app/breakpad_linux.cc @@ -25,8 +25,8 @@ #include "breakpad/linux/linux_libc_support.h" #include "breakpad/linux/linux_syscall_support.h" #include "breakpad/linux/memory.h" -#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_descriptors.h" +#include "chrome/common/chrome_switches.h" #include "chrome/installer/util/google_update_settings.h" static const char kUploadURL[] = diff --git a/chrome/browser/app_modal_dialog.cc b/chrome/browser/app_modal_dialog.cc index aa876ccda1f934..8385626d82c0de 100644 --- a/chrome/browser/app_modal_dialog.cc +++ b/chrome/browser/app_modal_dialog.cc @@ -8,7 +8,7 @@ #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/notification_service.h" #include "chrome/common/notification_type.h" -#include "chrome/common/ipc_message.h" +#include "ipc/ipc_message.h" AppModalDialog::AppModalDialog(TabContents* tab_contents, const std::wstring& title, diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index ed23671ca6b2c3..c28cb1c9f00e36 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -25,10 +25,10 @@ #include "chrome/browser/browser_list.h" #include "chrome/browser/history/history.h" #include "chrome/browser/tab_contents/navigation_entry.h" -#include "chrome/common/ipc_message.h" -#include "chrome/common/ipc_channel.h" #include "chrome/common/notification_registrar.h" #include "chrome/test/automation/automation_constants.h" +#include "ipc/ipc_message.h" +#include "ipc/ipc_channel.h" #if defined(OS_WIN) #include "views/event.h" #endif // defined(OS_WIN) diff --git a/chrome/browser/automation/automation_resource_message_filter.h b/chrome/browser/automation/automation_resource_message_filter.h index 7bec5cacf1be78..240bafbf2969a7 100644 --- a/chrome/browser/automation/automation_resource_message_filter.h +++ b/chrome/browser/automation/automation_resource_message_filter.h @@ -9,7 +9,7 @@ #include "base/lock.h" #include "base/platform_thread.h" -#include "chrome/common/ipc_channel_proxy.h" +#include "ipc/ipc_channel_proxy.h" class URLRequestAutomationJob; class MessageLoop; diff --git a/chrome/browser/automation/automation_resource_tracker.h b/chrome/browser/automation/automation_resource_tracker.h index 859a1797ac1c08..9d3d1373d46d73 100644 --- a/chrome/browser/automation/automation_resource_tracker.h +++ b/chrome/browser/automation/automation_resource_tracker.h @@ -8,10 +8,10 @@ #include #include "base/basictypes.h" -#include "chrome/common/ipc_message.h" #include "chrome/common/notification_observer.h" #include "chrome/common/notification_registrar.h" #include "chrome/common/notification_type.h" +#include "ipc/ipc_message.h" template class Source; diff --git a/chrome/browser/automation/extension_port_container.h b/chrome/browser/automation/extension_port_container.h index 8eedd09fbb53e0..ae86daed315fba 100644 --- a/chrome/browser/automation/extension_port_container.h +++ b/chrome/browser/automation/extension_port_container.h @@ -9,7 +9,7 @@ #include "base/basictypes.h" #include "base/ref_counted.h" -#include "chrome/common/ipc_message.h" +#include "ipc/ipc_message.h" class AutomationProvider; class ExtensionMessageService; diff --git a/chrome/browser/extensions/extension_message_service.h b/chrome/browser/extensions/extension_message_service.h index 832451d81c79d6..3b4e3674c74f16 100644 --- a/chrome/browser/extensions/extension_message_service.h +++ b/chrome/browser/extensions/extension_message_service.h @@ -12,8 +12,8 @@ #include "base/linked_ptr.h" #include "base/lock.h" #include "base/ref_counted.h" -#include "chrome/common/ipc_message.h" #include "chrome/common/notification_registrar.h" +#include "ipc/ipc_message.h" class MessageLoop; class Profile; diff --git a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h index a495d974f809d7..edc8822d2c3e6c 100644 --- a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h +++ b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h @@ -6,7 +6,7 @@ #define CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_DISPATCHER_HOST_H_ #include "base/ref_counted.h" -#include "chrome/common/ipc_message.h" +#include "ipc/ipc_message.h" class WebKitContext; class WebKitThread; diff --git a/chrome/browser/jsmessage_box_handler.h b/chrome/browser/jsmessage_box_handler.h index a4c0bdb374a4c3..856c1c59185277 100644 --- a/chrome/browser/jsmessage_box_handler.h +++ b/chrome/browser/jsmessage_box_handler.h @@ -7,7 +7,7 @@ #include -#include "chrome/common/ipc_message.h" +#include "ipc/ipc_message.h" class GURL; class TabContents; diff --git a/chrome/browser/modal_html_dialog_delegate.h b/chrome/browser/modal_html_dialog_delegate.h index 17c2d7d2635f9c..bcd5361f6adab0 100644 --- a/chrome/browser/modal_html_dialog_delegate.h +++ b/chrome/browser/modal_html_dialog_delegate.h @@ -9,8 +9,8 @@ #include "base/gfx/size.h" #include "chrome/browser/dom_ui/html_dialog_ui.h" -#include "chrome/common/ipc_message.h" #include "chrome/common/notification_registrar.h" +#include "ipc/ipc_message.h" // This class can only be used on the UI thread. class ModalHtmlDialogDelegate diff --git a/chrome/browser/net/resolve_proxy_msg_helper.h b/chrome/browser/net/resolve_proxy_msg_helper.h index ee6f4afe5615e0..81d2e7ea655d6e 100644 --- a/chrome/browser/net/resolve_proxy_msg_helper.h +++ b/chrome/browser/net/resolve_proxy_msg_helper.h @@ -8,9 +8,9 @@ #include #include -#include "chrome/common/ipc_message.h" -#include "net/base/completion_callback.h" #include "googleurl/src/gurl.h" +#include "ipc/ipc_message.h" +#include "net/base/completion_callback.h" #include "net/proxy/proxy_service.h" // This class holds the common logic used to respond to the messages: diff --git a/chrome/browser/plugin_process_host.cc b/chrome/browser/plugin_process_host.cc index bfe5ea873e3f5f..b3b3756dd2b519 100644 --- a/chrome/browser/plugin_process_host.cc +++ b/chrome/browser/plugin_process_host.cc @@ -34,14 +34,14 @@ #include "chrome/browser/renderer_host/browser_render_process_host.h" #include "chrome/browser/renderer_host/render_process_host.h" #include "chrome/browser/renderer_host/resource_dispatcher_host.h" -#include "chrome/common/chrome_descriptors.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_plugin_lib.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/logging_chrome.h" #include "chrome/common/plugin_messages.h" #include "chrome/common/render_messages.h" -#include "chrome/common/ipc_channel_handle.h" +#include "ipc/ipc_channel_handle.h" +#include "ipc/ipc_descriptors.h" #include "net/base/cookie_monster.h" #include "net/base/file_stream.h" #include "net/base/io_buffer.h" @@ -56,7 +56,7 @@ #endif #if defined(OS_POSIX) -#include "chrome/common/ipc_channel_posix.h" +#include "ipc/ipc_channel_posix.h" #endif #if defined(OS_LINUX) diff --git a/chrome/browser/plugin_process_host.h b/chrome/browser/plugin_process_host.h index 62efdbda350560..8c3a948b6a5fe6 100644 --- a/chrome/browser/plugin_process_host.h +++ b/chrome/browser/plugin_process_host.h @@ -18,7 +18,7 @@ #include "chrome/browser/net/resolve_proxy_msg_helper.h" #include "chrome/browser/renderer_host/resource_message_filter.h" #include "chrome/common/child_process_host.h" -#include "chrome/common/ipc_channel_handle.h" +#include "ipc/ipc_channel_handle.h" #include "webkit/glue/webplugininfo.h" class URLRequestContext; diff --git a/chrome/browser/renderer_host/audio_renderer_host.cc b/chrome/browser/renderer_host/audio_renderer_host.cc index 4ba0a24aaaa80e..495a8eab77934f 100644 --- a/chrome/browser/renderer_host/audio_renderer_host.cc +++ b/chrome/browser/renderer_host/audio_renderer_host.cc @@ -9,8 +9,8 @@ #include "base/shared_memory.h" #include "base/waitable_event.h" #include "chrome/browser/renderer_host/audio_renderer_host.h" -#include "chrome/common/ipc_logging.h" #include "chrome/common/render_messages.h" +#include "ipc/ipc_logging.h" namespace { diff --git a/chrome/browser/renderer_host/audio_renderer_host.h b/chrome/browser/renderer_host/audio_renderer_host.h index 01a3545431bd0a..9326cf7bb41ce2 100644 --- a/chrome/browser/renderer_host/audio_renderer_host.h +++ b/chrome/browser/renderer_host/audio_renderer_host.h @@ -75,7 +75,7 @@ #include "base/ref_counted.h" #include "base/shared_memory.h" #include "base/waitable_event.h" -#include "chrome/common/ipc_message.h" +#include "ipc/ipc_message.h" #include "media/audio/audio_output.h" #include "media/audio/simple_sources.h" #include "testing/gtest/include/gtest/gtest_prod.h" diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc index f8142f5fd0b837..2370fd3881fcfc 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -46,8 +46,8 @@ #include "chrome/browser/spellchecker.h" #include "chrome/browser/visitedlink_master.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/chrome_descriptors.h" #include "chrome/common/child_process_info.h" +#include "chrome/common/chrome_descriptors.h" #include "chrome/common/logging_chrome.h" #include "chrome/common/notification_service.h" #include "chrome/common/process_watcher.h" diff --git a/chrome/browser/renderer_host/render_process_host.h b/chrome/browser/renderer_host/render_process_host.h index 93d94cdc5949d3..4ce37411def70e 100644 --- a/chrome/browser/renderer_host/render_process_host.h +++ b/chrome/browser/renderer_host/render_process_host.h @@ -11,9 +11,9 @@ #include "base/id_map.h" #include "base/process.h" #include "base/scoped_ptr.h" -#include "chrome/common/ipc_sync_channel.h" #include "chrome/common/transport_dib.h" #include "chrome/common/visitedlink_common.h" +#include "ipc/ipc_sync_channel.h" class Profile; diff --git a/chrome/browser/renderer_host/render_widget_host.h b/chrome/browser/renderer_host/render_widget_host.h index b1e6e8a13e2477..edace908a68747 100644 --- a/chrome/browser/renderer_host/render_widget_host.h +++ b/chrome/browser/renderer_host/render_widget_host.h @@ -13,9 +13,9 @@ #include "base/gfx/size.h" #include "base/scoped_ptr.h" #include "base/timer.h" -#include "chrome/common/ipc_channel.h" #include "chrome/common/native_web_keyboard_event.h" #include "chrome/common/property_bag.h" +#include "ipc/ipc_channel.h" #include "testing/gtest/include/gtest/gtest_prod.h" #include "webkit/api/public/WebTextDirection.h" diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.h b/chrome/browser/renderer_host/resource_dispatcher_host.h index 9a19249799803e..7a0d42202b98e4 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host.h +++ b/chrome/browser/renderer_host/resource_dispatcher_host.h @@ -24,7 +24,7 @@ #include "chrome/browser/renderer_host/resource_handler.h" #include "chrome/common/child_process_info.h" #include "chrome/common/filter_policy.h" -#include "chrome/common/ipc_message.h" +#include "ipc/ipc_message.h" #include "net/url_request/url_request.h" #include "webkit/glue/resource_type.h" diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h index 7ac5b854768bf0..379cfdb9f5bfb4 100644 --- a/chrome/browser/renderer_host/resource_message_filter.h +++ b/chrome/browser/renderer_host/resource_message_filter.h @@ -19,10 +19,10 @@ #include "chrome/browser/net/resolve_proxy_msg_helper.h" #include "chrome/browser/renderer_host/render_widget_helper.h" #include "chrome/browser/renderer_host/resource_dispatcher_host.h" -#include "chrome/common/ipc_channel_proxy.h" #include "chrome/common/modal_dialog_event.h" #include "chrome/common/notification_registrar.h" #include "chrome/common/transport_dib.h" +#include "ipc/ipc_channel_proxy.h" #include "webkit/api/public/WebCache.h" #if defined(OS_WIN) diff --git a/chrome/browser/sandbox_policy.cc b/chrome/browser/sandbox_policy.cc index 8789c664519f25..a447650bc71200 100644 --- a/chrome/browser/sandbox_policy.cc +++ b/chrome/browser/sandbox_policy.cc @@ -20,8 +20,8 @@ #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/debug_flags.h" -#include "chrome/common/ipc_logging.h" #include "chrome/common/notification_service.h" +#include "ipc/ipc_logging.h" #include "sandbox/src/sandbox.h" #include "webkit/glue/plugins/plugin_list.h" diff --git a/chrome/browser/tab_contents/render_view_host_manager_unittest.cc b/chrome/browser/tab_contents/render_view_host_manager_unittest.cc index 6cf549e2965461..699b9e058b925f 100644 --- a/chrome/browser/tab_contents/render_view_host_manager_unittest.cc +++ b/chrome/browser/tab_contents/render_view_host_manager_unittest.cc @@ -6,10 +6,10 @@ #include "chrome/browser/tab_contents/navigation_controller.h" #include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/tab_contents/render_view_host_manager.h" -#include "chrome/common/ipc_message.h" #include "chrome/common/render_messages.h" #include "chrome/common/url_constants.h" #include "chrome/test/test_notification_tracker.h" +#include "ipc/ipc_message.h" #include "testing/gtest/include/gtest/gtest.h" class RenderViewHostManagerTest : public RenderViewHostTestHarness { diff --git a/chrome/browser/tab_contents/web_contents_unittest.cc b/chrome/browser/tab_contents/web_contents_unittest.cc index 15229a1652deec..47426c4c47e906 100644 --- a/chrome/browser/tab_contents/web_contents_unittest.cc +++ b/chrome/browser/tab_contents/web_contents_unittest.cc @@ -12,10 +12,10 @@ #include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/tab_contents/test_web_contents.h" #include "chrome/common/chrome_paths.h" -#include "chrome/common/ipc_channel.h" #include "chrome/common/pref_service.h" #include "chrome/common/render_messages.h" #include "chrome/test/testing_profile.h" +#include "ipc/ipc_channel.h" #include "testing/gtest/include/gtest/gtest.h" using webkit_glue::PasswordForm; diff --git a/chrome/browser/utility_process_host.cc b/chrome/browser/utility_process_host.cc index 0b33d907eb254d..d919b4c48eeccb 100644 --- a/chrome/browser/utility_process_host.cc +++ b/chrome/browser/utility_process_host.cc @@ -18,7 +18,7 @@ #include "chrome/browser/sandbox_policy.h" #elif defined(OS_POSIX) #include "base/global_descriptors_posix.h" -#include "chrome/common/chrome_descriptors.h" +#include "ipc/ipc_descriptors.h" #endif UtilityProcessHost::UtilityProcessHost(ResourceDispatcherHost* rdh, diff --git a/chrome/browser/utility_process_host.h b/chrome/browser/utility_process_host.h index ba87a3e580cfaf..329f8568cbbe80 100644 --- a/chrome/browser/utility_process_host.h +++ b/chrome/browser/utility_process_host.h @@ -11,7 +11,7 @@ #include "base/ref_counted.h" #include "base/task.h" #include "chrome/common/child_process_host.h" -#include "chrome/common/ipc_channel.h" +#include "ipc/ipc_channel.h" class CommandLine; class DictionaryValue; diff --git a/chrome/browser/views/about_ipc_dialog.cc b/chrome/browser/views/about_ipc_dialog.cc index f6168557bfac00..75be11425fd4eb 100644 --- a/chrome/browser/views/about_ipc_dialog.cc +++ b/chrome/browser/views/about_ipc_dialog.cc @@ -6,7 +6,7 @@ // IPC_MESSAGE_LOG_ENABLED. We need to use it to define // IPC_MESSAGE_MACROS_LOG_ENABLED so render_messages.h will generate the // ViewMsgLog et al. functions. -#include "chrome/common/ipc_message.h" +#include "ipc/ipc_message.h" #ifdef IPC_MESSAGE_LOG_ENABLED #define IPC_MESSAGE_MACROS_LOG_ENABLED diff --git a/chrome/browser/views/about_ipc_dialog.h b/chrome/browser/views/about_ipc_dialog.h index d111eac89a0e4e..0ba6090fff940c 100644 --- a/chrome/browser/views/about_ipc_dialog.h +++ b/chrome/browser/views/about_ipc_dialog.h @@ -6,7 +6,7 @@ #define CHROME_BROWSER_VIEWS_ABOUT_IPC_DIALOG_H_ #include "base/singleton.h" -#include "chrome/common/ipc_logging.h" +#include "ipc/ipc_logging.h" #include "views/controls/button/button.h" #include "views/controls/table/table_view.h" #include "views/window/dialog_delegate.h" diff --git a/chrome/browser/worker_host/worker_process_host.cc b/chrome/browser/worker_host/worker_process_host.cc index d76fecbb300e7c..c8ce3b1272392d 100644 --- a/chrome/browser/worker_host/worker_process_host.cc +++ b/chrome/browser/worker_host/worker_process_host.cc @@ -19,12 +19,12 @@ #include "chrome/browser/child_process_security_policy.h" #include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/browser/worker_host/worker_service.h" -#include "chrome/common/chrome_descriptors.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/debug_flags.h" #include "chrome/common/process_watcher.h" #include "chrome/common/render_messages.h" #include "chrome/common/worker_messages.h" +#include "ipc/ipc_descriptors.h" #include "net/base/registry_controlled_domain.h" #if defined(OS_WIN) diff --git a/chrome/browser/worker_host/worker_process_host.h b/chrome/browser/worker_host/worker_process_host.h index fca046e0c6cd60..00a6642087996d 100644 --- a/chrome/browser/worker_host/worker_process_host.h +++ b/chrome/browser/worker_host/worker_process_host.h @@ -9,8 +9,8 @@ #include "base/basictypes.h" #include "chrome/common/child_process_host.h" -#include "chrome/common/ipc_channel.h" #include "googleurl/src/gurl.h" +#include "ipc/ipc_channel.h" class WorkerProcessHost : public ChildProcessHost { public: diff --git a/chrome/browser/worker_host/worker_service.h b/chrome/browser/worker_host/worker_service.h index ba5760ffb55f23..45e8248cfdd1e9 100644 --- a/chrome/browser/worker_host/worker_service.h +++ b/chrome/browser/worker_host/worker_service.h @@ -10,9 +10,9 @@ #include "base/basictypes.h" #include "base/singleton.h" #include "chrome/browser/worker_host/worker_process_host.h" -#include "chrome/common/ipc_message.h" #include "chrome/common/notification_registrar.h" #include "googleurl/src/gurl.h" +#include "ipc/ipc_message.h" class MessageLoop; diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 8adc0f7a9ace47..d4f1810659ac89 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -300,6 +300,7 @@ '../base/base.gyp:base', '../base/base.gyp:base_gfx', '../build/temp_gyp/googleurl.gyp:googleurl', + '../ipc/ipc.gyp:ipc', '../net/net.gyp:net', '../skia/skia.gyp:skia', '../third_party/icu38/icu38.gyp:icui18n', @@ -361,6 +362,7 @@ 'common/chrome_constants.h', 'common/chrome_counters.cc', 'common/chrome_counters.h', + 'common/chrome_descriptors.h', 'common/chrome_paths.cc', 'common/chrome_paths.h', 'common/chrome_paths_internal.h', @@ -377,14 +379,14 @@ 'common/classfactory.cc', 'common/classfactory.h', 'common/common_glue.cc', + 'common/common_param_traits.cc', + 'common/common_param_traits.h', 'common/debug_flags.cc', 'common/debug_flags.h', 'common/devtools_messages.h', 'common/devtools_messages_internal.h', 'common/env_vars.cc', 'common/env_vars.h', - 'common/file_descriptor_set_posix.cc', - 'common/file_descriptor_set_posix.h', 'common/filter_policy.h', 'common/gears_api.h', 'common/gtk_util.cc', @@ -393,25 +395,6 @@ 'common/histogram_synchronizer.h', 'common/important_file_writer.cc', 'common/important_file_writer.h', - 'common/ipc_channel.h', - 'common/ipc_channel_handle.h', - 'common/ipc_channel_posix.cc', - 'common/ipc_channel_posix.h', - 'common/ipc_channel_proxy.cc', - 'common/ipc_channel_proxy.h', - 'common/ipc_channel_win.cc', - 'common/ipc_channel_win.h', - 'common/ipc_logging.cc', - 'common/ipc_logging.h', - 'common/ipc_message.cc', - 'common/ipc_message.h', - 'common/ipc_message_macros.h', - 'common/ipc_message_utils.cc', - 'common/ipc_message_utils.h', - 'common/ipc_sync_channel.cc', - 'common/ipc_sync_channel.h', - 'common/ipc_sync_message.cc', - 'common/ipc_sync_message.h', 'common/json_value_serializer.cc', 'common/json_value_serializer.h', 'common/jstemplate_builder.cc', @@ -3478,35 +3461,6 @@ }], ], }, - { - 'target_name': 'ipc_tests', - 'type': 'executable', - 'msvs_guid': 'B92AE829-E1CD-4781-824A-DCB1603A1672', - 'dependencies': [ - 'common', - 'test_support_unit', - '../base/base.gyp:base', - '../testing/gtest.gyp:gtest', - ], - 'sources': [ - 'common/ipc_fuzzing_tests.cc', - 'common/ipc_send_fds_test.cc', - 'common/ipc_tests.cc', - 'common/ipc_tests.h', - ], - 'conditions': [ - ['OS=="linux"', { - 'dependencies': [ - '../build/linux/system.gyp:gtk', - ], - }], - ['OS=="linux" and toolkit_views==1', { - 'dependencies': [ - '../views/views.gyp:views', - ], - }], - ], - }, { 'target_name': 'ui_tests', 'type': 'executable', @@ -3660,6 +3614,7 @@ 'test_support_unit', 'utility', '../app/app.gyp:app_resources', + '../ipc/ipc.gyp:ipc', '../net/net.gyp:net_resources', '../net/net.gyp:net_test_support', '../printing/printing.gyp:printing', @@ -3883,15 +3838,11 @@ 'common/bzip2_unittest.cc', 'common/child_process_logging_mac_unittest.mm', 'common/chrome_plugin_unittest.cc', + 'common/common_param_traits_unittest.cc', 'common/extensions/extension_unittest.cc', 'common/extensions/url_pattern_unittest.cc', 'common/extensions/user_script_unittest.cc', - 'common/file_descriptor_set_unittest.cc', 'common/important_file_writer_unittest.cc', - 'common/ipc_message_unittest.cc', - 'common/ipc_sync_channel_unittest.cc', - 'common/ipc_sync_message_unittest.cc', - 'common/ipc_sync_message_unittest.h', 'common/json_value_serializer_unittest.cc', 'common/mru_cache_unittest.cc', 'common/net/url_util_unittest.cc', @@ -4029,7 +3980,6 @@ ], 'sources!': [ 'browser/gtk/tabs/tab_renderer_gtk_unittest.cc', - 'common/file_descriptor_set_unittest.cc', 'common/net/url_util_unittest.cc', ], 'link_settings': { diff --git a/chrome/common/app_cache/app_cache_context_impl.h b/chrome/common/app_cache/app_cache_context_impl.h index dadf99d9b9332f..ec2f25fcc533c5 100644 --- a/chrome/common/app_cache/app_cache_context_impl.h +++ b/chrome/common/app_cache/app_cache_context_impl.h @@ -6,7 +6,7 @@ #define CHROME_COMMON_APP_CACHE_APP_CACHE_CONTEXT_IMPL_H_ #include "base/id_map.h" -#include "chrome/common/ipc_message.h" +#include "ipc/ipc_message.h" #include "webkit/glue/webappcachecontext.h" // A concrete implemenation of WebAppCacheContext for use in a child process. diff --git a/chrome/common/app_cache/app_cache_dispatcher.h b/chrome/common/app_cache/app_cache_dispatcher.h index c8baf28de55d0d..3d4cbbd3b96bdb 100644 --- a/chrome/common/app_cache/app_cache_dispatcher.h +++ b/chrome/common/app_cache/app_cache_dispatcher.h @@ -6,7 +6,7 @@ #define CHROME_COMMON_APP_CACHE_APP_CACHE_DISPATCHER_H_ #include "base/basictypes.h" -#include "chrome/common/ipc_message.h" +#include "ipc/ipc_message.h" // Dispatches app cache related messages sent to a child process from the // main browser process. There is one instance per child process. Messages diff --git a/chrome/common/app_cache/app_cache_dispatcher_host.h b/chrome/common/app_cache/app_cache_dispatcher_host.h index e84a7fd95104fa..749e74a1b8bb2b 100644 --- a/chrome/common/app_cache/app_cache_dispatcher_host.h +++ b/chrome/common/app_cache/app_cache_dispatcher_host.h @@ -6,7 +6,7 @@ #define CHROME_COMMON_APP_CACHE_APP_CACHE_DISPATCHER_HOST_H_ #include "base/id_map.h" -#include "chrome/common/ipc_message.h" +#include "ipc/ipc_message.h" #include "webkit/glue/webappcachecontext.h" class GURL; diff --git a/chrome/common/child_process_host.cc b/chrome/common/child_process_host.cc index 67d9a5a89ab4f1..b7cab7faba498f 100644 --- a/chrome/common/child_process_host.cc +++ b/chrome/common/child_process_host.cc @@ -11,12 +11,12 @@ #include "base/singleton.h" #include "base/waitable_event.h" #include "chrome/browser/chrome_thread.h" -#include "chrome/common/ipc_logging.h" #include "chrome/common/notification_service.h" #include "chrome/common/notification_type.h" #include "chrome/common/plugin_messages.h" #include "chrome/common/process_watcher.h" #include "chrome/common/result_codes.h" +#include "ipc/ipc_logging.h" namespace { diff --git a/chrome/common/child_process_host.h b/chrome/common/child_process_host.h index 3b97200ee9bc17..926bdd25efaaa7 100644 --- a/chrome/common/child_process_host.h +++ b/chrome/common/child_process_host.h @@ -11,7 +11,7 @@ #include "base/basictypes.h" #include "base/scoped_ptr.h" #include "chrome/browser/renderer_host/resource_dispatcher_host.h" -#include "chrome/common/ipc_channel.h" +#include "ipc/ipc_channel.h" class NotificationType; diff --git a/chrome/common/child_thread.cc b/chrome/common/child_thread.cc index 4c97b727f609bd..15a98b3111c61f 100644 --- a/chrome/common/child_thread.cc +++ b/chrome/common/child_thread.cc @@ -8,8 +8,8 @@ #include "base/command_line.h" #include "chrome/common/child_process.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/ipc_logging.h" #include "chrome/common/plugin_messages.h" +#include "ipc/ipc_logging.h" #include "webkit/glue/webkit_glue.h" diff --git a/chrome/common/child_thread.h b/chrome/common/child_thread.h index cc4abaa3c2e42d..1affe2587d81ea 100644 --- a/chrome/common/child_thread.h +++ b/chrome/common/child_thread.h @@ -8,9 +8,9 @@ #include "base/basictypes.h" #include "base/scoped_ptr.h" #include "base/thread.h" -#include "chrome/common/ipc_sync_channel.h" #include "chrome/common/message_router.h" #include "chrome/common/resource_dispatcher.h" +#include "ipc/ipc_sync_channel.h" // Child processes's background thread should derive from this class. class ChildThread : public IPC::Channel::Listener, diff --git a/chrome/common/chrome_counters.cc b/chrome/common/chrome_counters.cc index 98a977b6b9d8cb..fea09065ad9c12 100644 --- a/chrome/common/chrome_counters.cc +++ b/chrome/common/chrome_counters.cc @@ -19,11 +19,6 @@ namespace chrome { // we'd leak the extraneous StatsCounter object once, and that // would be it. But these are small objects, so this is ok. -StatsCounter& Counters::ipc_send_counter() { - static StatsCounter* ctr = new StatsCounter("IPC.SendMsgCount"); - return *ctr; -} - StatsCounterTimer& Counters::chrome_main() { static StatsCounterTimer* ctr = new StatsCounterTimer("Chrome.Init"); return *ctr; diff --git a/chrome/common/chrome_counters.h b/chrome/common/chrome_counters.h index c7975f85a9924b..14cfa210b11449 100644 --- a/chrome/common/chrome_counters.h +++ b/chrome/common/chrome_counters.h @@ -15,9 +15,6 @@ namespace chrome { class Counters { public: - // The number of messages sent on IPC channels. - static StatsCounter& ipc_send_counter(); - // The amount of time spent in chrome initialization. static StatsCounterTimer& chrome_main(); diff --git a/chrome/common/chrome_descriptors.h b/chrome/common/chrome_descriptors.h index c86eee54af6da5..8a4f6ee1e4e4d7 100644 --- a/chrome/common/chrome_descriptors.h +++ b/chrome/common/chrome_descriptors.h @@ -5,12 +5,12 @@ #ifndef CHROME_COMMON_CHROME_DESCRIPTORS_H_ #define CHROME_COMMON_CHROME_DESCRIPTORS_H_ +#include "ipc/ipc_descriptors.h" // This is a list of global descriptor keys to be used with the // base::GlobalDescriptors object (see base/global_descriptors_posix.h) enum { - kPrimaryIPCChannel = 0, - kCrashDumpSignal = 1, - kSandboxIPCChannel = 2, // http://code.google.com/p/chromium/LinuxSandboxIPC + kCrashDumpSignal = kPrimaryIPCChannel + 1, + kSandboxIPCChannel = kPrimaryIPCChannel + 2, // http://code.google.com/p/chromium/LinuxSandboxIPC }; #endif // CHROME_COMMON_CHROME_DESCRIPTORS_H_ diff --git a/chrome/common/ipc_message_utils.cc b/chrome/common/common_param_traits.cc similarity index 51% rename from chrome/common/ipc_message_utils.cc rename to chrome/common/common_param_traits.cc index e7ff9561e3b0bc..38682ba25268ff 100644 --- a/chrome/common/ipc_message_utils.cc +++ b/chrome/common/common_param_traits.cc @@ -2,12 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/common/ipc_message_utils.h" +#include "chrome/common/common_param_traits.h" #include "base/gfx/rect.h" -#include "base/json_writer.h" -#include "base/scoped_ptr.h" -#include "base/values.h" #include "googleurl/src/gurl.h" #ifndef EXCLUDE_SKIA_DEPENDENCIES #include "third_party/skia/include/core/SkBitmap.h" @@ -16,8 +13,6 @@ namespace IPC { -const int kMaxRecursionDepth = 100; - #ifndef EXCLUDE_SKIA_DEPENDENCIES namespace { @@ -226,223 +221,5 @@ void ParamTraits::Log( l->append(L""); } -// Value serialization - -static bool ReadValue(const Message* m, void** iter, Value** value, - int recursion); - -static void WriteValue(Message* m, const Value* value, int recursion) { - if (recursion > kMaxRecursionDepth) { - LOG(WARNING) << "Max recursion depth hit in WriteValue."; - return; - } - - m->WriteInt(value->GetType()); - - switch (value->GetType()) { - case Value::TYPE_NULL: - break; - case Value::TYPE_BOOLEAN: { - bool val; - value->GetAsBoolean(&val); - WriteParam(m, val); - break; - } - case Value::TYPE_INTEGER: { - int val; - value->GetAsInteger(&val); - WriteParam(m, val); - break; - } - case Value::TYPE_REAL: { - double val; - value->GetAsReal(&val); - WriteParam(m, val); - break; - } - case Value::TYPE_STRING: { - std::string val; - value->GetAsString(&val); - WriteParam(m, val); - break; - } - case Value::TYPE_BINARY: { - NOTREACHED() << "Don't send BinaryValues over IPC."; - } - case Value::TYPE_DICTIONARY: { - const DictionaryValue* dict = static_cast(value); - - WriteParam(m, static_cast(dict->GetSize())); - - for (DictionaryValue::key_iterator it = dict->begin_keys(); - it != dict->end_keys(); ++it) { - Value* subval; - if (dict->Get(*it, &subval)) { - WriteParam(m, *it); - WriteValue(m, subval, recursion + 1); - } else { - NOTREACHED() << "DictionaryValue iterators are filthy liars."; - } - } - break; - } - case Value::TYPE_LIST: { - const ListValue* list = static_cast(value); - WriteParam(m, static_cast(list->GetSize())); - for (size_t i = 0; i < list->GetSize(); ++i) { - Value* subval; - if (list->Get(i, &subval)) { - WriteValue(m, subval, recursion + 1); - } else { - NOTREACHED() << "ListValue::GetSize is a filthy liar."; - } - } - break; - } - } -} - -// Helper for ReadValue that reads a DictionaryValue into a pre-allocated -// object. -static bool ReadDictionaryValue(const Message* m, void** iter, - DictionaryValue* value, int recursion) { - int size; - if (!ReadParam(m, iter, &size)) - return false; - - for (int i = 0; i < size; ++i) { - std::wstring key; - Value* subval; - if (!ReadParam(m, iter, &key) || - !ReadValue(m, iter, &subval, recursion + 1)) - return false; - value->Set(key, subval); - } - - return true; -} - -// Helper for ReadValue that reads a ReadListValue into a pre-allocated -// object. -static bool ReadListValue(const Message* m, void** iter, - ListValue* value, int recursion) { - int size; - if (!ReadParam(m, iter, &size)) - return false; - - for (int i = 0; i < size; ++i) { - Value* subval; - if (!ReadValue(m, iter, &subval, recursion + 1)) - return false; - value->Set(i, subval); - } - - return true; -} - -static bool ReadValue(const Message* m, void** iter, Value** value, - int recursion) { - if (recursion > kMaxRecursionDepth) { - LOG(WARNING) << "Max recursion depth hit in ReadValue."; - return false; - } - - int type; - if (!ReadParam(m, iter, &type)) - return false; - - switch (type) { - case Value::TYPE_NULL: - *value = Value::CreateNullValue(); - break; - case Value::TYPE_BOOLEAN: { - bool val; - if (!ReadParam(m, iter, &val)) - return false; - *value = Value::CreateBooleanValue(val); - break; - } - case Value::TYPE_INTEGER: { - int val; - if (!ReadParam(m, iter, &val)) - return false; - *value = Value::CreateIntegerValue(val); - break; - } - case Value::TYPE_REAL: { - double val; - if (!ReadParam(m, iter, &val)) - return false; - *value = Value::CreateRealValue(val); - break; - } - case Value::TYPE_STRING: { - std::string val; - if (!ReadParam(m, iter, &val)) - return false; - *value = Value::CreateStringValue(val); - break; - } - case Value::TYPE_BINARY: { - NOTREACHED() << "Don't send BinaryValues over IPC."; - break; - } - case Value::TYPE_DICTIONARY: { - scoped_ptr val(new DictionaryValue()); - if (!ReadDictionaryValue(m, iter, val.get(), recursion)) - return false; - *value = val.release(); - break; - } - case Value::TYPE_LIST: { - scoped_ptr val(new ListValue()); - if (!ReadListValue(m, iter, val.get(), recursion)) - return false; - *value = val.release(); - break; - } - default: - return false; - } - - return true; -} - -void ParamTraits::Write(Message* m, const param_type& p) { - WriteValue(m, &p, 0); -} - -bool ParamTraits::Read( - const Message* m, void** iter, param_type* r) { - int type; - if (!ReadParam(m, iter, &type) || type != Value::TYPE_DICTIONARY) - return false; - - return ReadDictionaryValue(m, iter, r, 0); -} - -void ParamTraits::Log(const param_type& p, std::wstring* l) { - std::string json; - JSONWriter::Write(&p, false, &json); - l->append(UTF8ToWide(json)); -} - -void ParamTraits::Write(Message* m, const param_type& p) { - WriteValue(m, &p, 0); -} - -bool ParamTraits::Read( - const Message* m, void** iter, param_type* r) { - int type; - if (!ReadParam(m, iter, &type) || type != Value::TYPE_LIST) - return false; - - return ReadListValue(m, iter, r, 0); -} - -void ParamTraits::Log(const param_type& p, std::wstring* l) { - std::string json; - JSONWriter::Write(&p, false, &json); - l->append(UTF8ToWide(json)); -} } // namespace IPC + diff --git a/chrome/common/common_param_traits.h b/chrome/common/common_param_traits.h new file mode 100644 index 00000000000000..c34d55f2b5048e --- /dev/null +++ b/chrome/common/common_param_traits.h @@ -0,0 +1,251 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This file is used to define IPC::ParamTraits<> specializations for a number +// of types so that they can be serialized over IPC. IPC::ParamTraits<> +// specializations for basic types (like int and std::string) and types in the +// 'base' project can be found in ipc/ipc_message_utils.h. This file contains +// specializations for types that are shared by more than one child process. + +#ifndef CHROME_COMMON_COMMON_PARAM_TRAITS_H_ +#define CHROME_COMMON_COMMON_PARAM_TRAITS_H_ + +#include "base/gfx/native_widget_types.h" +#include "chrome/common/thumbnail_score.h" +#include "chrome/common/transport_dib.h" +#include "ipc/ipc_message_utils.h" +#include "net/url_request/url_request_status.h" +#include "webkit/glue/webcursor.h" +#include "webkit/glue/window_open_disposition.h" + +// Forward declarations. +class GURL; +class SkBitmap; +class DictionaryValue; +class ListValue; + +namespace gfx { +class Point; +class Rect; +class Size; +} // namespace gfx + +namespace webkit_glue { +struct WebApplicationInfo; +} // namespace webkit_glue + +namespace IPC { + +template <> +struct ParamTraits { + typedef SkBitmap param_type; + 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 Message* m, void** iter, param_type* r); + + static void Log(const param_type& p, std::wstring* l); +}; + + +template <> +struct ParamTraits { + typedef GURL param_type; + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, void** iter, param_type* p); + static void Log(const param_type& p, std::wstring* l); +}; + + +template <> +struct ParamTraits { + typedef gfx::Point param_type; + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, void** iter, param_type* r); + static void Log(const param_type& p, std::wstring* l); +}; + +template <> +struct ParamTraits { + typedef gfx::Rect param_type; + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, void** iter, param_type* r); + static void Log(const param_type& p, std::wstring* l); +}; + +template <> +struct ParamTraits { + typedef gfx::Size param_type; + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, void** iter, param_type* r); + static void Log(const param_type& p, std::wstring* l); +}; + +template <> +struct ParamTraits { + typedef gfx::NativeWindow param_type; + static void Write(Message* m, const param_type& p) { + m->WriteIntPtr(reinterpret_cast(p)); + } + 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(r)); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(StringPrintf(L"0x%X", p)); + } +}; + + +template <> +struct ParamTraits { + typedef WindowOpenDisposition param_type; + static void Write(Message* m, const param_type& p) { + m->WriteInt(p); + } + static bool Read(const Message* m, void** iter, param_type* r) { + int temp; + bool res = m->ReadInt(iter, &temp); + *r = static_cast(temp); + return res; + } + static void Log(const param_type& p, std::wstring* l) { + l->append(StringPrintf(L"%d", p)); + } +}; + + +template <> +struct ParamTraits { + typedef WebCursor param_type; + static void Write(Message* m, const param_type& p) { + p.Serialize(m); + } + 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) { + l->append(L""); + } +}; + + +template <> +struct ParamTraits { + typedef webkit_glue::WebApplicationInfo param_type; + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, void** iter, param_type* r); + static void Log(const param_type& p, std::wstring* l); +}; + + +#if defined(OS_WIN) +template<> +struct ParamTraits { + typedef TransportDIB::Id param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, p.handle); + WriteParam(m, p.sequence_num); + } + static bool Read(const Message* m, void** iter, param_type* r) { + return (ReadParam(m, iter, &r->handle) && + ReadParam(m, iter, &r->sequence_num)); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"TransportDIB("); + LogParam(p.handle, l); + l->append(L", "); + LogParam(p.sequence_num, l); + l->append(L")"); + } +}; +#endif + +// Traits for URLRequestStatus +template <> +struct ParamTraits { + typedef URLRequestStatus param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, static_cast(p.status())); + WriteParam(m, p.os_error()); + } + 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)) + return false; + r->set_status(static_cast(status)); + r->set_os_error(os_error); + return true; + } + static void Log(const param_type& p, std::wstring* l) { + std::wstring status; + switch (p.status()) { + case URLRequestStatus::SUCCESS: + status = L"SUCCESS"; + break; + case URLRequestStatus::IO_PENDING: + status = L"IO_PENDING "; + break; + case URLRequestStatus::HANDLED_EXTERNALLY: + status = L"HANDLED_EXTERNALLY"; + break; + case URLRequestStatus::CANCELED: + status = L"CANCELED"; + break; + case URLRequestStatus::FAILED: + status = L"FAILED"; + break; + default: + status = L"UNKNOWN"; + break; + } + if (p.status() == URLRequestStatus::FAILED) + l->append(L"("); + + LogParam(status, l); + + if (p.status() == URLRequestStatus::FAILED) { + l->append(L", "); + LogParam(p.os_error(), l); + l->append(L")"); + } + } +}; + +template<> +struct ParamTraits { + typedef ThumbnailScore param_type; + static void Write(Message* m, const param_type& p) { + IPC::ParamTraits::Write(m, p.boring_score); + IPC::ParamTraits::Write(m, p.good_clipping); + IPC::ParamTraits::Write(m, p.at_top); + IPC::ParamTraits::Write(m, p.time_at_snapshot); + } + 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 (!IPC::ParamTraits::Read(m, iter, &boring_score) || + !IPC::ParamTraits::Read(m, iter, &good_clipping) || + !IPC::ParamTraits::Read(m, iter, &at_top) || + !IPC::ParamTraits::Read(m, iter, &time_at_snapshot)) + return false; + + r->boring_score = boring_score; + r->good_clipping = good_clipping; + r->at_top = at_top; + r->time_at_snapshot = time_at_snapshot; + return true; + } + static void Log(const param_type& p, std::wstring* l) { + l->append(StringPrintf(L"(%f, %d, %d)", + p.boring_score, p.good_clipping, p.at_top)); + } +}; + +} // namespace IPC + +#endif // CHROME_COMMON_COMMON_PARAM_TRAITS_H_ diff --git a/chrome/common/ipc_message_unittest.cc b/chrome/common/common_param_traits_unittest.cc similarity index 97% rename from chrome/common/ipc_message_unittest.cc rename to chrome/common/common_param_traits_unittest.cc index 332f52974c024f..f3a7e922097b2a 100644 --- a/chrome/common/ipc_message_unittest.cc +++ b/chrome/common/common_param_traits_unittest.cc @@ -6,9 +6,10 @@ #include "base/scoped_ptr.h" #include "base/values.h" -#include "chrome/common/ipc_message.h" -#include "chrome/common/ipc_message_utils.h" +#include "chrome/common/common_param_traits.h" #include "googleurl/src/gurl.h" +#include "ipc/ipc_message.h" +#include "ipc/ipc_message_utils.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/core/SkBitmap.h" diff --git a/chrome/common/devtools_messages.h b/chrome/common/devtools_messages.h index 3321240ead6926..abb740d57c187e 100644 --- a/chrome/common/devtools_messages.h +++ b/chrome/common/devtools_messages.h @@ -6,6 +6,6 @@ #define CHROME_COMMON_DEVTOOLS_MESSAGES_H_ #define MESSAGES_INTERNAL_FILE "chrome/common/devtools_messages_internal.h" -#include "chrome/common/ipc_message_macros.h" +#include "ipc/ipc_message_macros.h" #endif // CHROME_COMMON_DEVTOOLS_MESSAGES_H_ diff --git a/chrome/common/devtools_messages_internal.h b/chrome/common/devtools_messages_internal.h index 377849742aa641..4411a2151bbfe3 100644 --- a/chrome/common/devtools_messages_internal.h +++ b/chrome/common/devtools_messages_internal.h @@ -42,7 +42,7 @@ // // This file describes developer tools message types. -#include "chrome/common/ipc_message_macros.h" +#include "ipc/ipc_message_macros.h" // These are messages sent from DevToolsAgent to DevToolsClient through the // browser. diff --git a/chrome/common/extensions/extension_unpacker.cc b/chrome/common/extensions/extension_unpacker.cc index 06957defc486d6..d3839a97ba609e 100644 --- a/chrome/common/extensions/extension_unpacker.cc +++ b/chrome/common/extensions/extension_unpacker.cc @@ -11,13 +11,14 @@ #include "base/thread.h" #include "base/values.h" #include "net/base/file_stream.h" +#include "chrome/common/common_param_traits.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_constants.h" -#include "chrome/common/ipc_message_utils.h" #include "chrome/common/json_value_serializer.h" #include "chrome/common/notification_service.h" #include "chrome/common/url_constants.h" #include "chrome/common/zip.h" +#include "ipc/ipc_message_utils.h" #include "third_party/skia/include/core/SkBitmap.h" #include "webkit/glue/image_decoder.h" diff --git a/chrome/common/ipc_maybe.h b/chrome/common/ipc_maybe.h deleted file mode 100644 index de45dc02b43b67..00000000000000 --- a/chrome/common/ipc_maybe.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef CHROME_COMMON_MAYBE_H_ -#define CHROME_COMMON_MAYBE_H_ - -namespace IPC { - -// The Maybe type can be used to avoid serialising a type when it's invalid. -// This is most useful in conjunction with FileDescriptor, as there's no -// possible invalid value which can be serialised (one can type to use -1, but -// the IPC channel will fail). It may also be useful if the invalid value is -// otherwise expensive to serialise. -template -struct Maybe { - bool valid; - A value; -}; - -} // namespace IPC - -#endif // CHROME_COMMON_MAYBE_H_ diff --git a/chrome/common/ipc_test_sink.h b/chrome/common/ipc_test_sink.h index fd9faee2b483e2..995ae3851f6896 100644 --- a/chrome/common/ipc_test_sink.h +++ b/chrome/common/ipc_test_sink.h @@ -9,7 +9,7 @@ #include #include "base/basictypes.h" -#include "chrome/common/ipc_message.h" +#include "ipc/ipc_message.h" namespace IPC { diff --git a/chrome/common/logging_chrome.cc b/chrome/common/logging_chrome.cc index 66a49cfceea7fd..3bcfd23d943f7c 100644 --- a/chrome/common/logging_chrome.cc +++ b/chrome/common/logging_chrome.cc @@ -72,6 +72,10 @@ void InitChromeLogging(const CommandLine& command_line, DCHECK(!chrome_logging_initialized_) << "Attempted to initialize logging when it was already initialized."; +#if defined(OS_POSIX) && defined(IPC_MESSAGE_LOG_ENABLED) + IPC::Logging::SetLoggerFunctions(g_log_function_mapping); +#endif + // only use OutputDebugString in debug mode #ifdef NDEBUG bool enable_logging = false; diff --git a/chrome/common/message_router.h b/chrome/common/message_router.h index d23e2f306fce34..ef18aaad807a4a 100644 --- a/chrome/common/message_router.h +++ b/chrome/common/message_router.h @@ -6,7 +6,7 @@ #define CHROME_COMMON_MESSAGE_ROUTER_H__ #include "base/id_map.h" -#include "chrome/common/ipc_channel.h" +#include "ipc/ipc_channel.h" // The MessageRouter handles all incoming messages sent to it by routing them // to the correct listener. Routing is based on the Message's routing ID. diff --git a/chrome/common/plugin_messages.h b/chrome/common/plugin_messages.h index 3b43b8b2082b80..dd1ee18380ffd2 100644 --- a/chrome/common/plugin_messages.h +++ b/chrome/common/plugin_messages.h @@ -16,9 +16,10 @@ #include "base/gfx/native_widget_types.h" #include "base/gfx/rect.h" #include "base/basictypes.h" -#include "chrome/common/ipc_message_utils.h" +#include "chrome/common/common_param_traits.h" #include "chrome/common/webkit_param_traits.h" #include "googleurl/src/gurl.h" +#include "ipc/ipc_message_utils.h" #include "third_party/npapi/bindings/npapi.h" #include "webkit/api/public/WebInputEvent.h" #include "webkit/glue/npruntime_util.h" @@ -408,6 +409,6 @@ struct ParamTraits { #define MESSAGES_INTERNAL_FILE "chrome/common/plugin_messages_internal.h" -#include "chrome/common/ipc_message_macros.h" +#include "ipc/ipc_message_macros.h" #endif // CHROME_COMMON_PLUGIN_MESSAGES_H__ diff --git a/chrome/common/plugin_messages_internal.h b/chrome/common/plugin_messages_internal.h index 974de000707b84..8631973a09cf07 100644 --- a/chrome/common/plugin_messages_internal.h +++ b/chrome/common/plugin_messages_internal.h @@ -5,7 +5,7 @@ #include "base/gfx/native_widget_types.h" #include "base/shared_memory.h" #include "build/build_config.h" -#include "chrome/common/ipc_message_macros.h" +#include "ipc/ipc_message_macros.h" #include "webkit/glue/webcursor.h" #if defined(OS_POSIX) diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index 2b6214560d07d0..d3faea0e9447bf 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -14,14 +14,15 @@ #include "base/ref_counted.h" #include "base/shared_memory.h" #include "chrome/browser/renderer_host/resource_handler.h" +#include "chrome/common/common_param_traits.h" #include "chrome/common/filter_policy.h" -#include "chrome/common/ipc_message_utils.h" #include "chrome/common/modal_dialog_event.h" #include "chrome/common/page_transition_types.h" #include "chrome/common/renderer_preferences.h" #include "chrome/common/transport_dib.h" #include "chrome/common/webkit_param_traits.h" #include "googleurl/src/gurl.h" +#include "ipc/ipc_message_utils.h" #include "media/audio/audio_output.h" #include "net/base/upload_data.h" #include "net/http/http_response_headers.h" @@ -1949,6 +1950,6 @@ struct ParamTraits { #define MESSAGES_INTERNAL_FILE "chrome/common/render_messages_internal.h" -#include "chrome/common/ipc_message_macros.h" +#include "ipc/ipc_message_macros.h" #endif // CHROME_COMMON_RENDER_MESSAGES_H_ diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index 040cd11127a8e4..50801160692e0c 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -17,9 +17,9 @@ #include "base/gfx/native_widget_types.h" #include "base/shared_memory.h" #include "base/values.h" -#include "chrome/common/ipc_channel_handle.h" -#include "chrome/common/ipc_message_macros.h" #include "chrome/common/transport_dib.h" +#include "ipc/ipc_channel_handle.h" +#include "ipc/ipc_message_macros.h" #include "third_party/skia/include/core/SkBitmap.h" #include "webkit/glue/dom_operations.h" #include "webkit/glue/webappcachecontext.h" diff --git a/chrome/common/resource_dispatcher.h b/chrome/common/resource_dispatcher.h index 1ba1fa569482b9..2424e2dbdd37b8 100644 --- a/chrome/common/resource_dispatcher.h +++ b/chrome/common/resource_dispatcher.h @@ -14,7 +14,7 @@ #include "base/shared_memory.h" #include "base/task.h" #include "chrome/common/filter_policy.h" -#include "chrome/common/ipc_channel.h" +#include "ipc/ipc_channel.h" #include "webkit/glue/resource_loader_bridge.h" struct ResourceResponseHead; diff --git a/chrome/common/webkit_param_traits.h b/chrome/common/webkit_param_traits.h index 126328575d2a06..b7e7e0bce4ecbc 100644 --- a/chrome/common/webkit_param_traits.h +++ b/chrome/common/webkit_param_traits.h @@ -23,7 +23,7 @@ #ifndef CHROME_COMMON_WEBKIT_PARAM_TRAITS_H_ #define CHROME_COMMON_WEBKIT_PARAM_TRAITS_H_ -#include "chrome/common/ipc_message_utils.h" +#include "ipc/ipc_message_utils.h" #include "webkit/api/public/WebCache.h" #include "webkit/api/public/WebCompositionCommand.h" #include "webkit/api/public/WebConsoleMessage.h" diff --git a/chrome/common/worker_messages.h b/chrome/common/worker_messages.h index f7a7c9cc846414..80004e5a6dac5d 100644 --- a/chrome/common/worker_messages.h +++ b/chrome/common/worker_messages.h @@ -11,7 +11,8 @@ #include #include "base/basictypes.h" -#include "chrome/common/ipc_message_utils.h" +#include "chrome/common/common_param_traits.h" +#include "ipc/ipc_message_utils.h" // Parameters structure for WorkerHostMsg_PostConsoleMessageToWorkerObject, // which has too many data parameters to be reasonably put in a predefined @@ -75,6 +76,6 @@ struct ParamTraits { } // namespace IPC #define MESSAGES_INTERNAL_FILE "chrome/common/worker_messages_internal.h" -#include "chrome/common/ipc_message_macros.h" +#include "ipc/ipc_message_macros.h" #endif // CHROME_COMMON_WORKER_MESSAGES_H_ diff --git a/chrome/common/worker_messages_internal.h b/chrome/common/worker_messages_internal.h index 74063c1670b408..9059719fb0313f 100644 --- a/chrome/common/worker_messages_internal.h +++ b/chrome/common/worker_messages_internal.h @@ -3,8 +3,8 @@ // found in the LICENSE file. #include "base/string16.h" -#include "chrome/common/ipc_message_macros.h" #include "googleurl/src/gurl.h" +#include "ipc/ipc_message_macros.h" //----------------------------------------------------------------------------- diff --git a/chrome/plugin/npobject_proxy.h b/chrome/plugin/npobject_proxy.h index afeb20739b98ed..8858a1b2b08541 100644 --- a/chrome/plugin/npobject_proxy.h +++ b/chrome/plugin/npobject_proxy.h @@ -9,8 +9,8 @@ #define CHROME_PLUGIN_NPOBJECT_PROXY_H_ #include "base/ref_counted.h" -#include "chrome/common/ipc_channel.h" #include "googleurl/src/gurl.h" +#include "ipc/ipc_channel.h" #include "third_party/npapi/bindings/npruntime.h" class PluginChannelBase; diff --git a/chrome/plugin/npobject_stub.h b/chrome/plugin/npobject_stub.h index acfd7727d8f622..da0745ce9423d7 100644 --- a/chrome/plugin/npobject_stub.h +++ b/chrome/plugin/npobject_stub.h @@ -11,8 +11,8 @@ #include #include "base/ref_counted.h" -#include "chrome/common/ipc_channel.h" #include "googleurl/src/gurl.h" +#include "ipc/ipc_channel.h" namespace base { class WaitableEvent; diff --git a/chrome/plugin/plugin_channel.cc b/chrome/plugin/plugin_channel.cc index 7977218214abfd..7f6f7d6be981cf 100644 --- a/chrome/plugin/plugin_channel.cc +++ b/chrome/plugin/plugin_channel.cc @@ -14,7 +14,7 @@ #include "chrome/plugin/plugin_thread.h" #if defined(OS_POSIX) -#include "chrome/common/ipc_channel_posix.h" +#include "ipc/ipc_channel_posix.h" #endif PluginChannel* PluginChannel::GetPluginChannel( diff --git a/chrome/plugin/plugin_channel_base.cc b/chrome/plugin/plugin_channel_base.cc index c05321ba255379..4ef42aeab31b68 100644 --- a/chrome/plugin/plugin_channel_base.cc +++ b/chrome/plugin/plugin_channel_base.cc @@ -6,7 +6,7 @@ #include "base/hash_tables.h" #include "chrome/common/child_process.h" -#include "chrome/common/ipc_sync_message.h" +#include "ipc/ipc_sync_message.h" typedef base::hash_map > PluginChannelMap; diff --git a/chrome/plugin/plugin_channel_base.h b/chrome/plugin/plugin_channel_base.h index 877ce703397837..9c722943b837a5 100644 --- a/chrome/plugin/plugin_channel_base.h +++ b/chrome/plugin/plugin_channel_base.h @@ -12,8 +12,8 @@ #include "base/message_loop.h" #include "base/ref_counted.h" #include "base/scoped_ptr.h" -#include "chrome/common/ipc_sync_channel.h" #include "chrome/common/message_router.h" +#include "ipc/ipc_sync_channel.h" // Encapsulates an IPC channel between a renderer and a plugin process. class PluginChannelBase : public IPC::Channel::Listener, diff --git a/chrome/plugin/plugin_main.cc b/chrome/plugin/plugin_main.cc index 375831a55f7ac6..7361d643473424 100644 --- a/chrome/plugin/plugin_main.cc +++ b/chrome/plugin/plugin_main.cc @@ -23,8 +23,8 @@ #include "chrome/test/injection_test_dll.h" #include "sandbox/src/sandbox.h" #elif defined(OS_LINUX) -#include "chrome/common/chrome_descriptors.h" #include "base/global_descriptors_posix.h" +#include "ipc/ipc_descriptors.h" #endif // main() routine for running as the plugin process. diff --git a/chrome/plugin/webplugin_delegate_stub.h b/chrome/plugin/webplugin_delegate_stub.h index 15b88a8d75b49c..2def46c197cc4d 100644 --- a/chrome/plugin/webplugin_delegate_stub.h +++ b/chrome/plugin/webplugin_delegate_stub.h @@ -11,9 +11,9 @@ #include "base/ref_counted.h" #include "base/shared_memory.h" #include "base/task.h" -#include "chrome/common/ipc_channel.h" #include "chrome/common/transport_dib.h" #include "googleurl/src/gurl.h" +#include "ipc/ipc_channel.h" #include "third_party/npapi/bindings/npapi.h" class PluginChannel; diff --git a/chrome/plugin/webplugin_proxy.h b/chrome/plugin/webplugin_proxy.h index b27e95b14a1296..1b1468e38ba0a9 100644 --- a/chrome/plugin/webplugin_proxy.h +++ b/chrome/plugin/webplugin_proxy.h @@ -16,10 +16,10 @@ #include "base/scoped_ptr.h" #include "base/shared_memory.h" #include "base/timer.h" -#include "chrome/common/ipc_message.h" #include "chrome/common/chrome_plugin_api.h" #include "chrome/common/transport_dib.h" #include "googleurl/src/gurl.h" +#include "ipc/ipc_message.h" #include "webkit/glue/webplugin.h" namespace base { diff --git a/chrome/renderer/audio_message_filter.cc b/chrome/renderer/audio_message_filter.cc index 0714b7106d55f3..b875f9206d7e53 100644 --- a/chrome/renderer/audio_message_filter.cc +++ b/chrome/renderer/audio_message_filter.cc @@ -4,9 +4,9 @@ #include "base/histogram.h" #include "base/message_loop.h" -#include "chrome/common/ipc_logging.h" #include "chrome/common/render_messages.h" #include "chrome/renderer/audio_message_filter.h" +#include "ipc/ipc_logging.h" namespace { diff --git a/chrome/renderer/audio_message_filter.h b/chrome/renderer/audio_message_filter.h index 7626b3cf451330..7fa17cbb534b2e 100644 --- a/chrome/renderer/audio_message_filter.h +++ b/chrome/renderer/audio_message_filter.h @@ -12,7 +12,7 @@ #include "base/id_map.h" #include "base/shared_memory.h" -#include "chrome/common/ipc_channel_proxy.h" +#include "ipc/ipc_channel_proxy.h" #include "media/audio/audio_output.h" #include "testing/gtest/include/gtest/gtest_prod.h" diff --git a/chrome/renderer/automation/dom_automation_controller.h b/chrome/renderer/automation/dom_automation_controller.h index 94720f7a9b2b11..bc6f5fecd7625c 100644 --- a/chrome/renderer/automation/dom_automation_controller.h +++ b/chrome/renderer/automation/dom_automation_controller.h @@ -5,7 +5,7 @@ #ifndef CHROME_RENDERER_AUTOMATION_DOM_AUTOMATION_CONTROLLER_H__ #define CHROME_RENDERER_AUTOMATION_DOM_AUTOMATION_CONTROLLER_H__ -#include "chrome/common/ipc_message.h" +#include "ipc/ipc_message.h" #include "webkit/glue/cpp_bound_class.h" /* DomAutomationController class: diff --git a/chrome/renderer/devtools_agent_filter.h b/chrome/renderer/devtools_agent_filter.h index 91872e449fb6a0..c04a44a44b1b76 100644 --- a/chrome/renderer/devtools_agent_filter.h +++ b/chrome/renderer/devtools_agent_filter.h @@ -8,7 +8,7 @@ #include #include -#include "chrome/common/ipc_channel_proxy.h" +#include "ipc/ipc_channel_proxy.h" class WebDevToolsAgent; diff --git a/chrome/renderer/dom_ui_bindings.h b/chrome/renderer/dom_ui_bindings.h index 23b2d3557cb834..b4ad992b3d2795 100644 --- a/chrome/renderer/dom_ui_bindings.h +++ b/chrome/renderer/dom_ui_bindings.h @@ -5,7 +5,7 @@ #ifndef CHROME_RENDERER_DOM_UI_BINDINGS_H__ #define CHROME_RENDERER_DOM_UI_BINDINGS_H__ -#include "chrome/common/ipc_message.h" +#include "ipc/ipc_message.h" #include "webkit/glue/cpp_bound_class.h" // A DOMBoundBrowserObject is a backing for some object bound to the window diff --git a/chrome/renderer/external_host_bindings.h b/chrome/renderer/external_host_bindings.h index cd8bcdb6f09a4c..d9959754c06f5d 100644 --- a/chrome/renderer/external_host_bindings.h +++ b/chrome/renderer/external_host_bindings.h @@ -5,8 +5,8 @@ #ifndef CHROME_RENDERER_EXTERNAL_HOST_BINDINGS_H_ #define CHROME_RENDERER_EXTERNAL_HOST_BINDINGS_H_ -#include "chrome/common/ipc_message.h" #include "chrome/renderer/dom_ui_bindings.h" +#include "ipc/ipc_message.h" // ExternalHostBindings is the class backing the "externalHost" object // accessible from Javascript diff --git a/chrome/renderer/mock_printer.cc b/chrome/renderer/mock_printer.cc index 4462ce74f22d68..2da66ae33559bf 100644 --- a/chrome/renderer/mock_printer.cc +++ b/chrome/renderer/mock_printer.cc @@ -7,8 +7,8 @@ #include "base/file_util.h" #include "base/logging.h" #include "base/shared_memory.h" -#include "chrome/common/ipc_message_utils.h" #include "chrome/common/render_messages.h" +#include "ipc/ipc_message_utils.h" #include "testing/gtest/include/gtest/gtest.h" MockPrinter::MockPrinter() diff --git a/chrome/renderer/mock_render_thread.cc b/chrome/renderer/mock_render_thread.cc index 17dab52776d2f1..e99c6182b7faad 100644 --- a/chrome/renderer/mock_render_thread.cc +++ b/chrome/renderer/mock_render_thread.cc @@ -4,8 +4,8 @@ #include "chrome/renderer/mock_render_thread.h" -#include "chrome/common/ipc_message_utils.h" #include "chrome/common/render_messages.h" +#include "ipc/ipc_message_utils.h" #include "testing/gtest/include/gtest/gtest.h" MockRenderThread::MockRenderThread() diff --git a/chrome/renderer/plugin_channel_host.cc b/chrome/renderer/plugin_channel_host.cc index 0befaab49f526c..04d7b4ffc3e5f2 100644 --- a/chrome/renderer/plugin_channel_host.cc +++ b/chrome/renderer/plugin_channel_host.cc @@ -7,7 +7,7 @@ #include "chrome/common/plugin_messages.h" #if defined(OS_POSIX) -#include "chrome/common/ipc_channel_posix.h" +#include "ipc/ipc_channel_posix.h" #endif // A simple MessageFilter that will ignore all messages and respond to sync diff --git a/chrome/renderer/render_process.cc b/chrome/renderer/render_process.cc index fd0608151e5878..1b8509f4d8de7f 100644 --- a/chrome/renderer/render_process.cc +++ b/chrome/renderer/render_process.cc @@ -24,11 +24,11 @@ #include "chrome/browser/net/dns_global.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_paths.h" -#include "chrome/common/ipc_channel.h" -#include "chrome/common/ipc_message_utils.h" #include "chrome/common/render_messages.h" #include "chrome/common/transport_dib.h" #include "chrome/renderer/render_view.h" +#include "ipc/ipc_channel.h" +#include "ipc/ipc_message_utils.h" #include "media/base/media.h" #include "webkit/glue/webkit_glue.h" diff --git a/chrome/renderer/render_thread_unittest.cc b/chrome/renderer/render_thread_unittest.cc index bb2e297a5f8e77..76491fe326f0e1 100644 --- a/chrome/renderer/render_thread_unittest.cc +++ b/chrome/renderer/render_thread_unittest.cc @@ -3,10 +3,10 @@ // found in the LICENSE file. #include "base/waitable_event.h" -#include "chrome/common/ipc_sync_channel.h" #include "chrome/common/render_messages.h" #include "chrome/renderer/mock_render_process.h" #include "chrome/renderer/render_thread.h" +#include "ipc/ipc_sync_channel.h" #include "testing/gtest/include/gtest/gtest.h" namespace { diff --git a/chrome/renderer/render_widget.h b/chrome/renderer/render_widget.h index 005b4b60f24580..7c6e59239b6f0d 100644 --- a/chrome/renderer/render_widget.h +++ b/chrome/renderer/render_widget.h @@ -13,8 +13,8 @@ #include "base/gfx/size.h" #include "base/ref_counted.h" #include "base/shared_memory.h" -#include "chrome/common/ipc_channel.h" #include "chrome/renderer/render_process.h" +#include "ipc/ipc_channel.h" #include "skia/ext/platform_canvas.h" #include "third_party/skia/include/core/SkBitmap.h" #include "webkit/api/public/WebCompositionCommand.h" diff --git a/chrome/renderer/renderer_main_unittest.cc b/chrome/renderer/renderer_main_unittest.cc index 605101efebf310..598277ae87fca1 100644 --- a/chrome/renderer/renderer_main_unittest.cc +++ b/chrome/renderer/renderer_main_unittest.cc @@ -6,8 +6,8 @@ #include "base/multiprocess_test.h" #include "base/process_util.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/ipc_channel.h" #include "chrome/common/main_function_params.h" +#include "ipc/ipc_channel.h" #include "testing/gtest/include/gtest/gtest.h" // TODO(port): Bring up this test this on other platforms. diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc index 524b9089faae61..34a728dbc526bd 100644 --- a/chrome/renderer/webplugin_delegate_proxy.cc +++ b/chrome/renderer/webplugin_delegate_proxy.cc @@ -41,7 +41,7 @@ #include "webkit/glue/webview.h" #if defined(OS_POSIX) -#include "chrome/common/ipc_channel_posix.h" +#include "ipc/ipc_channel_posix.h" #endif #if defined(OS_MACOSX) diff --git a/chrome/renderer/webplugin_delegate_proxy.h b/chrome/renderer/webplugin_delegate_proxy.h index a772384e35790b..17ce1d1431086f 100644 --- a/chrome/renderer/webplugin_delegate_proxy.h +++ b/chrome/renderer/webplugin_delegate_proxy.h @@ -12,10 +12,10 @@ #include "base/gfx/rect.h" #include "base/gfx/native_widget_types.h" #include "base/ref_counted.h" -#include "chrome/common/ipc_message.h" #include "chrome/common/transport_dib.h" #include "chrome/renderer/plugin_channel_host.h" #include "googleurl/src/gurl.h" +#include "ipc/ipc_message.h" #include "skia/ext/platform_canvas.h" #include "webkit/glue/webplugin.h" #include "webkit/glue/webplugin_delegate.h" diff --git a/chrome/renderer/webworker_proxy.h b/chrome/renderer/webworker_proxy.h index b56cf8eb997666..7567060729a6d8 100644 --- a/chrome/renderer/webworker_proxy.h +++ b/chrome/renderer/webworker_proxy.h @@ -8,7 +8,7 @@ #include #include "base/basictypes.h" -#include "chrome/common/ipc_channel.h" +#include "ipc/ipc_channel.h" #include "webkit/api/public/WebWorker.h" class ChildThread; diff --git a/chrome/test/automation/autocomplete_edit_proxy.h b/chrome/test/automation/autocomplete_edit_proxy.h index 79d89750a09b63..b0594d8597bb7c 100644 --- a/chrome/test/automation/autocomplete_edit_proxy.h +++ b/chrome/test/automation/autocomplete_edit_proxy.h @@ -9,10 +9,10 @@ #include #include "chrome/browser/autocomplete/autocomplete.h" -#include "chrome/common/ipc_message.h" -#include "chrome/common/ipc_message_utils.h" #include "chrome/test/automation/automation_handle_tracker.h" #include "googleurl/src/gurl.h" +#include "ipc/ipc_message.h" +#include "ipc/ipc_message_utils.h" // The purpose of this class is to act as a serializable version of // AutocompleteMatch. The reason for this class is because we don't want to diff --git a/chrome/test/automation/automation_messages.h b/chrome/test/automation/automation_messages.h index dd17017f44b244..710b17052da6cb 100644 --- a/chrome/test/automation/automation_messages.h +++ b/chrome/test/automation/automation_messages.h @@ -11,8 +11,9 @@ #include "base/gfx/rect.h" #include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/tab_contents/security_style.h" -#include "chrome/common/ipc_message_utils.h" +#include "chrome/common/common_param_traits.h" #include "chrome/test/automation/automation_constants.h" +#include "ipc/ipc_message_utils.h" struct AutomationMsg_Find_Params { // Unused value, which exists only for backwards compat. @@ -341,6 +342,6 @@ struct ParamTraits { #define MESSAGES_INTERNAL_FILE \ "chrome/test/automation/automation_messages_internal.h" -#include "chrome/common/ipc_message_macros.h" +#include "ipc/ipc_message_macros.h" #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 15528c2da79d80..b8991399c83300 100644 --- a/chrome/test/automation/automation_messages_internal.h +++ b/chrome/test/automation/automation_messages_internal.h @@ -14,10 +14,10 @@ #include "base/basictypes.h" #include "base/gfx/rect.h" #include "base/string16.h" -#include "chrome/common/ipc_message_macros.h" #include "chrome/common/navigation_types.h" #include "chrome/test/automation/autocomplete_edit_proxy.h" #include "googleurl/src/gurl.h" +#include "ipc/ipc_message_macros.h" // NOTE: All IPC messages have either a routing_id of 0 (for asynchronous // messages), or one that's been assigned by the proxy (for calls diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc index a1df2d8b43c663..dc94c18270a96a 100644 --- a/chrome/test/automation/automation_proxy.cc +++ b/chrome/test/automation/automation_proxy.cc @@ -13,12 +13,12 @@ #include "base/process_util.h" #include "base/ref_counted.h" #include "base/waitable_event.h" -#include "chrome/common/chrome_descriptors.h" #include "chrome/test/automation/automation_constants.h" #include "chrome/test/automation/automation_messages.h" #include "chrome/test/automation/browser_proxy.h" #include "chrome/test/automation/tab_proxy.h" #include "chrome/test/automation/window_proxy.h" +#include "ipc/ipc_descriptors.h" #if defined(OS_WIN) // TODO(port): Enable when dialog_delegate is ported. #include "views/window/dialog_delegate.h" diff --git a/chrome/test/automation/automation_proxy.h b/chrome/test/automation/automation_proxy.h index ffbf39d68ed552..186d7bfdb067fd 100644 --- a/chrome/test/automation/automation_proxy.h +++ b/chrome/test/automation/automation_proxy.h @@ -14,11 +14,11 @@ #include "base/time.h" #include "base/thread.h" #include "base/waitable_event.h" -#include "chrome/common/ipc_channel_proxy.h" -#include "chrome/common/ipc_message.h" -#include "chrome/common/ipc_sync_channel.h" #include "chrome/test/automation/automation_handle_tracker.h" #include "chrome/test/automation/automation_messages.h" +#include "ipc/ipc_channel_proxy.h" +#include "ipc/ipc_message.h" +#include "ipc/ipc_sync_channel.h" class BrowserProxy; class TabProxy; diff --git a/chrome/worker/webworkerclient_proxy.cc b/chrome/worker/webworkerclient_proxy.cc index b22428c678a99a..79ba379457b2f8 100644 --- a/chrome/worker/webworkerclient_proxy.cc +++ b/chrome/worker/webworkerclient_proxy.cc @@ -7,11 +7,11 @@ #include "base/command_line.h" #include "chrome/common/child_process.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/ipc_logging.h" #include "chrome/common/worker_messages.h" #include "chrome/renderer/webworker_proxy.h" #include "chrome/worker/worker_thread.h" #include "chrome/worker/nativewebworker_impl.h" +#include "ipc/ipc_logging.h" #include "webkit/api/public/WebString.h" #include "webkit/api/public/WebURL.h" #include "webkit/api/public/WebWorker.h" diff --git a/chrome/worker/webworkerclient_proxy.h b/chrome/worker/webworkerclient_proxy.h index 341c15a8039f2c..0e74e41240a2c6 100644 --- a/chrome/worker/webworkerclient_proxy.h +++ b/chrome/worker/webworkerclient_proxy.h @@ -6,8 +6,8 @@ #define CHROME_WORKER_WEBWORKERCLIENT_PROXY_H_ #include "base/basictypes.h" -#include "chrome/common/ipc_channel.h" #include "googleurl/src/gurl.h" +#include "ipc/ipc_channel.h" #include "webkit/api/public/WebWorkerClient.h" namespace WebKit { diff --git a/chrome/common/file_descriptor_set_posix.cc b/ipc/file_descriptor_set_posix.cc similarity index 98% rename from chrome/common/file_descriptor_set_posix.cc rename to ipc/file_descriptor_set_posix.cc index 1be7aa8f07af50..519e6e7648cdce 100644 --- a/chrome/common/file_descriptor_set_posix.cc +++ b/ipc/file_descriptor_set_posix.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/common/file_descriptor_set_posix.h" +#include "ipc/file_descriptor_set_posix.h" #include "base/eintr_wrapper.h" #include "base/logging.h" diff --git a/chrome/common/file_descriptor_set_posix.h b/ipc/file_descriptor_set_posix.h similarity index 96% rename from chrome/common/file_descriptor_set_posix.h rename to ipc/file_descriptor_set_posix.h index 342e6d932f89ce..c3d26ba8f607f2 100644 --- a/chrome/common/file_descriptor_set_posix.h +++ b/ipc/file_descriptor_set_posix.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_COMMON_FILE_DESCRIPTOR_SET_POSIX_H_ -#define CHROME_COMMON_FILE_DESCRIPTOR_SET_POSIX_H_ +#ifndef IPC_FILE_DESCRIPTOR_SET_POSIX_H_ +#define IPC_FILE_DESCRIPTOR_SET_POSIX_H_ #include @@ -105,4 +105,4 @@ class FileDescriptorSet : public base::RefCountedThreadSafe { DISALLOW_COPY_AND_ASSIGN(FileDescriptorSet); }; -#endif // CHROME_COMMON_FILE_DESCRIPTOR_SET_POSIX_H_ +#endif // IPC_FILE_DESCRIPTOR_SET_POSIX_H_ diff --git a/chrome/common/file_descriptor_set_unittest.cc b/ipc/file_descriptor_set_unittest.cc similarity index 98% rename from chrome/common/file_descriptor_set_unittest.cc rename to ipc/file_descriptor_set_unittest.cc index f412fdd90c3f6e..243d29e28ebbb2 100644 --- a/chrome/common/file_descriptor_set_unittest.cc +++ b/ipc/file_descriptor_set_unittest.cc @@ -9,7 +9,7 @@ #include "base/basictypes.h" #include "base/eintr_wrapper.h" -#include "chrome/common/file_descriptor_set_posix.h" +#include "ipc/file_descriptor_set_posix.h" #include "testing/gtest/include/gtest/gtest.h" namespace { diff --git a/ipc/ipc.gyp b/ipc/ipc.gyp new file mode 100644 index 00000000000000..2371ece3c9fac7 --- /dev/null +++ b/ipc/ipc.gyp @@ -0,0 +1,108 @@ +# Copyright (c) 2009 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +{ + 'includes': [ + '../build/common.gypi', + ], + 'target_defaults': { + 'sources/': [ + ['exclude', '/win/'], + ['exclude', '_(posix|win)(_unittest)?\\.(cc|mm?)$'], + ['exclude', '/win_[^/]*\\.cc$'], + ], + 'conditions': [ + ['OS=="linux"', {'sources/': [ + ['include', '_posix(_unittest)?\\.cc$'], + ]}], + ['OS=="mac"', {'sources/': [ + ['include', '_posix(_unittest)?\\.(cc|mm?)$'], + ]}], + ['OS=="win"', {'sources/': [ + ['include', '_win(_unittest)?\\.cc$'], + ['include', '/win/'], + ['include', '/win_[^/]*\\.cc$'], + ]}], + ], + }, + 'targets': [ + { + 'target_name': 'ipc', + 'type': '<(library)', + 'dependencies': [ + '../base/base.gyp:base', + ], + 'include_dirs': [ + '..', + ], + 'sources': [ + 'file_descriptor_set_posix.cc', + 'file_descriptor_set_posix.h', + 'ipc_channel.h', + 'ipc_channel_handle.h', + 'ipc_channel_posix.cc', + 'ipc_channel_posix.h', + 'ipc_channel_proxy.cc', + 'ipc_channel_proxy.h', + 'ipc_channel_win.cc', + 'ipc_channel_win.h', + 'ipc_descriptors.h', + 'ipc_logging.cc', + 'ipc_logging.h', + 'ipc_message.cc', + 'ipc_message.h', + 'ipc_message_macros.h', + 'ipc_message_utils.cc', + 'ipc_message_utils.h', + 'ipc_switches.cc', + 'ipc_switches.h', + 'ipc_sync_channel.cc', + 'ipc_sync_channel.h', + 'ipc_sync_message.cc', + 'ipc_sync_message.h', + ], + 'direct_dependent_settings': { + 'include_dirs': [ + '..', + ], + }, + }, + { + 'target_name': 'ipc_tests', + 'type': 'executable', + 'msvs_guid': 'B92AE829-E1CD-4781-824A-DCB1603A1672', + 'dependencies': [ + 'ipc', + '../base/base.gyp:base', + '../testing/gtest.gyp:gtest', + ], + 'include_dirs': [ + '..' + ], + 'sources': [ + 'file_descriptor_set_unittest.cc', + 'ipc_fuzzing_tests.cc', + 'ipc_message_unittest.cc', + 'ipc_send_fds_test.cc', + 'ipc_sync_channel_unittest.cc', + 'ipc_sync_message_unittest.cc', + 'ipc_sync_message_unittest.h', + 'ipc_tests.cc', + 'ipc_tests.h', + ], + 'conditions': [ + ['OS=="linux"', { + 'dependencies': [ + '../build/linux/system.gyp:gtk', + ], + }], + ['OS=="linux" and toolkit_views==1', { + 'dependencies': [ + '../views/views.gyp:views', + ], + }], + ], + }, + ] +} diff --git a/chrome/common/ipc_channel.h b/ipc/ipc_channel.h similarity index 96% rename from chrome/common/ipc_channel.h rename to ipc/ipc_channel.h index 85b35fae5cbd76..a7a9a347b3c664 100644 --- a/chrome/common/ipc_channel.h +++ b/ipc/ipc_channel.h @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_COMMON_IPC_CHANNEL_H_ -#define CHROME_COMMON_IPC_CHANNEL_H_ +#ifndef IPC_IPC_CHANNEL_H_ +#define IPC_IPC_CHANNEL_H_ -#include "chrome/common/ipc_message.h" +#include "ipc/ipc_message.h" namespace IPC { @@ -115,4 +115,4 @@ class Channel : public Message::Sender { } // namespace IPC -#endif // CHROME_COMMON_IPC_CHANNEL_H_ +#endif // IPC_IPC_CHANNEL_H_ diff --git a/chrome/common/ipc_channel_handle.h b/ipc/ipc_channel_handle.h similarity index 90% rename from chrome/common/ipc_channel_handle.h rename to ipc/ipc_channel_handle.h index 2bb63803b41917..e3b2f3e7ba1d03 100644 --- a/chrome/common/ipc_channel_handle.h +++ b/ipc/ipc_channel_handle.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_COMMON_IPC_CHANNEL_HANDLE_H_ -#define CHROME_COMMON_IPC_CHANNEL_HANDLE_H_ +#ifndef IPC_IPC_CHANNEL_HANDLE_H_ +#define IPC_IPC_CHANNEL_HANDLE_H_ #include "build/build_config.h" @@ -42,4 +42,4 @@ struct ChannelHandle { } // namespace IPC -#endif // CHROME_COMMON_IPC_CHANNEL_HANDLE_H_ +#endif // IPC_IPC_CHANNEL_HANDLE_H_ diff --git a/chrome/common/ipc_channel_posix.cc b/ipc/ipc_channel_posix.cc similarity index 98% rename from chrome/common/ipc_channel_posix.cc rename to ipc/ipc_channel_posix.cc index 16ae02cb0b8616..22b9241e5e8dd4 100644 --- a/chrome/common/ipc_channel_posix.cc +++ b/ipc/ipc_channel_posix.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/common/ipc_channel_posix.h" +#include "ipc/ipc_channel_posix.h" #include #include @@ -22,15 +22,14 @@ #include "base/logging.h" #include "base/process_util.h" #include "base/scoped_ptr.h" -#include "base/string_util.h" #include "base/singleton.h" #include "base/stats_counters.h" -#include "chrome/common/chrome_counters.h" -#include "chrome/common/chrome_descriptors.h" -#include "chrome/common/chrome_switches.h" -#include "chrome/common/file_descriptor_set_posix.h" -#include "chrome/common/ipc_logging.h" -#include "chrome/common/ipc_message_utils.h" +#include "base/string_util.h" +#include "ipc/ipc_descriptors.h" +#include "ipc/ipc_switches.h" +#include "ipc/file_descriptor_set_posix.h" +#include "ipc/ipc_logging.h" +#include "ipc/ipc_message_utils.h" namespace IPC { @@ -682,7 +681,6 @@ bool Channel::ChannelImpl::ProcessOutgoingMessages() { } bool Channel::ChannelImpl::Send(Message* message) { - chrome::Counters::ipc_send_counter().Increment(); #ifdef IPC_MESSAGE_DEBUG_EXTRA DLOG(INFO) << "sending message @" << message << " on channel @" << this << " with type " << message->type() diff --git a/chrome/common/ipc_channel_posix.h b/ipc/ipc_channel_posix.h similarity index 95% rename from chrome/common/ipc_channel_posix.h rename to ipc/ipc_channel_posix.h index 9b4157ed0d22d0..aa69d4ff228426 100644 --- a/chrome/common/ipc_channel_posix.h +++ b/ipc/ipc_channel_posix.h @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_COMMON_IPC_CHANNEL_POSIX_H_ -#define CHROME_COMMON_IPC_CHANNEL_POSIX_H_ +#ifndef IPC_IPC_CHANNEL_POSIX_H_ +#define IPC_IPC_CHANNEL_POSIX_H_ -#include "chrome/common/ipc_channel.h" +#include "ipc/ipc_channel.h" #include // for CMSG macros @@ -14,7 +14,7 @@ #include #include "base/message_loop.h" -#include "chrome/common/file_descriptor_set_posix.h" +#include "ipc/file_descriptor_set_posix.h" namespace IPC { @@ -132,4 +132,4 @@ class Channel::ChannelImpl : public MessageLoopForIO::Watcher { } // namespace IPC -#endif // CHROME_COMMON_IPC_CHANNEL_POSIX_H_ +#endif // IPC_IPC_CHANNEL_POSIX_H_ diff --git a/chrome/common/ipc_channel_proxy.cc b/ipc/ipc_channel_proxy.cc similarity index 98% rename from chrome/common/ipc_channel_proxy.cc rename to ipc/ipc_channel_proxy.cc index c97e6f5ec7a092..d96e41313efac3 100644 --- a/chrome/common/ipc_channel_proxy.cc +++ b/ipc/ipc_channel_proxy.cc @@ -4,9 +4,9 @@ #include "base/message_loop.h" #include "base/thread.h" -#include "chrome/common/ipc_channel_proxy.h" -#include "chrome/common/ipc_logging.h" -#include "chrome/common/ipc_message_utils.h" +#include "ipc/ipc_channel_proxy.h" +#include "ipc/ipc_logging.h" +#include "ipc/ipc_message_utils.h" namespace IPC { diff --git a/chrome/common/ipc_channel_proxy.h b/ipc/ipc_channel_proxy.h similarity index 98% rename from chrome/common/ipc_channel_proxy.h rename to ipc/ipc_channel_proxy.h index 8adcb5ba677190..1aed33e6536da6 100644 --- a/chrome/common/ipc_channel_proxy.h +++ b/ipc/ipc_channel_proxy.h @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_COMMON_IPC_CHANNEL_PROXY_H__ -#define CHROME_COMMON_IPC_CHANNEL_PROXY_H__ +#ifndef IPC_IPC_CHANNEL_PROXY_H__ +#define IPC_IPC_CHANNEL_PROXY_H__ #include #include "base/ref_counted.h" -#include "chrome/common/ipc_channel.h" +#include "ipc/ipc_channel.h" class MessageLoop; @@ -206,4 +206,4 @@ class ChannelProxy : public Message::Sender { } // namespace IPC -#endif // CHROME_COMMON_IPC_CHANNEL_PROXY_H__ +#endif // IPC_IPC_CHANNEL_PROXY_H__ diff --git a/chrome/common/ipc_channel_win.cc b/ipc/ipc_channel_win.cc similarity index 98% rename from chrome/common/ipc_channel_win.cc rename to ipc/ipc_channel_win.cc index 9d1de29f250f25..9296ea44caabc2 100644 --- a/chrome/common/ipc_channel_win.cc +++ b/ipc/ipc_channel_win.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/common/ipc_channel_win.h" +#include "ipc/ipc_channel_win.h" #include #include @@ -12,9 +12,8 @@ #include "base/non_thread_safe.h" #include "base/stats_counters.h" #include "base/win_util.h" -#include "chrome/common/chrome_counters.h" -#include "chrome/common/ipc_logging.h" -#include "chrome/common/ipc_message_utils.h" +#include "ipc/ipc_logging.h" +#include "ipc/ipc_message_utils.h" namespace IPC { //------------------------------------------------------------------------------ @@ -84,7 +83,6 @@ void Channel::ChannelImpl::Close() { bool Channel::ChannelImpl::Send(Message* message) { DCHECK(thread_check_->CalledOnValidThread()); - chrome::Counters::ipc_send_counter().Increment(); #ifdef IPC_MESSAGE_DEBUG_EXTRA DLOG(INFO) << "sending message @" << message << " on channel @" << this << " with type " << message->type() diff --git a/chrome/common/ipc_channel_win.h b/ipc/ipc_channel_win.h similarity index 93% rename from chrome/common/ipc_channel_win.h rename to ipc/ipc_channel_win.h index f52143159ab491..7610d02f42005b 100644 --- a/chrome/common/ipc_channel_win.h +++ b/ipc/ipc_channel_win.h @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_COMMON_IPC_CHANNEL_WIN_H_ -#define CHROME_COMMON_IPC_CHANNEL_WIN_H_ +#ifndef IPC_IPC_CHANNEL_WIN_H_ +#define IPC_IPC_CHANNEL_WIN_H_ -#include "chrome/common/ipc_channel.h" +#include "ipc/ipc_channel.h" #include #include @@ -82,4 +82,4 @@ class Channel::ChannelImpl : public MessageLoopForIO::IOHandler { } // namespace IPC -#endif // CHROME_COMMON_IPC_CHANNEL_WIN_H_ +#endif // IPC_IPC_CHANNEL_WIN_H_ diff --git a/ipc/ipc_descriptors.h b/ipc/ipc_descriptors.h new file mode 100644 index 00000000000000..5717aa4e8f3983 --- /dev/null +++ b/ipc/ipc_descriptors.h @@ -0,0 +1,14 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef IPC_IPC_DESCRIPTORS_H_ +#define IPC_IPC_DESCRIPTORS_H_ + +// This is a list of global descriptor keys to be used with the +// base::GlobalDescriptors object (see base/global_descriptors_posix.h) +enum { + kPrimaryIPCChannel = 0, +}; + +#endif // IPC_IPC_DESCRIPTORS_H_ diff --git a/chrome/common/ipc_fuzzing_tests.cc b/ipc/ipc_fuzzing_tests.cc similarity index 97% rename from chrome/common/ipc_fuzzing_tests.cc rename to ipc/ipc_fuzzing_tests.cc index 5d1f13bb731c45..c79d05a176cd36 100644 --- a/chrome/common/ipc_fuzzing_tests.cc +++ b/ipc/ipc_fuzzing_tests.cc @@ -10,10 +10,10 @@ #include "base/message_loop.h" #include "base/platform_thread.h" #include "base/process_util.h" -#include "chrome/common/ipc_channel.h" -#include "chrome/common/ipc_channel_proxy.h" -#include "chrome/common/ipc_message_utils.h" -#include "chrome/common/ipc_tests.h" +#include "ipc/ipc_channel.h" +#include "ipc/ipc_channel_proxy.h" +#include "ipc/ipc_message_utils.h" +#include "ipc/ipc_tests.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/multiprocess_func_list.h" @@ -98,8 +98,8 @@ TEST(IPCMessageIntegrity, ReadVectorTooLarge2) { // We don't actually use the messages defined in this file, but we do this // to get to the IPC macros. -#define MESSAGES_INTERNAL_FILE "chrome/common/ipc_sync_message_unittest.h" -#include "chrome/common/ipc_message_macros.h" +#define MESSAGES_INTERNAL_FILE "ipc/ipc_sync_message_unittest.h" +#include "ipc/ipc_message_macros.h" enum IPCMessageIds { UNUSED_IPC_TYPE, diff --git a/chrome/common/ipc_logging.cc b/ipc/ipc_logging.cc similarity index 93% rename from chrome/common/ipc_logging.cc rename to ipc/ipc_logging.cc index 7ff1681f24e891..4ecb7d9a91e01e 100644 --- a/chrome/common/ipc_logging.cc +++ b/ipc/ipc_logging.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/common/ipc_logging.h" +#include "ipc/ipc_logging.h" #if defined(OS_POSIX) #ifdef IPC_MESSAGE_LOG_ENABLED @@ -19,16 +19,9 @@ #include "base/time.h" #include "base/waitable_event.h" #include "base/waitable_event_watcher.h" -#include "chrome/common/chrome_switches.h" -#include "chrome/common/ipc_sync_message.h" -#include "chrome/common/ipc_message_utils.h" - -// This include list should contain all _messages.h header files so that they -// can get *MsgLog function etc. This makes ipc logs much more informative. -#include "chrome/common/plugin_messages.h" -#include "chrome/common/render_messages.h" -#include "chrome/common/worker_messages.h" -#include "chrome/test/automation/automation_messages.h" +#include "ipc/ipc_switches.h" +#include "ipc/ipc_sync_message.h" +#include "ipc/ipc_message_utils.h" #if defined(OS_POSIX) #include "base/string_util.h" @@ -96,7 +89,6 @@ Logging::Logging() #elif defined(OS_POSIX) if (getenv("CHROME_IPC_LOGGING")) enabled_ = true; - SetLoggerFunctions(g_log_function_mapping); #endif MessageLoop::current()->AddDestructionObserver(this); diff --git a/chrome/common/ipc_logging.h b/ipc/ipc_logging.h similarity index 94% rename from chrome/common/ipc_logging.h rename to ipc/ipc_logging.h index fea0034563dff1..364ad79f8301ca 100644 --- a/chrome/common/ipc_logging.h +++ b/ipc/ipc_logging.h @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_COMMON_IPC_LOGGING_H_ -#define CHROME_COMMON_IPC_LOGGING_H_ +#ifndef IPC_IPC_LOGGING_H_ +#define IPC_IPC_LOGGING_H_ -#include "chrome/common/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. +#include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. #ifdef IPC_MESSAGE_LOG_ENABLED @@ -109,4 +109,4 @@ class Logging : public base::WaitableEventWatcher::Delegate, #endif // IPC_MESSAGE_LOG_ENABLED -#endif // CHROME_COMMON_IPC_LOGGING_H_ +#endif // IPC_IPC_LOGGING_H_ diff --git a/chrome/common/ipc_message.cc b/ipc/ipc_message.cc similarity index 97% rename from chrome/common/ipc_message.cc rename to ipc/ipc_message.cc index 6b9ded04d63cbe..84db00ce7b67fc 100644 --- a/chrome/common/ipc_message.cc +++ b/ipc/ipc_message.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/common/ipc_message.h" +#include "ipc/ipc_message.h" #include "base/logging.h" #include "build/build_config.h" #if defined(OS_POSIX) -#include "chrome/common/file_descriptor_set_posix.h" +#include "ipc/file_descriptor_set_posix.h" #endif namespace IPC { diff --git a/chrome/common/ipc_message.h b/ipc/ipc_message.h similarity index 98% rename from chrome/common/ipc_message.h rename to ipc/ipc_message.h index af4a0df8d54607..6357c0bc3175c8 100644 --- a/chrome/common/ipc_message.h +++ b/ipc/ipc_message.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_COMMON_IPC_MESSAGE_H__ -#define CHROME_COMMON_IPC_MESSAGE_H__ +#ifndef IPC_IPC_MESSAGE_H__ +#define IPC_IPC_MESSAGE_H__ #include @@ -276,4 +276,4 @@ enum SpecialRoutingIDs { #define IPC_REPLY_ID 0xFFF0 // Special message id for replies #define IPC_LOGGING_ID 0xFFF1 // Special message id for logging -#endif // CHROME_COMMON_IPC_MESSAGE_H__ +#endif // IPC_IPC_MESSAGE_H__ diff --git a/chrome/common/ipc_message_macros.h b/ipc/ipc_message_macros.h similarity index 99% rename from chrome/common/ipc_message_macros.h rename to ipc/ipc_message_macros.h index f3c927899009e1..ba2a10afedb1d6 100644 --- a/chrome/common/ipc_message_macros.h +++ b/ipc/ipc_message_macros.h @@ -40,7 +40,7 @@ // ViewHostMsg_SyncMessageName::WriteReplyParams(reply_msg, out1, out2); // Send(reply_msg); -#include "chrome/common/ipc_message_utils.h" +#include "ipc/ipc_message_utils.h" #ifndef MESSAGES_INTERNAL_FILE @@ -50,7 +50,7 @@ // Trick scons and xcode into seeing the possible real dependencies since they // don't understand #include MESSAGES_INTERNAL_FILE. See http://crbug.com/7828 #if 0 -#include "chrome/common/ipc_sync_message_unittest.h" +#include "ipc/ipc_sync_message_unittest.h" #include "chrome/common/plugin_messages_internal.h" #include "chrome/common/render_messages_internal.h" #include "chrome/common/devtools_messages_internal.h" diff --git a/ipc/ipc_message_unittest.cc b/ipc/ipc_message_unittest.cc new file mode 100644 index 00000000000000..36a3229a6948d6 --- /dev/null +++ b/ipc/ipc_message_unittest.cc @@ -0,0 +1,67 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include + +#include "base/scoped_ptr.h" +#include "base/values.h" +#include "ipc/ipc_message.h" +#include "ipc/ipc_message_utils.h" +#include "testing/gtest/include/gtest/gtest.h" + +TEST(IPCMessageTest, ListValue) { + ListValue input; + input.Set(0, Value::CreateRealValue(42.42)); + input.Set(1, Value::CreateStringValue("forty")); + input.Set(2, Value::CreateNullValue()); + + IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); + IPC::WriteParam(&msg, input); + + ListValue output; + void* iter = NULL; + EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output)); + + EXPECT_TRUE(input.Equals(&output)); + + // Also test the corrupt case. + IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL); + bad_msg.WriteInt(99); + iter = NULL; + EXPECT_FALSE(IPC::ReadParam(&bad_msg, &iter, &output)); +} + +TEST(IPCMessageTest, DictionaryValue) { + DictionaryValue input; + input.Set(L"null", Value::CreateNullValue()); + input.Set(L"bool", Value::CreateBooleanValue(true)); + input.Set(L"int", Value::CreateIntegerValue(42)); + + scoped_ptr subdict(new DictionaryValue()); + subdict->Set(L"str", Value::CreateStringValue("forty two")); + subdict->Set(L"bool", Value::CreateBooleanValue(false)); + + scoped_ptr sublist(new ListValue()); + sublist->Set(0, Value::CreateRealValue(42.42)); + sublist->Set(1, Value::CreateStringValue("forty")); + sublist->Set(2, Value::CreateStringValue("two")); + subdict->Set(L"list", sublist.release()); + + input.Set(L"dict", subdict.release()); + + IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); + IPC::WriteParam(&msg, input); + + DictionaryValue output; + void* iter = NULL; + EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output)); + + EXPECT_TRUE(input.Equals(&output)); + + // Also test the corrupt case. + IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL); + bad_msg.WriteInt(99); + iter = NULL; + EXPECT_FALSE(IPC::ReadParam(&bad_msg, &iter, &output)); +} diff --git a/ipc/ipc_message_utils.cc b/ipc/ipc_message_utils.cc new file mode 100644 index 00000000000000..ac188bfb52e736 --- /dev/null +++ b/ipc/ipc_message_utils.cc @@ -0,0 +1,235 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ipc/ipc_message_utils.h" + +#include "base/json_writer.h" +#include "base/scoped_ptr.h" +#include "base/time.h" +#include "base/values.h" + +namespace IPC { + +const int kMaxRecursionDepth = 100; + +// Value serialization + +static bool ReadValue(const Message* m, void** iter, Value** value, + int recursion); + +static void WriteValue(Message* m, const Value* value, int recursion) { + if (recursion > kMaxRecursionDepth) { + LOG(WARNING) << "Max recursion depth hit in WriteValue."; + return; + } + + m->WriteInt(value->GetType()); + + switch (value->GetType()) { + case Value::TYPE_NULL: + break; + case Value::TYPE_BOOLEAN: { + bool val; + value->GetAsBoolean(&val); + WriteParam(m, val); + break; + } + case Value::TYPE_INTEGER: { + int val; + value->GetAsInteger(&val); + WriteParam(m, val); + break; + } + case Value::TYPE_REAL: { + double val; + value->GetAsReal(&val); + WriteParam(m, val); + break; + } + case Value::TYPE_STRING: { + std::string val; + value->GetAsString(&val); + WriteParam(m, val); + break; + } + case Value::TYPE_BINARY: { + NOTREACHED() << "Don't send BinaryValues over IPC."; + } + case Value::TYPE_DICTIONARY: { + const DictionaryValue* dict = static_cast(value); + + WriteParam(m, static_cast(dict->GetSize())); + + for (DictionaryValue::key_iterator it = dict->begin_keys(); + it != dict->end_keys(); ++it) { + Value* subval; + if (dict->Get(*it, &subval)) { + WriteParam(m, *it); + WriteValue(m, subval, recursion + 1); + } else { + NOTREACHED() << "DictionaryValue iterators are filthy liars."; + } + } + break; + } + case Value::TYPE_LIST: { + const ListValue* list = static_cast(value); + WriteParam(m, static_cast(list->GetSize())); + for (size_t i = 0; i < list->GetSize(); ++i) { + Value* subval; + if (list->Get(i, &subval)) { + WriteValue(m, subval, recursion + 1); + } else { + NOTREACHED() << "ListValue::GetSize is a filthy liar."; + } + } + break; + } + } +} + +// Helper for ReadValue that reads a DictionaryValue into a pre-allocated +// object. +static bool ReadDictionaryValue(const Message* m, void** iter, + DictionaryValue* value, int recursion) { + int size; + if (!ReadParam(m, iter, &size)) + return false; + + for (int i = 0; i < size; ++i) { + std::wstring key; + Value* subval; + if (!ReadParam(m, iter, &key) || + !ReadValue(m, iter, &subval, recursion + 1)) + return false; + value->Set(key, subval); + } + + return true; +} + +// Helper for ReadValue that reads a ReadListValue into a pre-allocated +// object. +static bool ReadListValue(const Message* m, void** iter, + ListValue* value, int recursion) { + int size; + if (!ReadParam(m, iter, &size)) + return false; + + for (int i = 0; i < size; ++i) { + Value* subval; + if (!ReadValue(m, iter, &subval, recursion + 1)) + return false; + value->Set(i, subval); + } + + return true; +} + +static bool ReadValue(const Message* m, void** iter, Value** value, + int recursion) { + if (recursion > kMaxRecursionDepth) { + LOG(WARNING) << "Max recursion depth hit in ReadValue."; + return false; + } + + int type; + if (!ReadParam(m, iter, &type)) + return false; + + switch (type) { + case Value::TYPE_NULL: + *value = Value::CreateNullValue(); + break; + case Value::TYPE_BOOLEAN: { + bool val; + if (!ReadParam(m, iter, &val)) + return false; + *value = Value::CreateBooleanValue(val); + break; + } + case Value::TYPE_INTEGER: { + int val; + if (!ReadParam(m, iter, &val)) + return false; + *value = Value::CreateIntegerValue(val); + break; + } + case Value::TYPE_REAL: { + double val; + if (!ReadParam(m, iter, &val)) + return false; + *value = Value::CreateRealValue(val); + break; + } + case Value::TYPE_STRING: { + std::string val; + if (!ReadParam(m, iter, &val)) + return false; + *value = Value::CreateStringValue(val); + break; + } + case Value::TYPE_BINARY: { + NOTREACHED() << "Don't send BinaryValues over IPC."; + break; + } + case Value::TYPE_DICTIONARY: { + scoped_ptr val(new DictionaryValue()); + if (!ReadDictionaryValue(m, iter, val.get(), recursion)) + return false; + *value = val.release(); + break; + } + case Value::TYPE_LIST: { + scoped_ptr val(new ListValue()); + if (!ReadListValue(m, iter, val.get(), recursion)) + return false; + *value = val.release(); + break; + } + default: + return false; + } + + return true; +} + +void ParamTraits::Write(Message* m, const param_type& p) { + WriteValue(m, &p, 0); +} + +bool ParamTraits::Read( + const Message* m, void** iter, param_type* r) { + int type; + if (!ReadParam(m, iter, &type) || type != Value::TYPE_DICTIONARY) + return false; + + return ReadDictionaryValue(m, iter, r, 0); +} + +void ParamTraits::Log(const param_type& p, std::wstring* l) { + std::string json; + JSONWriter::Write(&p, false, &json); + l->append(UTF8ToWide(json)); +} + +void ParamTraits::Write(Message* m, const param_type& p) { + WriteValue(m, &p, 0); +} + +bool ParamTraits::Read( + const Message* m, void** iter, param_type* r) { + int type; + if (!ReadParam(m, iter, &type) || type != Value::TYPE_LIST) + return false; + + return ReadListValue(m, iter, r, 0); +} + +void ParamTraits::Log(const param_type& p, std::wstring* l) { + std::string json; + JSONWriter::Write(&p, false, &json); + l->append(UTF8ToWide(json)); +} +} // namespace IPC diff --git a/chrome/common/ipc_message_utils.h b/ipc/ipc_message_utils.h similarity index 83% rename from chrome/common/ipc_message_utils.h rename to ipc/ipc_message_utils.h index c6222e83659ec2..3fd8123863c918 100644 --- a/chrome/common/ipc_message_utils.h +++ b/ipc/ipc_message_utils.h @@ -1,9 +1,9 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_COMMON_IPC_MESSAGE_UTILS_H_ -#define CHROME_COMMON_IPC_MESSAGE_UTILS_H_ +#ifndef IPC_IPC_MESSAGE_UTILS_H_ +#define IPC_IPC_MESSAGE_UTILS_H_ #include #include @@ -11,36 +11,16 @@ #include "base/file_path.h" #include "base/format_macros.h" -#include "base/gfx/native_widget_types.h" #include "base/string16.h" #include "base/string_util.h" +#include "base/time.h" #include "base/tuple.h" +#include "base/values.h" #if defined(OS_POSIX) -#include "chrome/common/file_descriptor_set_posix.h" +#include "ipc/file_descriptor_set_posix.h" #endif -#include "chrome/common/ipc_channel_handle.h" -#include "chrome/common/ipc_sync_message.h" -#include "chrome/common/thumbnail_score.h" -#include "chrome/common/transport_dib.h" -#include "net/url_request/url_request_status.h" -#include "webkit/glue/webcursor.h" -#include "webkit/glue/window_open_disposition.h" - -// Forward declarations. -class GURL; -class SkBitmap; -class DictionaryValue; -class ListValue; - -namespace gfx { -class Point; -class Rect; -class Size; -} // namespace gfx - -namespace webkit_glue { -struct WebApplicationInfo; -} // namespace webkit_glue +#include "ipc/ipc_channel_handle.h" +#include "ipc/ipc_sync_message.h" // 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 @@ -73,6 +53,7 @@ enum IPCMessageStart { COMPILE_ASSERT(LastMsgIndex <= 16, need_to_update_IPC_MESSAGE_MACRO); + namespace IPC { //----------------------------------------------------------------------------- @@ -375,18 +356,6 @@ struct ParamTraits { }; #endif // defined(OS_WIN) -template <> -struct ParamTraits { - typedef SkBitmap param_type; - 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 Message* m, void** iter, param_type* r); - - static void Log(const param_type& p, std::wstring* l); -}; - template <> struct ParamTraits { typedef DictionaryValue param_type; @@ -572,14 +541,6 @@ struct ParamTraits { }; #endif -template <> -struct ParamTraits { - typedef GURL param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* p); - static void Log(const param_type& p, std::wstring* l); -}; - // and, a few more useful types... #if defined(OS_WIN) template <> @@ -663,45 +624,6 @@ struct ParamTraits { } }; -template <> -struct ParamTraits { - typedef gfx::Point param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); - static void Log(const param_type& p, std::wstring* l); -}; - -template <> -struct ParamTraits { - typedef gfx::Rect param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); - static void Log(const param_type& p, std::wstring* l); -}; - -template <> -struct ParamTraits { - typedef gfx::Size param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); - static void Log(const param_type& p, std::wstring* l); -}; - -template <> -struct ParamTraits { - typedef gfx::NativeWindow param_type; - static void Write(Message* m, const param_type& p) { - m->WriteIntPtr(reinterpret_cast(p)); - } - 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(r)); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(StringPrintf(L"0x%X", p)); - } -}; - #if defined(OS_POSIX) // FileDescriptors may be serialised over IPC channels on POSIX. On the // receiving side, the FileDescriptor is a valid duplicate of the file @@ -781,54 +703,6 @@ struct ParamTraits { } }; -template<> -struct ParamTraits { - typedef ThumbnailScore param_type; - static void Write(Message* m, const param_type& p) { - IPC::ParamTraits::Write(m, p.boring_score); - IPC::ParamTraits::Write(m, p.good_clipping); - IPC::ParamTraits::Write(m, p.at_top); - IPC::ParamTraits::Write(m, p.time_at_snapshot); - } - 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 (!IPC::ParamTraits::Read(m, iter, &boring_score) || - !IPC::ParamTraits::Read(m, iter, &good_clipping) || - !IPC::ParamTraits::Read(m, iter, &at_top) || - !IPC::ParamTraits::Read(m, iter, &time_at_snapshot)) - return false; - - r->boring_score = boring_score; - r->good_clipping = good_clipping; - r->at_top = at_top; - r->time_at_snapshot = time_at_snapshot; - return true; - } - static void Log(const param_type& p, std::wstring* l) { - l->append(StringPrintf(L"(%f, %d, %d)", - p.boring_score, p.good_clipping, p.at_top)); - } -}; - -template <> -struct ParamTraits { - typedef WindowOpenDisposition param_type; - static void Write(Message* m, const param_type& p) { - m->WriteInt(p); - } - static bool Read(const Message* m, void** iter, param_type* r) { - int temp; - bool res = m->ReadInt(iter, &temp); - *r = static_cast(temp); - return res; - } - static void Log(const param_type& p, std::wstring* l) { - l->append(StringPrintf(L"%d", p)); - } -}; - #if defined(OS_WIN) template <> struct ParamTraits { @@ -855,20 +729,6 @@ struct ParamTraits { }; #endif // defined(OS_WIN) -template <> -struct ParamTraits { - typedef WebCursor param_type; - static void Write(Message* m, const param_type& p) { - p.Serialize(m); - } - 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) { - l->append(L""); - } -}; - struct LogData { std::string channel; int32 routing_id; @@ -916,89 +776,6 @@ struct ParamTraits { }; -template <> -struct ParamTraits { - typedef webkit_glue::WebApplicationInfo param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); - static void Log(const param_type& p, std::wstring* l); -}; - - -#if defined(OS_WIN) -template<> -struct ParamTraits { - typedef TransportDIB::Id param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.handle); - WriteParam(m, p.sequence_num); - } - static bool Read(const Message* m, void** iter, param_type* r) { - return (ReadParam(m, iter, &r->handle) && - ReadParam(m, iter, &r->sequence_num)); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"TransportDIB("); - LogParam(p.handle, l); - l->append(L", "); - LogParam(p.sequence_num, l); - l->append(L")"); - } -}; -#endif - -// Traits for URLRequestStatus -template <> -struct ParamTraits { - typedef URLRequestStatus param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, static_cast(p.status())); - WriteParam(m, p.os_error()); - } - 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)) - return false; - r->set_status(static_cast(status)); - r->set_os_error(os_error); - return true; - } - static void Log(const param_type& p, std::wstring* l) { - std::wstring status; - switch (p.status()) { - case URLRequestStatus::SUCCESS: - status = L"SUCCESS"; - break; - case URLRequestStatus::IO_PENDING: - status = L"IO_PENDING "; - break; - case URLRequestStatus::HANDLED_EXTERNALLY: - status = L"HANDLED_EXTERNALLY"; - break; - case URLRequestStatus::CANCELED: - status = L"CANCELED"; - break; - case URLRequestStatus::FAILED: - status = L"FAILED"; - break; - default: - status = L"UNKNOWN"; - break; - } - if (p.status() == URLRequestStatus::FAILED) - l->append(L"("); - - LogParam(status, l); - - if (p.status() == URLRequestStatus::FAILED) { - l->append(L", "); - LogParam(p.os_error(), l); - l->append(L")"); - } - } -}; - template <> struct ParamTraits { static void Write(Message* m, const Message& p) { @@ -1441,4 +1218,4 @@ class MessageWithReply : public SyncMessage { } // namespace IPC -#endif // CHROME_COMMON_IPC_MESSAGE_UTILS_H_ +#endif // IPC_IPC_MESSAGE_UTILS_H_ diff --git a/chrome/common/ipc_send_fds_test.cc b/ipc/ipc_send_fds_test.cc similarity index 97% rename from chrome/common/ipc_send_fds_test.cc rename to ipc/ipc_send_fds_test.cc index 24cc870e27d014..5f399daf6aa338 100644 --- a/chrome/common/ipc_send_fds_test.cc +++ b/ipc/ipc_send_fds_test.cc @@ -4,7 +4,7 @@ #include "build/build_config.h" -#include "chrome/common/ipc_tests.h" +#include "ipc/ipc_tests.h" #if defined(OS_MACOSX) extern "C" { @@ -16,8 +16,8 @@ extern "C" { #include "base/eintr_wrapper.h" #include "base/message_loop.h" -#include "chrome/common/ipc_channel.h" -#include "chrome/common/ipc_message_utils.h" +#include "ipc/ipc_channel.h" +#include "ipc/ipc_message_utils.h" #if defined(OS_POSIX) diff --git a/ipc/ipc_switches.cc b/ipc/ipc_switches.cc new file mode 100644 index 00000000000000..18f7c2736b3acf --- /dev/null +++ b/ipc/ipc_switches.cc @@ -0,0 +1,28 @@ +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ipc/ipc_switches.h" + +#include "base/base_switches.h" + +namespace switches { + +// Can't find the switch you are looking for? try looking in +// base/base_switches.cc instead. + +// On POSIX only: use FIFO for IPC channels so that "unrelated" process +// can connect to a channel, provided it knows its name. For debugging purposes. +const wchar_t kIPCUseFIFO[] = L"ipc-use-fifo"; + +// The value of this switch tells the child process which +// IPC channel the browser expects to use to communicate with it. +const wchar_t kProcessChannelID[] = L"channel"; + +// Will add kDebugOnStart to every child processes. If a value is passed, it +// will be used as a filter to determine if the child process should have the +// kDebugOnStart flag passed on or not. +const wchar_t kDebugChildren[] = L"debug-children"; + +} // namespace switches + diff --git a/ipc/ipc_switches.h b/ipc/ipc_switches.h new file mode 100644 index 00000000000000..1468432dcc8e46 --- /dev/null +++ b/ipc/ipc_switches.h @@ -0,0 +1,20 @@ +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Defines all the command-line switches used by the IPC infrastructure. + +#ifndef IPC_IPC_SWITCHES_H_ +#define IPC_IPC_SWITCHES_H_ + +#include "base/base_switches.h" + +namespace switches { + +extern const wchar_t kIPCUseFIFO[]; +extern const wchar_t kProcessChannelID[]; +extern const wchar_t kDebugChildren[]; + +} // namespace switches + +#endif // IPC_IPC_SWITCHES_H_ diff --git a/chrome/common/ipc_sync_channel.cc b/ipc/ipc_sync_channel.cc similarity index 99% rename from chrome/common/ipc_sync_channel.cc rename to ipc/ipc_sync_channel.cc index 6b5179caa043d3..de9b434a7ad44c 100644 --- a/chrome/common/ipc_sync_channel.cc +++ b/ipc/ipc_sync_channel.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/common/ipc_sync_channel.h" +#include "ipc/ipc_sync_channel.h" #include "base/lazy_instance.h" #include "base/logging.h" @@ -10,7 +10,7 @@ #include "base/message_loop.h" #include "base/waitable_event.h" #include "base/waitable_event_watcher.h" -#include "chrome/common/ipc_sync_message.h" +#include "ipc/ipc_sync_message.h" using base::TimeDelta; using base::TimeTicks; diff --git a/chrome/common/ipc_sync_channel.h b/ipc/ipc_sync_channel.h similarity index 96% rename from chrome/common/ipc_sync_channel.h rename to ipc/ipc_sync_channel.h index 3b2c671843b105..f5d2addec8f7ad 100644 --- a/chrome/common/ipc_sync_channel.h +++ b/ipc/ipc_sync_channel.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_COMMON_IPC_SYNC_SENDER_H__ -#define CHROME_COMMON_IPC_SYNC_SENDER_H__ +#ifndef IPC_IPC_SYNC_SENDER_H__ +#define IPC_IPC_SYNC_SENDER_H__ #include #include @@ -12,7 +12,7 @@ #include "base/lock.h" #include "base/ref_counted.h" #include "base/waitable_event_watcher.h" -#include "chrome/common/ipc_channel_proxy.h" +#include "ipc/ipc_channel_proxy.h" namespace base { class WaitableEvent; @@ -159,4 +159,4 @@ class SyncChannel : public ChannelProxy, } // namespace IPC -#endif // CHROME_COMMON_IPC_SYNC_SENDER_H__ +#endif // IPC_IPC_SYNC_SENDER_H__ diff --git a/chrome/common/ipc_sync_channel_unittest.cc b/ipc/ipc_sync_channel_unittest.cc similarity index 99% rename from chrome/common/ipc_sync_channel_unittest.cc rename to ipc/ipc_sync_channel_unittest.cc index 8d4cd804af2414..f20f78811fe841 100644 --- a/chrome/common/ipc_sync_channel_unittest.cc +++ b/ipc/ipc_sync_channel_unittest.cc @@ -15,13 +15,13 @@ #include "base/string_util.h" #include "base/thread.h" #include "base/waitable_event.h" -#include "chrome/common/ipc_message.h" -#include "chrome/common/ipc_sync_channel.h" +#include "ipc/ipc_message.h" +#include "ipc/ipc_sync_channel.h" #include "testing/gtest/include/gtest/gtest.h" -#define MESSAGES_INTERNAL_FILE "chrome/common/ipc_sync_message_unittest.h" -#include "chrome/common/ipc_message_macros.h" +#define MESSAGES_INTERNAL_FILE "ipc/ipc_sync_message_unittest.h" +#include "ipc/ipc_message_macros.h" using namespace IPC; using base::WaitableEvent; diff --git a/chrome/common/ipc_sync_message.cc b/ipc/ipc_sync_message.cc similarity index 98% rename from chrome/common/ipc_sync_message.cc rename to ipc/ipc_sync_message.cc index a7407e43453365..519adb17555b5f 100644 --- a/chrome/common/ipc_sync_message.cc +++ b/ipc/ipc_sync_message.cc @@ -11,7 +11,7 @@ #include "base/logging.h" #include "base/waitable_event.h" -#include "chrome/common/ipc_sync_message.h" +#include "ipc/ipc_sync_message.h" namespace IPC { diff --git a/chrome/common/ipc_sync_message.h b/ipc/ipc_sync_message.h similarity index 94% rename from chrome/common/ipc_sync_message.h rename to ipc/ipc_sync_message.h index b03007e343cc11..5d072a7561ff74 100644 --- a/chrome/common/ipc_sync_message.h +++ b/ipc/ipc_sync_message.h @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_COMMON_IPC_SYNC_MESSAGE_H__ -#define CHROME_COMMON_IPC_SYNC_MESSAGE_H__ +#ifndef IPC_IPC_SYNC_MESSAGE_H__ +#define IPC_IPC_SYNC_MESSAGE_H__ #if defined(OS_WIN) #include #endif #include #include "base/basictypes.h" -#include "chrome/common/ipc_message.h" +#include "ipc/ipc_message.h" namespace base { class WaitableEvent; @@ -93,4 +93,4 @@ class MessageReplyDeserializer { } // namespace IPC -#endif // CHROME_COMMON_IPC_SYNC_MESSAGE_H__ +#endif // IPC_IPC_SYNC_MESSAGE_H__ diff --git a/chrome/common/ipc_sync_message_unittest.cc b/ipc/ipc_sync_message_unittest.cc similarity index 96% rename from chrome/common/ipc_sync_message_unittest.cc rename to ipc/ipc_sync_message_unittest.cc index b4f86a27c1f08d..1c92574a39f7b7 100644 --- a/chrome/common/ipc_sync_message_unittest.cc +++ b/ipc/ipc_sync_message_unittest.cc @@ -9,14 +9,14 @@ #include #include "base/basictypes.h" -#include "chrome/common/ipc_message.h" -#include "chrome/common/ipc_message_utils.h" +#include "ipc/ipc_message.h" +#include "ipc/ipc_message_utils.h" #include "base/logging.h" #include "testing/gtest/include/gtest/gtest.h" -#define MESSAGES_INTERNAL_FILE "chrome/common/ipc_sync_message_unittest.h" -#include "chrome/common/ipc_message_macros.h" +#define MESSAGES_INTERNAL_FILE "ipc/ipc_sync_message_unittest.h" +#include "ipc/ipc_message_macros.h" static IPC::Message* g_reply; diff --git a/chrome/common/ipc_sync_message_unittest.h b/ipc/ipc_sync_message_unittest.h similarity index 98% rename from chrome/common/ipc_sync_message_unittest.h rename to ipc/ipc_sync_message_unittest.h index 4ac9099b9bdeb8..7b252b56c5a551 100644 --- a/chrome/common/ipc_sync_message_unittest.h +++ b/ipc/ipc_sync_message_unittest.h @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/common/ipc_message_macros.h" +#include "ipc/ipc_message_macros.h" IPC_BEGIN_MESSAGES(Test) IPC_SYNC_MESSAGE_CONTROL0_0(SyncChannelTestMsg_NoArgs) diff --git a/chrome/common/ipc_tests.cc b/ipc/ipc_tests.cc similarity index 98% rename from chrome/common/ipc_tests.cc rename to ipc/ipc_tests.cc index c2e0baac7edb2c..172284eeadd360 100644 --- a/chrome/common/ipc_tests.cc +++ b/ipc/ipc_tests.cc @@ -15,7 +15,7 @@ #include #include -#include "chrome/common/ipc_tests.h" +#include "ipc/ipc_tests.h" #include "base/at_exit.h" #include "base/base_switches.h" @@ -29,11 +29,11 @@ #include "base/perf_test_suite.h" #include "base/test_suite.h" #include "base/thread.h" -#include "chrome/common/chrome_switches.h" -#include "chrome/common/chrome_descriptors.h" -#include "chrome/common/ipc_channel.h" -#include "chrome/common/ipc_channel_proxy.h" -#include "chrome/common/ipc_message_utils.h" +#include "ipc/ipc_descriptors.h" +#include "ipc/ipc_channel.h" +#include "ipc/ipc_channel_proxy.h" +#include "ipc/ipc_message_utils.h" +#include "ipc/ipc_switches.h" #include "testing/multiprocess_func_list.h" // Define to enable IPC performance testing instead of the regular unit tests diff --git a/chrome/common/ipc_tests.h b/ipc/ipc_tests.h similarity index 91% rename from chrome/common/ipc_tests.h rename to ipc/ipc_tests.h index 36026bfd32ef77..e800883ae7640f 100644 --- a/chrome/common/ipc_tests.h +++ b/ipc/ipc_tests.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_COMMON_IPC_TESTS_H__ -#define CHROME_COMMON_IPC_TESTS_H__ +#ifndef IPC_IPC_TESTS_H__ +#define IPC_IPC_TESTS_H__ #include "base/multiprocess_test.h" #include "base/process.h" @@ -44,4 +44,4 @@ class IPCChannelTest : public MultiProcessTest { MessageLoopForIO *message_loop_; }; -#endif // CHROME_COMMON_IPC_TESTS_H__ +#endif // IPC_IPC_TESTS_H__