summaryrefslogtreecommitdiffstats
path: root/ipc/ipc_channel_common.cc
diff options
context:
space:
mode:
authormorrita@chromium.org <morrita@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-29 20:30:17 +0000
committermorrita@chromium.org <morrita@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-29 20:30:17 +0000
commit3909aa922a9e3c966de47ba2dde76c3a11596b43 (patch)
treee31523ae6de47f6e5ba253760e931829d619e8cc /ipc/ipc_channel_common.cc
parent7deb50808af310b10d9eb25ae81aefff8a3c652f (diff)
downloadchromium_src-3909aa922a9e3c966de47ba2dde76c3a11596b43.zip
chromium_src-3909aa922a9e3c966de47ba2dde76c3a11596b43.tar.gz
chromium_src-3909aa922a9e3c966de47ba2dde76c3a11596b43.tar.bz2
Introduce IPC::Channel::Create*() to ensure it being heap-allocated.
This change introduces IPC::Channel::Create*() API to turn IPC::Channel into a heap allocated object. This will allow us to make Channel a polymorphic class. This change also tries to hide Channel::Mode from public API so that we can simplify channel creation code paths cleaner in following changes. ChannelProxy has to follow same pattern to finish this cleanup. Such changes will follow. TEST=none BUG=377980 R=darin@chromium.org,cpu@chromium.org Review URL: https://codereview.chromium.org/307653003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273575 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc/ipc_channel_common.cc')
-rw-r--r--ipc/ipc_channel_common.cc55
1 files changed, 55 insertions, 0 deletions
diff --git a/ipc/ipc_channel_common.cc b/ipc/ipc_channel_common.cc
new file mode 100644
index 0000000..c5ceba3e
--- /dev/null
+++ b/ipc/ipc_channel_common.cc
@@ -0,0 +1,55 @@
+// Copyright 2014 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_channel.h"
+
+namespace IPC {
+
+// static
+scoped_ptr<Channel> Channel::CreateByModeForProxy(
+ const IPC::ChannelHandle &channel_handle, Mode mode, Listener* listener) {
+ return make_scoped_ptr(
+ new Channel(channel_handle, mode, listener));
+}
+
+// static
+scoped_ptr<Channel> Channel::CreateClient(
+ const IPC::ChannelHandle &channel_handle, Listener* listener) {
+ return make_scoped_ptr(
+ new Channel(channel_handle, Channel::MODE_CLIENT, listener));
+}
+
+// static
+scoped_ptr<Channel> Channel::CreateNamedServer(
+ const IPC::ChannelHandle &channel_handle, Listener* listener) {
+ return make_scoped_ptr(
+ new Channel(channel_handle, Channel::MODE_NAMED_SERVER, listener));
+}
+
+// static
+scoped_ptr<Channel> Channel::CreateNamedClient(
+ const IPC::ChannelHandle &channel_handle, Listener* listener) {
+ return make_scoped_ptr(
+ new Channel(channel_handle, Channel::MODE_NAMED_CLIENT, listener));
+}
+
+#if defined(OS_POSIX)
+// static
+scoped_ptr<Channel> Channel::CreateOpenNamedServer(
+ const IPC::ChannelHandle &channel_handle, Listener* listener) {
+ return make_scoped_ptr(
+ new Channel(channel_handle, Channel::MODE_OPEN_NAMED_SERVER, listener));
+}
+#endif
+
+// static
+scoped_ptr<Channel> Channel::CreateServer(
+ const IPC::ChannelHandle &channel_handle, Listener* listener) {
+ return make_scoped_ptr(
+ new Channel(channel_handle, Channel::MODE_SERVER, listener));
+}
+
+
+} // namespace IPC
+