summaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-12 17:48:54 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-12 17:48:54 +0000
commit996e88a555b61046bfd3bb719042da05f6b68976 (patch)
treea5fdada9bb2ce14692fc862edb52d5a222ebebdc /ipc
parentdf24c66010e79acddad6e9b0d82a7ebc1285a2b0 (diff)
downloadchromium_src-996e88a555b61046bfd3bb719042da05f6b68976.zip
chromium_src-996e88a555b61046bfd3bb719042da05f6b68976.tar.gz
chromium_src-996e88a555b61046bfd3bb719042da05f6b68976.tar.bz2
FBTF: Remove all the easy headers from *_messages.h.
BUG=51411 TEST=compiles Review URL: http://codereview.chromium.org/3174002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55902 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc')
-rw-r--r--ipc/ipc_message_utils.cc109
-rw-r--r--ipc/ipc_message_utils.h108
-rw-r--r--ipc/ipc_send_fds_test.cc1
3 files changed, 127 insertions, 91 deletions
diff --git a/ipc/ipc_message_utils.cc b/ipc/ipc_message_utils.cc
index 7975faa..93f192ed 100644
--- a/ipc/ipc_message_utils.cc
+++ b/ipc/ipc_message_utils.cc
@@ -4,10 +4,16 @@
#include "ipc/ipc_message_utils.h"
+#include "base/file_path.h"
#include "base/json/json_writer.h"
+#include "base/nullable_string16.h"
#include "base/scoped_ptr.h"
#include "base/time.h"
#include "base/values.h"
+#if defined(OS_POSIX)
+#include "ipc/file_descriptor_set_posix.h"
+#endif
+#include "ipc/ipc_channel_handle.h"
namespace IPC {
@@ -256,4 +262,107 @@ void ParamTraits<ListValue>::Log(const param_type& p, std::wstring* l) {
base::JSONWriter::Write(&p, false, &json);
l->append(UTF8ToWide(json));
}
+
+void ParamTraits<NullableString16>::Write(Message* m, const param_type& p) {
+ WriteParam(m, p.string());
+ WriteParam(m, p.is_null());
+}
+
+bool ParamTraits<NullableString16>::Read(const Message* m, void** iter,
+ param_type* r) {
+ string16 string;
+ if (!ReadParam(m, iter, &string))
+ return false;
+ bool is_null;
+ if (!ReadParam(m, iter, &is_null))
+ return false;
+ *r = NullableString16(string, is_null);
+ return true;
+}
+
+void ParamTraits<NullableString16>::Log(const param_type& p, std::wstring* l) {
+ l->append(L"(");
+ LogParam(p.string(), l);
+ l->append(L", ");
+ LogParam(p.is_null(), l);
+ l->append(L")");
+}
+
+void ParamTraits<FilePath>::Write(Message* m, const param_type& p) {
+ ParamTraits<FilePath::StringType>::Write(m, p.value());
+}
+
+bool ParamTraits<FilePath>::Read(const Message* m, void** iter, param_type* r) {
+ FilePath::StringType value;
+ if (!ParamTraits<FilePath::StringType>::Read(m, iter, &value))
+ return false;
+ *r = FilePath(value);
+ return true;
+}
+
+void ParamTraits<FilePath>::Log(const param_type& p, std::wstring* l) {
+ ParamTraits<FilePath::StringType>::Log(p.value(), l);
+}
+
+#if defined(OS_POSIX)
+void ParamTraits<base::FileDescriptor>::Write(Message* m, const param_type& p) {
+ const bool valid = p.fd >= 0;
+ WriteParam(m, valid);
+
+ if (valid) {
+ if (!m->WriteFileDescriptor(p))
+ NOTREACHED();
+ }
+}
+
+bool ParamTraits<base::FileDescriptor>::Read(const Message* m, void** iter,
+ param_type* r) {
+ bool valid;
+ if (!ReadParam(m, iter, &valid))
+ return false;
+
+ if (!valid) {
+ r->fd = -1;
+ r->auto_close = false;
+ return true;
+ }
+
+ return m->ReadFileDescriptor(iter, r);
+}
+
+void ParamTraits<base::FileDescriptor>::Log(const param_type& p,
+ std::wstring* l) {
+ if (p.auto_close) {
+ l->append(StringPrintf(L"FD(%d auto-close)", p.fd));
+ } else {
+ l->append(StringPrintf(L"FD(%d)", p.fd));
+ }
+}
+#endif // defined(OS_POSIX)
+
+void ParamTraits<IPC::ChannelHandle>::Write(Message* m, const param_type& p) {
+ WriteParam(m, p.name);
+#if defined(OS_POSIX)
+ WriteParam(m, p.socket);
+#endif
+}
+
+bool ParamTraits<IPC::ChannelHandle>::Read(const Message* m, void** iter,
+ param_type* r) {
+ return ReadParam(m, iter, &r->name)
+#if defined(OS_POSIX)
+ && ReadParam(m, iter, &r->socket)
+#endif
+ ;
+}
+
+void ParamTraits<IPC::ChannelHandle>::Log(const param_type& p,
+ std::wstring* l) {
+ l->append(ASCIIToWide(StringPrintf("ChannelHandle(%s", p.name.c_str())));
+#if defined(OS_POSIX)
+ ParamTraits<base::FileDescriptor>::Log(p.socket, l);
+#endif
+ l->append(L")");
+}
+
} // namespace IPC
diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h
index 4882688..12eb02f 100644
--- a/ipc/ipc_message_utils.h
+++ b/ipc/ipc_message_utils.h
@@ -12,20 +12,12 @@
#include <map>
#include <set>
-#include "base/file_path.h"
#include "base/format_macros.h"
-#include "base/nullable_string16.h"
#include "base/string16.h"
#include "base/string_number_conversions.h"
#include "base/string_util.h"
-#include "base/utf_string_conversions.h"
#include "base/tuple.h"
#include "base/utf_string_conversions.h"
-#include "base/values.h"
-#if defined(OS_POSIX)
-#include "ipc/file_descriptor_set_posix.h"
-#endif
-#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
@@ -68,14 +60,19 @@ enum IPCMessageStart {
};
class DictionaryValue;
+class FilePath;
class ListValue;
+class NullableString16;
namespace base {
class Time;
+struct FileDescriptor;
}
namespace IPC {
+struct ChannelHandle;
+
//-----------------------------------------------------------------------------
// An iterator class for reading the fields contained within a Message.
@@ -598,27 +595,9 @@ struct ParamTraits<std::pair<A, B> > {
template <>
struct ParamTraits<NullableString16> {
typedef NullableString16 param_type;
- static void Write(Message* m, const param_type& p) {
- WriteParam(m, p.string());
- WriteParam(m, p.is_null());
- }
- static bool Read(const Message* m, void** iter, param_type* r) {
- string16 string;
- if (!ReadParam(m, iter, &string))
- return false;
- bool is_null;
- if (!ReadParam(m, iter, &is_null))
- return false;
- *r = NullableString16(string, is_null);
- return true;
- }
- static void Log(const param_type& p, std::wstring* l) {
- l->append(L"(");
- LogParam(p.string(), l);
- l->append(L", ");
- LogParam(p.is_null(), l);
- l->append(L")");
- }
+ 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 WCHAR_T_IS_UTF16 is defined, then string16 is a std::wstring so we don't
@@ -709,19 +688,9 @@ struct ParamTraits<POINT> {
template <>
struct ParamTraits<FilePath> {
typedef FilePath param_type;
- static void Write(Message* m, const param_type& p) {
- ParamTraits<FilePath::StringType>::Write(m, p.value());
- }
- static bool Read(const Message* m, void** iter, param_type* r) {
- FilePath::StringType value;
- if (!ParamTraits<FilePath::StringType>::Read(m, iter, &value))
- return false;
- *r = FilePath(value);
- return true;
- }
- static void Log(const param_type& p, std::wstring* l) {
- ParamTraits<FilePath::StringType>::Log(p.value(), l);
- }
+ 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_POSIX)
@@ -743,35 +712,9 @@ struct ParamTraits<FilePath> {
template<>
struct ParamTraits<base::FileDescriptor> {
typedef base::FileDescriptor param_type;
- static void Write(Message* m, const param_type& p) {
- const bool valid = p.fd >= 0;
- WriteParam(m, valid);
-
- if (valid) {
- if (!m->WriteFileDescriptor(p))
- NOTREACHED();
- }
- }
- static bool Read(const Message* m, void** iter, param_type* r) {
- bool valid;
- if (!ReadParam(m, iter, &valid))
- return false;
-
- if (!valid) {
- r->fd = -1;
- r->auto_close = false;
- return true;
- }
-
- return m->ReadFileDescriptor(iter, r);
- }
- static void Log(const param_type& p, std::wstring* l) {
- if (p.auto_close) {
- l->append(StringPrintf(L"FD(%d auto-close)", p.fd));
- } else {
- l->append(StringPrintf(L"FD(%d)", p.fd));
- }
- }
+ 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);
};
#endif // defined(OS_POSIX)
@@ -781,26 +724,9 @@ struct ParamTraits<base::FileDescriptor> {
template<>
struct ParamTraits<IPC::ChannelHandle> {
typedef ChannelHandle param_type;
- static void Write(Message* m, const param_type& p) {
- WriteParam(m, p.name);
-#if defined(OS_POSIX)
- WriteParam(m, p.socket);
-#endif
- }
- static bool Read(const Message* m, void** iter, param_type* r) {
- return ReadParam(m, iter, &r->name)
-#if defined(OS_POSIX)
- && ReadParam(m, iter, &r->socket)
-#endif
- ;
- }
- static void Log(const param_type& p, std::wstring* l) {
- l->append(ASCIIToWide(StringPrintf("ChannelHandle(%s", p.name.c_str())));
-#if defined(OS_POSIX)
- ParamTraits<base::FileDescriptor>::Log(p.socket, l);
-#endif
- l->append(L")");
- }
+ 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)
diff --git a/ipc/ipc_send_fds_test.cc b/ipc/ipc_send_fds_test.cc
index 5f399da..f6d315f 100644
--- a/ipc/ipc_send_fds_test.cc
+++ b/ipc/ipc_send_fds_test.cc
@@ -20,6 +20,7 @@ extern "C" {
#include "ipc/ipc_message_utils.h"
#if defined(OS_POSIX)
+#include "base/file_descriptor_posix.h"
namespace {