From 252cad6dec04039d456e716273153951d0090b5f Mon Sep 17 00:00:00 2001 From: "erg@google.com" Date: Wed, 18 Aug 2010 18:33:57 +0000 Subject: Remove all wstrings from the IPC logging subsystem. Changes all IPC Log methods from wstring to string. All static logging debug data changed from wchar[] to char[]. Various string conversion/numeric headers no longer need to be included in ipc_message_utils.h and have been removed (and added in all implementation files that require them). BUG=none TEST=none Review URL: http://codereview.chromium.org/3159013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56563 0039d316-1c4b-4281-b951-d872f2087c98 --- ipc/ipc_message_utils.h | 178 ++++++++++++++++++++++-------------------------- 1 file changed, 80 insertions(+), 98 deletions(-) (limited to 'ipc/ipc_message_utils.h') diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h index 05d3916..c3a9ca4 100644 --- a/ipc/ipc_message_utils.h +++ b/ipc/ipc_message_utils.h @@ -14,10 +14,8 @@ #include "base/format_macros.h" #include "base/string16.h" -#include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/tuple.h" -#include "base/utf_string_conversions.h" #include "ipc/ipc_sync_message.h" #if defined(COMPILER_GCC) @@ -148,7 +146,7 @@ static inline bool WARN_UNUSED_RESULT ReadParam(const Message* m, void** iter, } template -static inline void LogParam(const P& p, std::wstring* l) { +static inline void LogParam(const P& p, std::string* l) { typedef typename SimilarTypeTraits

::Type Type; ParamTraits::Log(static_cast(p), l); } @@ -162,8 +160,8 @@ struct ParamTraits { static bool Read(const Message* m, void** iter, param_type* r) { return m->ReadBool(iter, r); } - static void Log(const param_type& p, std::wstring* l) { - l->append(p ? L"true" : L"false"); + static void Log(const param_type& p, std::string* l) { + l->append(p ? "true" : "false"); } }; @@ -176,9 +174,7 @@ struct ParamTraits { static bool Read(const Message* m, void** iter, param_type* r) { return m->ReadInt(iter, r); } - static void Log(const param_type& p, std::wstring* l) { - l->append(StringPrintf(L"%d", p)); - } + static void Log(const param_type& p, std::string* l); }; template <> @@ -190,9 +186,7 @@ struct ParamTraits { static bool Read(const Message* m, void** iter, param_type* r) { return m->ReadInt(iter, reinterpret_cast(r)); } - static void Log(const param_type& p, std::wstring* l) { - l->append(StringPrintf(L"%d", p)); - } + static void Log(const param_type& p, std::string* l); }; template <> @@ -204,9 +198,7 @@ struct ParamTraits { static bool Read(const Message* m, void** iter, param_type* r) { return m->ReadLong(iter, r); } - static void Log(const param_type& p, std::wstring* l) { - l->append(StringPrintf(L"%ld", p)); - } + static void Log(const param_type& p, std::string* l); }; template <> @@ -218,9 +210,7 @@ struct ParamTraits { static bool Read(const Message* m, void** iter, param_type* r) { return m->ReadLong(iter, reinterpret_cast(r)); } - static void Log(const param_type& p, std::wstring* l) { - l->append(StringPrintf(L"%lu", p)); - } + static void Log(const param_type& p, std::string* l); }; template <> @@ -232,9 +222,7 @@ struct ParamTraits { static bool Read(const Message* m, void** iter, param_type* r) { return m->ReadInt64(iter, reinterpret_cast(r)); } - static void Log(const param_type& p, std::wstring* l) { - l->append(UTF8ToWide(base::Int64ToString(static_cast(p)))); - } + static void Log(const param_type& p, std::string* l); }; template <> @@ -246,9 +234,7 @@ struct ParamTraits { static bool Read(const Message* m, void** iter, param_type* r) { return m->ReadInt64(iter, reinterpret_cast(r)); } - static void Log(const param_type& p, std::wstring* l) { - l->append(UTF8ToWide(base::Uint64ToString(p))); - } + static void Log(const param_type& p, std::string* l); }; // Note that the IPC layer doesn't sanitize NaNs and +/- INF values. Clients @@ -271,8 +257,8 @@ struct ParamTraits { memcpy(r, data, sizeof(param_type)); return true; } - static void Log(const param_type& p, std::wstring* l) { - l->append(StringPrintf(L"e", p)); + static void Log(const param_type& p, std::string* l) { + l->append(StringPrintf("%e", p)); } }; @@ -293,8 +279,8 @@ struct ParamTraits { memcpy(r, data, sizeof(param_type)); return true; } - static void Log(const param_type& p, std::wstring* l) { - l->append(StringPrintf(L"e", p)); + static void Log(const param_type& p, std::string* l) { + l->append(StringPrintf("%e", p)); } }; @@ -317,8 +303,8 @@ struct ParamTraits { return result; } - static void Log(const param_type& p, std::wstring* l) { - l->append(StringPrintf(L"%lc", p)); + static void Log(const param_type& p, std::string* l) { + l->append(StringPrintf("%lc", p)); } }; @@ -327,7 +313,7 @@ struct ParamTraits { typedef base::Time 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); + static void Log(const param_type& p, std::string* l); }; #if defined(OS_WIN) @@ -350,8 +336,8 @@ struct ParamTraits { return result; } - static void Log(const param_type& p, std::wstring* l) { - l->append(StringPrintf(L"")); + static void Log(const param_type& p, std::string* l) { + l->append(StringPrintf("")); } }; @@ -374,8 +360,8 @@ struct ParamTraits { return result; } - static void Log(const param_type& p, std::wstring* l) { - l->append(L""); + static void Log(const param_type& p, std::string* l) { + l->append(""); } }; #endif // defined(OS_WIN) @@ -385,7 +371,7 @@ struct ParamTraits { typedef DictionaryValue 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); + static void Log(const param_type& p, std::string* l); }; template <> @@ -393,7 +379,7 @@ struct ParamTraits { typedef ListValue 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); + static void Log(const param_type& p, std::string* l); }; template <> @@ -405,13 +391,13 @@ struct ParamTraits { static bool Read(const Message* m, void** iter, param_type* r) { return m->ReadString(iter, r); } - static void Log(const param_type& p, std::wstring* l) { - l->append(UTF8ToWide(p)); + static void Log(const param_type& p, std::string* l) { + l->append(p); } }; template -static void LogBytes(const std::vector& data, std::wstring* out) { +static void LogBytes(const std::vector& data, std::string* out) { #if defined(OS_WIN) // Windows has a GUI for logging, which can handle arbitrary binary data. for (size_t i = 0; i < data.size(); ++i) @@ -423,11 +409,11 @@ static void LogBytes(const std::vector& data, std::wstring* out) { if (isprint(data[i])) out->push_back(data[i]); else - out->append(StringPrintf(L"[%02X]", static_cast(data[i]))); + out->append(StringPrintf("[%02X]", static_cast(data[i]))); } if (data.size() > kMaxBytesToLog) { out->append( - StringPrintf(L" and %u more bytes", + StringPrintf(" and %u more bytes", static_cast(data.size() - kMaxBytesToLog))); } #endif @@ -454,7 +440,7 @@ struct ParamTraits > { memcpy(&r->front(), data, data_size); return true; } - static void Log(const param_type& p, std::wstring* l) { + static void Log(const param_type& p, std::string* l) { LogBytes(p, l); } }; @@ -479,7 +465,7 @@ struct ParamTraits > { memcpy(&r->front(), data, data_size); return true; } - static void Log(const param_type& p, std::wstring* l) { + static void Log(const param_type& p, std::string* l) { LogBytes(p, l); } }; @@ -507,10 +493,10 @@ struct ParamTraits > { } return true; } - static void Log(const param_type& p, std::wstring* l) { + static void Log(const param_type& p, std::string* l) { for (size_t i = 0; i < p.size(); ++i) { if (i != 0) - l->append(L" "); + l->append(" "); LogParam((p[i]), l); } } @@ -537,8 +523,8 @@ struct ParamTraits > { } return true; } - static void Log(const param_type& p, std::wstring* l) { - l->append(L""); + static void Log(const param_type& p, std::string* l) { + l->append(""); } }; @@ -568,8 +554,8 @@ struct ParamTraits > { } return true; } - static void Log(const param_type& p, std::wstring* l) { - l->append(L""); + static void Log(const param_type& p, std::string* l) { + l->append(""); } }; @@ -583,9 +569,7 @@ struct ParamTraits { static bool Read(const Message* m, void** iter, param_type* r) { return m->ReadWString(iter, r); } - static void Log(const param_type& p, std::wstring* l) { - l->append(p); - } + static void Log(const param_type& p, std::string* l); }; template @@ -598,12 +582,12 @@ struct ParamTraits > { static bool Read(const Message* m, void** iter, param_type* r) { return ReadParam(m, iter, &r->first) && ReadParam(m, iter, &r->second); } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"("); + static void Log(const param_type& p, std::string* l) { + l->append("("); LogParam(p.first, l); - l->append(L", "); + l->append(", "); LogParam(p.second, l); - l->append(L")"); + l->append(")"); } }; @@ -612,7 +596,7 @@ struct ParamTraits { typedef NullableString16 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); + static void Log(const param_type& p, std::string* l); }; // If WCHAR_T_IS_UTF16 is defined, then string16 is a std::wstring so we don't @@ -627,9 +611,7 @@ struct ParamTraits { static bool Read(const Message* m, void** iter, param_type* r) { return m->ReadString16(iter, r); } - static void Log(const param_type& p, std::wstring* l) { - l->append(UTF16ToWide(p)); - } + static void Log(const param_type& p, std::string* l); }; #endif @@ -647,8 +629,8 @@ struct ParamTraits { DCHECK_EQ(sizeof(param_type), sizeof(uint32)); return m->ReadUInt32(iter, reinterpret_cast(r)); } - static void Log(const param_type& p, std::wstring* l) { - l->append(StringPrintf(L"0x%X", p)); + static void Log(const param_type& p, std::string* l) { + l->append(StringPrintf("0x%X", p)); } }; @@ -662,8 +644,8 @@ struct ParamTraits { DCHECK_EQ(sizeof(param_type), sizeof(uint32)); return m->ReadUInt32(iter, reinterpret_cast(r)); } - static void Log(const param_type& p, std::wstring* l) { - l->append(StringPrintf(L"0x%X", p)); + static void Log(const param_type& p, std::string* l) { + l->append(StringPrintf("0x%X", p)); } }; @@ -694,8 +676,8 @@ struct ParamTraits { r->y = y; return true; } - static void Log(const param_type& p, std::wstring* l) { - l->append(StringPrintf(L"(%d, %d)", p.x, p.y)); + static void Log(const param_type& p, std::string* l) { + l->append(StringPrintf("(%d, %d)", p.x, p.y)); } }; #endif // defined(OS_WIN) @@ -705,7 +687,7 @@ struct ParamTraits { typedef FilePath 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); + static void Log(const param_type& p, std::string* l); }; #if defined(OS_POSIX) @@ -729,7 +711,7 @@ struct ParamTraits { typedef base::FileDescriptor 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); + static void Log(const param_type& p, std::string* l); }; #endif // defined(OS_POSIX) @@ -741,7 +723,7 @@ struct ParamTraits { typedef ChannelHandle 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); + static void Log(const param_type& p, std::string* l); }; #if defined(OS_WIN) @@ -764,8 +746,8 @@ struct ParamTraits { return result; } - static void Log(const param_type& p, std::wstring* l) { - l->append(L""); + static void Log(const param_type& p, std::string* l) { + l->append(""); } }; #endif // defined(OS_WIN) @@ -774,14 +756,14 @@ struct LogData { std::string channel; int32 routing_id; uint32 type; // "User-defined" message type, from ipc_message.h. - std::wstring flags; + std::string flags; int64 sent; // Time that the message was sent (i.e. at Send()). int64 receive; // Time before it was dispatched (i.e. before calling // OnMessageReceived). int64 dispatch; // Time after it was dispatched (i.e. after calling // OnMessageReceived). - std::wstring message_name; - std::wstring params; + std::string message_name; + std::string params; }; template <> @@ -811,7 +793,7 @@ struct ParamTraits { r->type = static_cast(type); return result; } - static void Log(const param_type& p, std::wstring* l) { + static void Log(const param_type& p, std::string* l) { // Doesn't make sense to implement this! } }; @@ -832,8 +814,8 @@ struct ParamTraits { *r = Message(data, size); return true; } - static void Log(const Message& p, std::wstring* l) { - l->append(L""); + static void Log(const Message& p, std::string* l) { + l->append(""); } }; @@ -845,7 +827,7 @@ struct ParamTraits { static bool Read(const Message* m, void** iter, param_type* r) { return true; } - static void Log(const param_type& p, std::wstring* l) { + static void Log(const param_type& p, std::string* l) { } }; @@ -858,7 +840,7 @@ struct ParamTraits< Tuple1 > { static bool Read(const Message* m, void** iter, param_type* r) { return ReadParam(m, iter, &r->a); } - static void Log(const param_type& p, std::wstring* l) { + static void Log(const param_type& p, std::string* l) { LogParam(p.a, l); } }; @@ -874,9 +856,9 @@ struct ParamTraits< Tuple2 > { return (ReadParam(m, iter, &r->a) && ReadParam(m, iter, &r->b)); } - static void Log(const param_type& p, std::wstring* l) { + static void Log(const param_type& p, std::string* l) { LogParam(p.a, l); - l->append(L", "); + l->append(", "); LogParam(p.b, l); } }; @@ -894,11 +876,11 @@ struct ParamTraits< Tuple3 > { ReadParam(m, iter, &r->b) && ReadParam(m, iter, &r->c)); } - static void Log(const param_type& p, std::wstring* l) { + static void Log(const param_type& p, std::string* l) { LogParam(p.a, l); - l->append(L", "); + l->append(", "); LogParam(p.b, l); - l->append(L", "); + l->append(", "); LogParam(p.c, l); } }; @@ -918,13 +900,13 @@ struct ParamTraits< Tuple4 > { ReadParam(m, iter, &r->c) && ReadParam(m, iter, &r->d)); } - static void Log(const param_type& p, std::wstring* l) { + static void Log(const param_type& p, std::string* l) { LogParam(p.a, l); - l->append(L", "); + l->append(", "); LogParam(p.b, l); - l->append(L", "); + l->append(", "); LogParam(p.c, l); - l->append(L", "); + l->append(", "); LogParam(p.d, l); } }; @@ -946,15 +928,15 @@ struct ParamTraits< Tuple5 > { ReadParam(m, iter, &r->d) && ReadParam(m, iter, &r->e)); } - static void Log(const param_type& p, std::wstring* l) { + static void Log(const param_type& p, std::string* l) { LogParam(p.a, l); - l->append(L", "); + l->append(", "); LogParam(p.b, l); - l->append(L", "); + l->append(", "); LogParam(p.c, l); - l->append(L", "); + l->append(", "); LogParam(p.d, l); - l->append(L", "); + l->append(", "); LogParam(p.e, l); } }; @@ -1102,10 +1084,10 @@ void GenerateLogData(const std::string& channel, const Message& message, #if defined(IPC_MESSAGE_LOG_ENABLED) -inline void AddOutputParamsToLog(const Message* msg, std::wstring* l) { - const std::wstring& output_params = msg->output_params(); +inline void AddOutputParamsToLog(const Message* msg, std::string* l) { + const std::string& output_params = msg->output_params(); if (!l->empty() && !output_params.empty()) - l->append(L", "); + l->append(", "); l->append(output_params); } @@ -1114,7 +1096,7 @@ template inline void LogReplyParamsToMessage(const ReplyParamType& reply_params, const Message* msg) { if (msg->received_time() != 0) { - std::wstring output_params; + std::string output_params; LogParam(reply_params, &output_params); msg->set_output_params(output_params); } @@ -1132,7 +1114,7 @@ inline void ConnectMessageAndReply(const Message* msg, Message* reply) { } } #else -inline void AddOutputParamsToLog(const Message* msg, std::wstring* l) {} +inline void AddOutputParamsToLog(const Message* msg, std::string* l) {} template inline void LogReplyParamsToMessage(const ReplyParamType& reply_params, -- cgit v1.1