diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-18 18:33:57 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-18 18:33:57 +0000 |
commit | 252cad6dec04039d456e716273153951d0090b5f (patch) | |
tree | 68437c27571fe3e88317f1f2848573fe647fdbb5 /ipc/ipc_message_utils.h | |
parent | 371390a71a7e4530b39e46f1f52c5a6d5a3acd43 (diff) | |
download | chromium_src-252cad6dec04039d456e716273153951d0090b5f.zip chromium_src-252cad6dec04039d456e716273153951d0090b5f.tar.gz chromium_src-252cad6dec04039d456e716273153951d0090b5f.tar.bz2 |
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
Diffstat (limited to 'ipc/ipc_message_utils.h')
-rw-r--r-- | ipc/ipc_message_utils.h | 178 |
1 files changed, 80 insertions, 98 deletions
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 <class P> -static inline void LogParam(const P& p, std::wstring* l) { +static inline void LogParam(const P& p, std::string* l) { typedef typename SimilarTypeTraits<P>::Type Type; ParamTraits<Type>::Log(static_cast<const Type& >(p), l); } @@ -162,8 +160,8 @@ struct ParamTraits<bool> { 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<int> { 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<unsigned int> { static bool Read(const Message* m, void** iter, param_type* r) { return m->ReadInt(iter, reinterpret_cast<int*>(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<long> { 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<unsigned long> { static bool Read(const Message* m, void** iter, param_type* r) { return m->ReadLong(iter, reinterpret_cast<long*>(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<long long> { static bool Read(const Message* m, void** iter, param_type* r) { return m->ReadInt64(iter, reinterpret_cast<int64*>(r)); } - static void Log(const param_type& p, std::wstring* l) { - l->append(UTF8ToWide(base::Int64ToString(static_cast<int64>(p)))); - } + static void Log(const param_type& p, std::string* l); }; template <> @@ -246,9 +234,7 @@ struct ParamTraits<unsigned long long> { static bool Read(const Message* m, void** iter, param_type* r) { return m->ReadInt64(iter, reinterpret_cast<int64*>(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<float> { 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<double> { 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<wchar_t> { 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<base::Time> { 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<LOGFONT> { return result; } - static void Log(const param_type& p, std::wstring* l) { - l->append(StringPrintf(L"<LOGFONT>")); + static void Log(const param_type& p, std::string* l) { + l->append(StringPrintf("<LOGFONT>")); } }; @@ -374,8 +360,8 @@ struct ParamTraits<MSG> { return result; } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"<MSG>"); + static void Log(const param_type& p, std::string* l) { + l->append("<MSG>"); } }; #endif // defined(OS_WIN) @@ -385,7 +371,7 @@ struct ParamTraits<DictionaryValue> { 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<ListValue> { 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<std::string> { 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<typename CharType> -static void LogBytes(const std::vector<CharType>& data, std::wstring* out) { +static void LogBytes(const std::vector<CharType>& 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<CharType>& data, std::wstring* out) { if (isprint(data[i])) out->push_back(data[i]); else - out->append(StringPrintf(L"[%02X]", static_cast<unsigned char>(data[i]))); + out->append(StringPrintf("[%02X]", static_cast<unsigned char>(data[i]))); } if (data.size() > kMaxBytesToLog) { out->append( - StringPrintf(L" and %u more bytes", + StringPrintf(" and %u more bytes", static_cast<unsigned>(data.size() - kMaxBytesToLog))); } #endif @@ -454,7 +440,7 @@ struct ParamTraits<std::vector<unsigned char> > { 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<std::vector<char> > { 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<std::vector<P> > { } 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<std::set<P> > { } return true; } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"<std::set>"); + static void Log(const param_type& p, std::string* l) { + l->append("<std::set>"); } }; @@ -568,8 +554,8 @@ struct ParamTraits<std::map<K, V> > { } return true; } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"<std::map>"); + static void Log(const param_type& p, std::string* l) { + l->append("<std::map>"); } }; @@ -583,9 +569,7 @@ struct ParamTraits<std::wstring> { 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 <class A, class B> @@ -598,12 +582,12 @@ struct ParamTraits<std::pair<A, B> > { 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<NullableString16> { 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<string16> { 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<HANDLE> { DCHECK_EQ(sizeof(param_type), sizeof(uint32)); return m->ReadUInt32(iter, reinterpret_cast<uint32*>(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<HCURSOR> { DCHECK_EQ(sizeof(param_type), sizeof(uint32)); return m->ReadUInt32(iter, reinterpret_cast<uint32*>(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<POINT> { 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<FilePath> { 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<base::FileDescriptor> { 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<IPC::ChannelHandle> { 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<XFORM> { return result; } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"<XFORM>"); + static void Log(const param_type& p, std::string* l) { + l->append("<XFORM>"); } }; #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<LogData> { r->type = static_cast<uint16>(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<Message> { *r = Message(data, size); return true; } - static void Log(const Message& p, std::wstring* l) { - l->append(L"<IPC::Message>"); + static void Log(const Message& p, std::string* l) { + l->append("<IPC::Message>"); } }; @@ -845,7 +827,7 @@ struct ParamTraits<Tuple0> { 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<A> > { 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<A, B> > { 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<A, B, C> > { 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<A, B, C, D> > { 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<A, B, C, D, E> > { 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 <class ReplyParamType> 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 <class ReplyParamType> inline void LogReplyParamsToMessage(const ReplyParamType& reply_params, |