diff options
-rw-r--r-- | chrome/chrome.xcodeproj/project.pbxproj | 53 | ||||
-rw-r--r-- | chrome/common/common.scons | 1 | ||||
-rw-r--r-- | chrome/common/ipc_channel_proxy.cc | 8 | ||||
-rw-r--r-- | chrome/common/ipc_logging.cc | 82 | ||||
-rw-r--r-- | chrome/common/ipc_logging.h | 16 | ||||
-rw-r--r-- | chrome/common/ipc_message.h | 5 | ||||
-rw-r--r-- | chrome/common/ipc_message_utils.h | 1 | ||||
-rw-r--r-- | chrome/common/ipc_tests.scons | 11 |
8 files changed, 135 insertions, 42 deletions
diff --git a/chrome/chrome.xcodeproj/project.pbxproj b/chrome/chrome.xcodeproj/project.pbxproj index 7cb12a3..e270f07 100644 --- a/chrome/chrome.xcodeproj/project.pbxproj +++ b/chrome/chrome.xcodeproj/project.pbxproj @@ -75,6 +75,7 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ + 2DF2A9EB8AF96926EE9B6B02 /* ipc_logging.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BFBAE0E9D4C9F009A6919 /* ipc_logging.cc */; }; 1C284EB767D0E3D302AC675C /* tab_restore_service.cc in Sources */ = {isa = PBXBuildFile; fileRef = B020A11D500D7519E54F2957 /* tab_restore_service.cc */; }; 331218220F3BFF32006CB2B0 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 331B93A90F3BF2B9008B1C46 /* QuartzCore.framework */; }; 331218230F3BFF36006CB2B0 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 331B93AB0F3BF2DA008B1C46 /* Carbon.framework */; }; @@ -116,6 +117,9 @@ 3380A9C00F2FC61E004EF74F /* render_process_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3380A9BF0F2FC61E004EF74F /* render_process_unittest.cc */; }; 3380A9D60F2FC8F6004EF74F /* render_dns_master.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D640CE10EAE86A500EBCFC0 /* render_dns_master.cc */; }; 3380A9D70F2FC8F9004EF74F /* render_dns_master.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D640CE10EAE86A500EBCFC0 /* render_dns_master.cc */; }; + 33A327240F439BDD005AC1DA /* libnet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 33A327230F439BDD005AC1DA /* libnet.a */; }; + 33A3272C0F439CFC005AC1DA /* libglue.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 33A3272B0F439CFC005AC1DA /* libglue.a */; }; + 33A3272F0F439D6A005AC1DA /* libwtf.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 33A3272E0F439D6A005AC1DA /* libwtf.a */; }; 3AEA44DB19C9D93B63D7A2E4 /* url_fetcher_protect.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0B7CC9C105E90E0665852528 /* url_fetcher_protect.cc */; }; 406DFE278638D6132B21B2C9 /* url_pattern.cc in Sources */ = {isa = PBXBuildFile; fileRef = 6447F24FADC63E58A44DB762 /* url_pattern.cc */; }; 423A79243BC7B7C0B1E9B97A /* session_service.cc in Sources */ = {isa = PBXBuildFile; fileRef = C8D26D9EC81E03E91E270463 /* session_service.cc */; }; @@ -892,6 +896,27 @@ remoteGlobalIDString = 7B5E85AD0D7F28CD001ECF42; remoteInfo = wtf; }; + 33A327250F439BF3005AC1DA /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 4D7B00340E9D5464009A6919 /* net.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = D2AAC045055464E500DB518D; + remoteInfo = net; + }; + 33A327290F439C9B005AC1DA /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 826850040F2FC82D009F6555 /* webkit.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = E45626A20E268F03005E4685; + remoteInfo = glue; + }; + 33A327300F439D7E005AC1DA /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 826850040F2FC82D009F6555 /* webkit.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = 7B5E85AD0D7F28CD001ECF42; + remoteInfo = wtf; + }; 4D1F59EE0F2A6B740040C1E3 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 4D7BF2E90E9D46A4009A6919 /* Project object */; @@ -1781,6 +1806,9 @@ 3380A6B50F2E9252004EF74F /* render_thread_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = render_thread_unittest.cc; sourceTree = "<group>"; }; 3380A6B90F2E9275004EF74F /* render_view_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = render_view_unittest.cc; sourceTree = "<group>"; }; 3380A9BF0F2FC61E004EF74F /* render_process_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = render_process_unittest.cc; sourceTree = "<group>"; }; + 33A327230F439BDD005AC1DA /* libnet.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libnet.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 33A3272B0F439CFC005AC1DA /* libglue.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libglue.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 33A3272E0F439D6A005AC1DA /* libwtf.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libwtf.a; sourceTree = BUILT_PRODUCTS_DIR; }; 37521A11B07C479E93A39D52 /* user_script_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = user_script_unittest.cc; path = common/extensions/user_script_unittest.cc; sourceTree = SOURCE_ROOT; }; 3CCF8AA8A56FF8FE59F0C299 /* template_url.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = template_url.cc; sourceTree = "<group>"; }; 3D00CDB6C665E7ED1A1090D7 /* bookmark_model.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = bookmark_model.cc; path = browser/bookmarks/bookmark_model.cc; sourceTree = SOURCE_ROOT; }; @@ -2841,12 +2869,15 @@ E4F3258A0EE8375A002533CE /* libbase_gfx.a in Frameworks */, B5FDC1D00EE48ADB00BEC6E6 /* libcommon.a in Frameworks */, B5FDC1D10EE48ADB00BEC6E6 /* libevent.a in Frameworks */, + 33A3272C0F439CFC005AC1DA /* libglue.a in Frameworks */, E4F3258C0EE83767002533CE /* libgoogleurl.a in Frameworks */, B5FDC1D30EE48ADB00BEC6E6 /* libgtest.a in Frameworks */, B5FDC1D40EE48ADB00BEC6E6 /* libicudata.a in Frameworks */, B5FDC2180EE48F4100BEC6E6 /* libicui18n.a in Frameworks */, B5FDC1D60EE48ADB00BEC6E6 /* libicuuc.a in Frameworks */, + 33A327240F439BDD005AC1DA /* libnet.a in Frameworks */, E4F325880EE83745002533CE /* libskia.a in Frameworks */, + 33A3272F0F439D6A005AC1DA /* libwtf.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3032,6 +3063,9 @@ 4D7BF2E70E9D46A4009A6919 = { isa = PBXGroup; children = ( + 33A3272E0F439D6A005AC1DA /* libwtf.a */, + 33A3272B0F439CFC005AC1DA /* libglue.a */, + 33A327230F439BDD005AC1DA /* libnet.a */, 4D7BF2FA0E9D46CD009A6919 /* Configuration */, 4D7BF3380E9D479D009A6919 /* Source */, 4D7BFDD00E9D527E009A6919 /* Frameworks */, @@ -4562,6 +4596,9 @@ B5067F650EE4938E00CC5024 /* PBXTargetDependency */, B5067F5F0EE4937A00CC5024 /* PBXTargetDependency */, 4DCE9E260EF0B7C100682526 /* PBXTargetDependency */, + 33A327260F439BF3005AC1DA /* PBXTargetDependency */, + 33A3272A0F439C9B005AC1DA /* PBXTargetDependency */, + 33A327310F439D7E005AC1DA /* PBXTargetDependency */, ); name = ipc_tests; productName = ipc_tests; @@ -5474,6 +5511,7 @@ 4D7BFC330E9D4CF9009A6919 /* env_vars.cc in Sources */, B5FDC0580EE488E500BEC6E6 /* ipc_channel_posix.cc in Sources */, B5DBEA900EFC60E200C95176 /* ipc_channel_proxy.cc in Sources */, + 2DF2A9EB8AF96926EE9B6B02 /* ipc_logging.cc in Sources */, 4D7BFC380E9D4CFF009A6919 /* ipc_message.cc in Sources */, E4F3257D0EE83679002533CE /* ipc_message_utils.cc in Sources */, B507AC1F0F0048E10060FEE8 /* ipc_sync_message.cc in Sources */, @@ -5791,6 +5829,21 @@ name = wtf; targetProxy = 33121F3C0F3CF49C006CB2B0 /* PBXContainerItemProxy */; }; + 33A327260F439BF3005AC1DA /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = net; + targetProxy = 33A327250F439BF3005AC1DA /* PBXContainerItemProxy */; + }; + 33A3272A0F439C9B005AC1DA /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = glue; + targetProxy = 33A327290F439C9B005AC1DA /* PBXContainerItemProxy */; + }; + 33A327310F439D7E005AC1DA /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = wtf; + targetProxy = 33A327300F439D7E005AC1DA /* PBXContainerItemProxy */; + }; 4D1F59EF0F2A6B740040C1E3 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 4D1F59E90F2A6B590040C1E3 /* image_diff */; diff --git a/chrome/common/common.scons b/chrome/common/common.scons index 832485f..5824335 100644 --- a/chrome/common/common.scons +++ b/chrome/common/common.scons @@ -232,7 +232,6 @@ if not env.Bit('windows'): 'gfx/emf.cc', 'gfx/icon_util.cc', 'gfx/path.cc', - 'ipc_logging.cc', 'os_exchange_data.cc', 'process_watcher.cc', ) diff --git a/chrome/common/ipc_channel_proxy.cc b/chrome/common/ipc_channel_proxy.cc index 11fdb9b..6173135 100644 --- a/chrome/common/ipc_channel_proxy.cc +++ b/chrome/common/ipc_channel_proxy.cc @@ -5,19 +5,11 @@ #include "base/message_loop.h" #include "base/thread.h" #include "chrome/common/ipc_channel_proxy.h" -#if defined(OS_WIN) -// TODO(playmobil): remove ifdef once ObjectWatcher is ported #include "chrome/common/ipc_logging.h" -#endif #include "chrome/common/ipc_message_utils.h" namespace IPC { -#if defined(OS_POSIX) -// TODO(playmobil): remove once ObjectWatcher is ported -#undef IPC_MESSAGE_LOG_ENABLED -#endif - //----------------------------------------------------------------------------- ChannelProxy::Context::Context(Channel::Listener* listener, diff --git a/chrome/common/ipc_logging.cc b/chrome/common/ipc_logging.cc index c9874b7..6cb401f 100644 --- a/chrome/common/ipc_logging.cc +++ b/chrome/common/ipc_logging.cc @@ -4,17 +4,34 @@ #include "chrome/common/ipc_logging.h" +#if defined(OS_POSIX) +#ifdef IPC_MESSAGE_LOG_ENABLED +// This will cause render_messages.h etc to define ViewMsgLog and friends. +#define IPC_MESSAGE_MACROS_LOG_ENABLED +#endif +#endif + #include "base/command_line.h" #include "base/logging.h" #include "base/message_loop.h" #include "base/string_util.h" #include "base/thread.h" #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" #include "chrome/common/render_messages.h" +#if defined(OS_WIN) +// TODO(port): These messages will need to be ported at some point #include "chrome/common/plugin_messages.h" +#endif + +#if defined(OS_POSIX) +#include "base/string_util.h" +#include <unistd.h> +#endif #ifdef IPC_MESSAGE_LOG_ENABLED @@ -41,14 +58,17 @@ Logging::Logging() : logging_event_on_(NULL), logging_event_off_(NULL), enabled_(false), - sender_(NULL), - consumer_(NULL), queue_invoke_later_pending_(false), - main_thread_(MessageLoop::current()) { + sender_(NULL), + main_thread_(MessageLoop::current()), + consumer_(NULL) { // Create an event for this browser instance that's set when logging is // enabled, so child processes can know when logging is enabled. - int browser_pid; +#if defined(OS_WIN) + // On Windows we have a couple of named events which switch logging on and + // off. + int browser_pid; const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); std::wstring process_type = parsed_command_line.GetSwitchValue(switches::kProcessType); @@ -63,18 +83,23 @@ Logging::Logging() } std::wstring event_name = GetEventName(browser_pid, true); - logging_event_on_ = CreateEvent(NULL, TRUE, FALSE, event_name.c_str()); + logging_event_on_.reset(new base::WaitableEvent( + CreateEvent(NULL, TRUE, FALSE, event_name.c_str()))); event_name = GetEventName(browser_pid, false); - logging_event_off_ = CreateEvent(NULL, TRUE, FALSE, event_name.c_str()); + logging_event_off_.reset(new base::WaitableEvent( + CreateEvent(NULL, TRUE, FALSE, event_name.c_str()))); RegisterWaitForEvent(true); +#elif defined(OS_POSIX) + if (getenv("CHROME_IPC_LOGGING")) + enabled_ = true; + SetLoggerFunctions(g_log_function_mapping); +#endif } Logging::~Logging() { watcher_.StopWatching(); - CloseHandle(logging_event_on_); - CloseHandle(logging_event_off_); } Logging* Logging::current() { @@ -84,11 +109,11 @@ Logging* Logging::current() { void Logging::RegisterWaitForEvent(bool enabled) { watcher_.StopWatching(); watcher_.StartWatching( - enabled ? logging_event_on_ : logging_event_off_, this); + enabled ? logging_event_on_.get() : logging_event_off_.get(), this); } -void Logging::OnObjectSignaled(HANDLE object) { - enabled_ = object == logging_event_on_; +void Logging::OnWaitableEventSignaled(base::WaitableEvent* event) { + enabled_ = event == logging_event_on_.get(); RegisterWaitForEvent(!enabled_); } @@ -96,9 +121,11 @@ void Logging::SetLoggerFunctions(LogFunction *functions) { log_function_mapping_ = functions; } +#if defined(OS_WIN) std::wstring Logging::GetEventName(bool enabled) { return current()->GetEventName(GetCurrentProcessId(), enabled); } +#endif std::wstring Logging::GetEventName(int browser_pid, bool enabled) { std::wstring result = StringPrintf(kLoggingEventName, browser_pid); @@ -111,17 +138,13 @@ void Logging::SetConsumer(Consumer* consumer) { } void Logging::Enable() { - ResetEvent(logging_event_off_); - SetEvent(logging_event_on_); + logging_event_off_->Reset(); + logging_event_on_->Signal(); } void Logging::Disable() { - ResetEvent(logging_event_on_); - SetEvent(logging_event_off_); -} - -inline bool Logging::Enabled() const { - return enabled_; + logging_event_on_->Reset(); + logging_event_off_->Signal(); } void Logging::OnSendLogs() { @@ -182,7 +205,11 @@ void Logging::OnPreDispatchMessage(const Message& message) { void Logging::OnPostDispatchMessage(const Message& message, const std::wstring& channel_id) { - if (!Enabled() || !message.sent_time() || message.dont_log()) + if (!Enabled() || +#if defined(OS_WIN) + !message.sent_time() || +#endif + message.dont_log()) return; LogData data; @@ -212,6 +239,7 @@ void Logging::GetMessageText(uint16 type, std::wstring* name, } void Logging::Log(const LogData& data) { +#if defined(OS_WIN) if (consumer_) { // We're in the browser process. consumer_->Log(data); @@ -226,6 +254,15 @@ void Logging::Log(const LogData& data) { } } } +#elif defined(OS_POSIX) + // On POSIX, for now, we just dump the log to stderr + fprintf(stderr, "ipc %s %d %s %s %s\n", + WideToUTF8(data.channel).c_str(), + data.type, + WideToUTF8(data.flags).c_str(), + WideToUTF8(data.message_name).c_str(), + WideToUTF8(data.params).c_str()); +#endif } void GenerateLogData(const std::wstring& channel, const Message& message, @@ -252,8 +289,8 @@ void GenerateLogData(const std::wstring& channel, const Message& message, if (message.is_reply_error()) flags += L"E"; - std::wstring params; - Logging::GetMessageText(message.type(), NULL, &message, ¶ms); + std::wstring params, message_name; + Logging::GetMessageText(message.type(), &message_name, &message, ¶ms); data->channel = channel; data->type = message.type(); @@ -262,6 +299,7 @@ void GenerateLogData(const std::wstring& channel, const Message& message, data->receive = message.received_time(); data->dispatch = Time::Now().ToInternalValue(); data->params = params; + data->message_name = message_name; } } diff --git a/chrome/common/ipc_logging.h b/chrome/common/ipc_logging.h index 5d4016d..06a687b 100644 --- a/chrome/common/ipc_logging.h +++ b/chrome/common/ipc_logging.h @@ -10,8 +10,8 @@ #ifdef IPC_MESSAGE_LOG_ENABLED #include "base/lock.h" -#include "base/object_watcher.h" #include "base/singleton.h" +#include "base/waitable_event_watcher.h" #include "chrome/common/ipc_message_utils.h" class MessageLoop; @@ -23,7 +23,7 @@ class Message; // One instance per process. Needs to be created on the main thread (the UI // thread in the browser) but OnPreDispatchMessage/OnPostDispatchMessage // can be called on other threads. -class Logging : public base::ObjectWatcher::Delegate { +class Logging : public base::WaitableEventWatcher::Delegate { public: // Implemented by consumers of log messages. class Consumer { @@ -38,7 +38,7 @@ class Logging : public base::ObjectWatcher::Delegate { void Enable(); void Disable(); - bool inline Enabled() const; + bool Enabled() const { return enabled_; } // Called by child processes to give the logger object the channel to send // logging data to the browser process. @@ -64,8 +64,8 @@ class Logging : public base::ObjectWatcher::Delegate { static void GetMessageText(uint16 type, std::wstring* name, const Message* message, std::wstring* params); - // ObjectWatcher::Delegate implementation - void OnObjectSignaled(HANDLE object); + // WaitableEventWatcher::Delegate implementation + void OnWaitableEventSignaled(base::WaitableEvent* event); typedef void (*LogFunction)(uint16 type, std::wstring* name, @@ -84,10 +84,10 @@ class Logging : public base::ObjectWatcher::Delegate { void RegisterWaitForEvent(bool enabled); - base::ObjectWatcher watcher_; + base::WaitableEventWatcher watcher_; - HANDLE logging_event_on_; - HANDLE logging_event_off_; + scoped_ptr<base::WaitableEvent> logging_event_on_; + scoped_ptr<base::WaitableEvent> logging_event_off_; bool enabled_; std::vector<LogData> queued_logs_; diff --git a/chrome/common/ipc_message.h b/chrome/common/ipc_message.h index 8aedbe3..0601ed6 100644 --- a/chrome/common/ipc_message.h +++ b/chrome/common/ipc_message.h @@ -11,12 +11,11 @@ #include "base/pickle.h" #include "testing/gtest/include/gtest/gtest_prod.h" -#if defined(OS_WIN) -// TODO(port): IPC message logging hasn't been ported to other platforms yet. #ifndef NDEBUG #define IPC_MESSAGE_LOG_ENABLED #endif -#elif defined(OS_POSIX) + +#if defined(OS_POSIX) #include "chrome/common/descriptor_set_posix.h" #endif diff --git a/chrome/common/ipc_message_utils.h b/chrome/common/ipc_message_utils.h index e7dd7e3..a87a594 100644 --- a/chrome/common/ipc_message_utils.h +++ b/chrome/common/ipc_message_utils.h @@ -867,6 +867,7 @@ struct LogData { // OnMessageReceived). int64 dispatch; // Time after it was dispatched (i.e. after calling // OnMessageReceived). + std::wstring message_name; std::wstring params; }; diff --git a/chrome/common/ipc_tests.scons b/chrome/common/ipc_tests.scons index a9dd518..3f2c3fb 100644 --- a/chrome/common/ipc_tests.scons +++ b/chrome/common/ipc_tests.scons @@ -8,6 +8,8 @@ env = env.Clone() env.SConscript([ '$BASE_DIR/using_base.scons', + '$BASE_DIR/gfx/using_base_gfx.scons', # needed for logging + '$CHROME_SRC_DIR/build/using_googleurl.scons', # needed for logging '$BREAKPAD_DIR/using_breakpad.scons', '$CHROME_DIR/third_party/wtl/using_wtl.scons', '$GTEST_DIR/../using_gtest.scons', @@ -15,11 +17,20 @@ env.SConscript([ '$LIBJPEG_DIR/using_libjpeg.scons', '$LIBPNG_DIR/using_libpng.scons', '$LIBXML_DIR/using_libxml.scons', + '$NET_DIR/using_net.scons', # needed for logging '$NPAPI_DIR/using_npapi.scons', '$SKIA_DIR/using_skia.scons', '$ZLIB_DIR/using_zlib.scons', ], {'env':env}) +# needed for logging +env.Append( + LIBS = [ + 'glue', + 'WTF', + ], +) + if env.Bit('posix'): env.SConscript([ '$LIBEVENT_DIR/using_libevent.scons', |