summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/chrome.xcodeproj/project.pbxproj2
-rw-r--r--chrome/common/common.scons5
-rw-r--r--chrome/common/ipc_channel_proxy.cc39
-rw-r--r--chrome/common/ipc_channel_proxy.h8
-rw-r--r--chrome/common/ipc_tests.cc18
5 files changed, 68 insertions, 4 deletions
diff --git a/chrome/chrome.xcodeproj/project.pbxproj b/chrome/chrome.xcodeproj/project.pbxproj
index 5302d98..34756e9 100644
--- a/chrome/chrome.xcodeproj/project.pbxproj
+++ b/chrome/chrome.xcodeproj/project.pbxproj
@@ -155,6 +155,7 @@
A54612E20EE995F600A8EE5D /* extensions_service.cc in Sources */ = {isa = PBXBuildFile; fileRef = A54612D90EE9957000A8EE5D /* extensions_service.cc */; };
B54BD8FC0ED622C00093FD54 /* mach_message_source_mac.cc in Sources */ = {isa = PBXBuildFile; fileRef = B54BD8FA0ED622C00093FD54 /* mach_message_source_mac.cc */; };
B562C8430ED49C830077A23F /* mach_ipc_mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = B562C8420ED49C830077A23F /* mach_ipc_mac.mm */; };
+ B5DBEA900EFC60E200C95176 /* ipc_channel_proxy.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BFBAB0E9D4C9F009A6919 /* ipc_channel_proxy.cc */; };
B5FDC0580EE488E500BEC6E6 /* ipc_channel_posix.cc in Sources */ = {isa = PBXBuildFile; fileRef = B5FDC0570EE488E500BEC6E6 /* ipc_channel_posix.cc */; };
B5FDC1CA0EE48ADB00BEC6E6 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D7BFDD10E9D5295009A6919 /* CoreFoundation.framework */; };
B5FDC1CC0EE48ADB00BEC6E6 /* libbase.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D7BFDC70E9D525B009A6919 /* libbase.a */; };
@@ -3239,6 +3240,7 @@
4D7BFC2E0E9D4CF5009A6919 /* debug_flags.cc in Sources */,
4D7BFC330E9D4CF9009A6919 /* env_vars.cc in Sources */,
B5FDC0580EE488E500BEC6E6 /* ipc_channel_posix.cc in Sources */,
+ B5DBEA900EFC60E200C95176 /* ipc_channel_proxy.cc in Sources */,
4D7BFC380E9D4CFF009A6919 /* ipc_message.cc in Sources */,
E4F3257D0EE83679002533CE /* ipc_message_utils.cc in Sources */,
4D7BFC580E9D4D0E009A6919 /* jpeg_codec.cc in Sources */,
diff --git a/chrome/common/common.scons b/chrome/common/common.scons
index 4ef1cef..5f5e919 100644
--- a/chrome/common/common.scons
+++ b/chrome/common/common.scons
@@ -41,6 +41,10 @@ if env.Bit('windows'):
input_files = []
+input_files.extend([
+ 'ipc_channel_proxy.cc',
+])
+
if not env.Bit('mac'):
# TODO(port): Port to Mac.
input_files.extend([
@@ -91,7 +95,6 @@ if env.Bit('windows'):
'gfx/icon_util.cc',
'gfx/path.cc',
'gfx/text_elider.cc',
- 'ipc_channel_proxy.cc',
'ipc_logging.cc',
'ipc_sync_channel.cc',
'ipc_sync_message.cc',
diff --git a/chrome/common/ipc_channel_proxy.cc b/chrome/common/ipc_channel_proxy.cc
index 23d8ea9..11fdb9b 100644
--- a/chrome/common/ipc_channel_proxy.cc
+++ b/chrome/common/ipc_channel_proxy.cc
@@ -5,11 +5,19 @@
#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,
@@ -216,6 +224,19 @@ void ChannelProxy::Init(const std::wstring& channel_id, Channel::Mode mode,
// to connect and get an error since the pipe doesn't exist yet.
context_->CreateChannel(channel_id, mode);
} else {
+#if defined(OS_POSIX)
+ // TODO(playmobil): On POSIX, IPC::Channel uses a socketpair(), one side of
+ // which needs to be mapped into the child process' address space.
+ // To know the value of the client side FD we need to have already
+ // created a socketpair which currently occurs in IPC::Channel's
+ // constructor.
+ // If we lazilly construct the IPC::Channel then the caller has no way
+ // of knowing the FD #.
+ //
+ // We can solve this either by having the Channel's creation launch the
+ // subprocess itself or by creating the socketpair() externally.
+ NOTIMPLEMENTED();
+#endif // defined(OS_POSIX)
context_->ipc_message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
context_.get(), &Context::CreateChannel, channel_id, mode));
}
@@ -260,6 +281,24 @@ void ChannelProxy::RemoveFilter(MessageFilter* filter) {
context_.get(), &Context::OnRemoveFilter, filter));
}
+#if defined(OS_POSIX)
+// See the TODO regarding lazy initialization of the channel in
+// ChannelProxy::Init().
+// We assume that IPC::Channel::GetClientFileDescriptorMapping() is thread-safe.
+void ChannelProxy::GetClientFileDescriptorMapping(int *src_fd, int *dest_fd) {
+ Channel *channel = context_.get()->channel_;
+ DCHECK(channel); // Channel must have been created first.
+ channel->GetClientFileDescriptorMapping(src_fd, dest_fd);
+}
+
+// We assume that IP::Channel::OnClientConnected() is thread-safe.
+void ChannelProxy::OnClientConnected() {
+ Channel *channel = context_.get()->channel_;
+ DCHECK(channel); // Channel must have been created first.
+ channel->OnClientConnected();
+}
+#endif
+
//-----------------------------------------------------------------------------
} // namespace IPC
diff --git a/chrome/common/ipc_channel_proxy.h b/chrome/common/ipc_channel_proxy.h
index 0b88cb7..667a64e 100644
--- a/chrome/common/ipc_channel_proxy.h
+++ b/chrome/common/ipc_channel_proxy.h
@@ -113,6 +113,14 @@ class ChannelProxy : public Message::Sender {
void AddFilter(MessageFilter* filter);
void RemoveFilter(MessageFilter* filter);
+#if defined(OS_POSIX)
+ // Calls through to the underlying channel's methods.
+ // TODO(playmobil): For now this is only implemented in the case of
+ // create_pipe_now = true, we need to figure this out for the latter case.
+ void GetClientFileDescriptorMapping(int *src_fd, int *dest_fd);
+ void OnClientConnected();
+#endif // defined(OS_POSIX)
+
protected:
class Context;
// A subclass uses this constructor if it needs to add more information
diff --git a/chrome/common/ipc_tests.cc b/chrome/common/ipc_tests.cc
index 971f16b..ffa7109 100644
--- a/chrome/common/ipc_tests.cc
+++ b/chrome/common/ipc_tests.cc
@@ -212,8 +212,6 @@ TEST_F(IPCChannelTest, ChannelTest) {
EXPECT_TRUE(base::WaitForSingleProcess(process_handle, 5000));
}
-// TODO(playmobil): Implement
-#if defined(OS_WIN)
TEST_F(IPCChannelTest, ChannelProxyTest) {
// The thread needs to out-live the ChannelProxy.
base::Thread thread("ChannelProxyTestServer");
@@ -227,10 +225,25 @@ TEST_F(IPCChannelTest, ChannelProxyTest) {
channel_listener.Init(&chan);
+#if defined(OS_WIN)
+ base::ProcessHandle process_handle = SpawnChild(TEST_CLIENT, NULL);
+#elif defined(OS_POSIX)
bool debug_on_start = CommandLine().HasSwitch(switches::kDebugChildren);
+ base::file_handle_mapping_vector fds_to_map;
+ int src_fd;
+ int dest_fd;
+ chan.GetClientFileDescriptorMapping(&src_fd, &dest_fd);
+ if (src_fd > -1) {
+ fds_to_map.push_back(std::pair<int,int>(src_fd, dest_fd));
+ }
+
base::ProcessHandle process_handle = MultiProcessTest::SpawnChild(
L"RunTestClient",
+ fds_to_map,
debug_on_start);
+ chan.OnClientConnected();
+#endif // defined(OS_POXIX)
+
ASSERT_TRUE(process_handle);
Send(&chan, "hello from parent");
@@ -243,7 +256,6 @@ TEST_F(IPCChannelTest, ChannelProxyTest) {
}
thread.Stop();
}
-#endif // defined(OS_WIN)
MULTIPROCESS_TEST_MAIN(RunTestClient) {
MessageLoopForIO main_message_loop;