diff options
author | tzik <tzik@chromium.org> | 2016-03-07 21:47:44 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-08 05:50:35 +0000 |
commit | 55e3e4d3c52bf99bd8a710e55b1dcccea5e3acc6 (patch) | |
tree | 6e1839d069b5e7b70951f0852891402a0730055d /ipc | |
parent | ae1c7e7f600035bfb918ba8f217e9e0e5b505702 (diff) | |
download | chromium_src-55e3e4d3c52bf99bd8a710e55b1dcccea5e3acc6.zip chromium_src-55e3e4d3c52bf99bd8a710e55b1dcccea5e3acc6.tar.gz chromium_src-55e3e4d3c52bf99bd8a710e55b1dcccea5e3acc6.tar.bz2 |
Replace base::Tuple in //ipc with std::tuple
BUG=554987
Review URL: https://codereview.chromium.org/1770013002
Cr-Commit-Position: refs/heads/master@{#379759}
Diffstat (limited to 'ipc')
-rw-r--r-- | ipc/attachment_broker_mac_unittest.cc | 16 | ||||
-rw-r--r-- | ipc/attachment_broker_privileged_mac.cc | 4 | ||||
-rw-r--r-- | ipc/attachment_broker_privileged_win.cc | 4 | ||||
-rw-r--r-- | ipc/attachment_broker_privileged_win_unittest.cc | 10 | ||||
-rw-r--r-- | ipc/ipc_message_macros.h | 5 | ||||
-rw-r--r-- | ipc/ipc_message_templates.h | 17 | ||||
-rw-r--r-- | ipc/ipc_message_templates_impl.h | 32 | ||||
-rw-r--r-- | ipc/ipc_message_utils.h | 122 |
8 files changed, 111 insertions, 99 deletions
diff --git a/ipc/attachment_broker_mac_unittest.cc b/ipc/attachment_broker_mac_unittest.cc index 9736c02..9442324 100644 --- a/ipc/attachment_broker_mac_unittest.cc +++ b/ipc/attachment_broker_mac_unittest.cc @@ -9,6 +9,8 @@ #include <stddef.h> #include <sys/mman.h> +#include <tuple> + #include "base/command_line.h" #include "base/files/file_util.h" #include "base/files/scoped_file.h" @@ -111,7 +113,7 @@ base::SharedMemoryHandle GetSharedMemoryHandleFromMsg1( return base::SharedMemoryHandle(); } - return base::get<1>(p); + return std::get<1>(p); } // |message| must be deserializable as a TestSharedMemoryHandleMsg2. Returns @@ -132,8 +134,8 @@ bool GetSharedMemoryHandlesFromMsg2(const IPC::Message& message, return false; } - *handle1 = base::get<0>(p); - *handle2 = base::get<1>(p); + *handle1 = std::get<0>(p); + *handle2 = std::get<1>(p); return true; } @@ -868,16 +870,16 @@ void SendPosixFDAndMachPortCallback(IPC::Sender* sender, return; } - base::SharedMemoryHandle handle1 = base::get<1>(p); - base::SharedMemoryHandle handle2 = base::get<3>(p); + base::SharedMemoryHandle handle1 = std::get<1>(p); + base::SharedMemoryHandle handle2 = std::get<3>(p); bool success1 = CheckContentsOfSharedMemoryHandle(handle1, kDataBuffer1) && CheckContentsOfSharedMemoryHandle(handle2, kDataBuffer2); if (!success1) LOG(ERROR) << "SharedMemoryHandles have wrong contents."; bool success2 = - CheckContentsOfFileDescriptor(base::get<0>(p), kDataBuffer3) && - CheckContentsOfFileDescriptor(base::get<2>(p), kDataBuffer4); + CheckContentsOfFileDescriptor(std::get<0>(p), kDataBuffer3) && + CheckContentsOfFileDescriptor(std::get<2>(p), kDataBuffer4); if (!success2) LOG(ERROR) << "FileDescriptors have wrong contents."; diff --git a/ipc/attachment_broker_privileged_mac.cc b/ipc/attachment_broker_privileged_mac.cc index c5bed27..725085b 100644 --- a/ipc/attachment_broker_privileged_mac.cc +++ b/ipc/attachment_broker_privileged_mac.cc @@ -6,6 +6,8 @@ #include <stdint.h> +#include <tuple> + #include "base/mac/scoped_mach_port.h" #include "base/memory/shared_memory.h" #include "base/process/port_provider_mac.h" @@ -183,7 +185,7 @@ void AttachmentBrokerPrivilegedMac::OnDuplicateMachPort( return; } IPC::internal::MachPortAttachmentMac::WireFormat wire_format = - base::get<0>(param); + std::get<0>(param); if (wire_format.destination_process == base::kNullProcessId) { LogError(NO_DESTINATION); diff --git a/ipc/attachment_broker_privileged_win.cc b/ipc/attachment_broker_privileged_win.cc index c749a09..3ce3ec5 100644 --- a/ipc/attachment_broker_privileged_win.cc +++ b/ipc/attachment_broker_privileged_win.cc @@ -6,6 +6,8 @@ #include <windows.h> +#include <tuple> + #include "base/process/process.h" #include "ipc/attachment_broker_messages.h" #include "ipc/brokerable_attachment.h" @@ -59,7 +61,7 @@ void AttachmentBrokerPrivilegedWin::OnDuplicateWinHandle( if (!AttachmentBrokerMsg_DuplicateWinHandle::Read(&message, ¶m)) return; IPC::internal::HandleAttachmentWin::WireFormat wire_format = - base::get<0>(param); + std::get<0>(param); if (wire_format.destination_process == base::kNullProcessId) { LogError(NO_DESTINATION); diff --git a/ipc/attachment_broker_privileged_win_unittest.cc b/ipc/attachment_broker_privileged_win_unittest.cc index 870e262..9f720c8 100644 --- a/ipc/attachment_broker_privileged_win_unittest.cc +++ b/ipc/attachment_broker_privileged_win_unittest.cc @@ -6,6 +6,8 @@ #include <windows.h> +#include <tuple> + #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" @@ -76,7 +78,7 @@ ScopedHandle GetHandleFromTestHandleWinMsg(const IPC::Message& message) { return ScopedHandle(nullptr); } - IPC::HandleWin handle_win = base::get<1>(p); + IPC::HandleWin handle_win = std::get<1>(p); return ScopedHandle(handle_win.get_handle()); } @@ -97,7 +99,7 @@ scoped_ptr<base::SharedMemory> GetSharedMemoryFromSharedMemoryHandleMsg1( return nullptr; } - base::SharedMemoryHandle handle = base::get<0>(p); + base::SharedMemoryHandle handle = std::get<0>(p); scoped_ptr<base::SharedMemory> shared_memory( new base::SharedMemory(handle, false)); @@ -123,9 +125,9 @@ bool GetHandleFromTestTwoHandleWinMsg(const IPC::Message& message, return false; } - IPC::HandleWin handle_win = base::get<0>(p); + IPC::HandleWin handle_win = std::get<0>(p); *h1 = handle_win.get_handle(); - handle_win = base::get<1>(p); + handle_win = std::get<1>(p); *h2 = handle_win.get_handle(); return true; } diff --git a/ipc/ipc_message_macros.h b/ipc/ipc_message_macros.h index 6126b59..ea28d0c 100644 --- a/ipc/ipc_message_macros.h +++ b/ipc/ipc_message_macros.h @@ -201,8 +201,9 @@ #include <stdint.h> +#include <tuple> + #include "base/profiler/scoped_profile.h" -#include "base/tuple.h" #include "ipc/export_template.h" #include "ipc/ipc_message_templates.h" #include "ipc/ipc_message_utils.h" @@ -248,7 +249,7 @@ #define IPC_SYNC_MESSAGE_ROUTED(msg_class, in, out) \ IPC_MESSAGE_DECL(msg_class, ROUTED, IPC_TUPLE in, IPC_TUPLE out) -#define IPC_TUPLE(...) base::Tuple<__VA_ARGS__> +#define IPC_TUPLE(...) std::tuple<__VA_ARGS__> #define IPC_MESSAGE_DECL(msg_name, kind, in_tuple, out_tuple) \ struct IPC_MESSAGE_EXPORT msg_name##_Meta { \ diff --git a/ipc/ipc_message_templates.h b/ipc/ipc_message_templates.h index 17dfc1b..ac627dd 100644 --- a/ipc/ipc_message_templates.h +++ b/ipc/ipc_message_templates.h @@ -7,6 +7,7 @@ #include <stdint.h> +#include <tuple> #include <type_traits> #include "base/logging.h" @@ -35,7 +36,7 @@ void DispatchToMethodImpl(ObjT* obj, const Tuple& tuple, base::IndexSequence<Ns...>) { // TODO(mdempsky): Apply UnwrapTraits like base::DispatchToMethod? - (obj->*method)(parameter, base::get<Ns>(tuple)...); + (obj->*method)(parameter, std::get<Ns>(tuple)...); } // The following function is for async IPCs which have a dispatcher with an @@ -45,7 +46,7 @@ typename std::enable_if<sizeof...(Args) == sizeof...(Ts)>::type DispatchToMethod(ObjT* obj, void (ObjT::*method)(P*, Args...), P* parameter, - const base::Tuple<Ts...>& tuple) { + const std::tuple<Ts...>& tuple) { DispatchToMethodImpl(obj, method, parameter, tuple, base::MakeIndexSequence<sizeof...(Ts)>()); } @@ -84,9 +85,9 @@ class MessageT; // Asynchronous message partial specialization. template <typename Meta, typename... Ins> -class MessageT<Meta, base::Tuple<Ins...>, void> : public Message { +class MessageT<Meta, std::tuple<Ins...>, void> : public Message { public: - using Param = base::Tuple<Ins...>; + using Param = std::tuple<Ins...>; enum { ID = Meta::ID }; // TODO(mdempsky): Remove. Uses of MyMessage::Schema::Param can be replaced @@ -127,11 +128,11 @@ class MessageT<Meta, base::Tuple<Ins...>, void> : public Message { // Synchronous message partial specialization. template <typename Meta, typename... Ins, typename... Outs> -class MessageT<Meta, base::Tuple<Ins...>, base::Tuple<Outs...>> +class MessageT<Meta, std::tuple<Ins...>, std::tuple<Outs...>> : public SyncMessage { public: - using SendParam = base::Tuple<Ins...>; - using ReplyParam = base::Tuple<Outs...>; + using SendParam = std::tuple<Ins...>; + using ReplyParam = std::tuple<Outs...>; enum { ID = Meta::ID }; // TODO(mdempsky): Remove. Uses of MyMessage::Schema::{Send,Reply}Param can @@ -186,7 +187,7 @@ class MessageT<Meta, base::Tuple<Ins...>, base::Tuple<Outs...>> bool ok = ReadSendParam(msg, &send_params); Message* reply = SyncMessage::GenerateReply(msg); if (ok) { - base::Tuple<Message&> t = base::MakeRefTuple(*reply); + std::tuple<Message&> t = std::tie(*reply); ConnectMessageAndReply(msg, reply); base::DispatchToMethod(obj, func, send_params, &t); } else { diff --git a/ipc/ipc_message_templates_impl.h b/ipc/ipc_message_templates_impl.h index bfcdad0..192d2ef 100644 --- a/ipc/ipc_message_templates_impl.h +++ b/ipc/ipc_message_templates_impl.h @@ -5,37 +5,39 @@ #ifndef IPC_IPC_MESSAGE_TEMPLATES_IMPL_H_ #define IPC_IPC_MESSAGE_TEMPLATES_IMPL_H_ +#include <tuple> + namespace IPC { template <typename... Ts> class ParamDeserializer : public MessageReplyDeserializer { public: - explicit ParamDeserializer(const base::Tuple<Ts&...>& out) : out_(out) {} + explicit ParamDeserializer(const std::tuple<Ts&...>& out) : out_(out) {} bool SerializeOutputParameters(const IPC::Message& msg, base::PickleIterator iter) override { return ReadParam(&msg, &iter, &out_); } - base::Tuple<Ts&...> out_; + std::tuple<Ts&...> out_; }; template <typename Meta, typename... Ins> -MessageT<Meta, base::Tuple<Ins...>, void>::MessageT(Routing routing, +MessageT<Meta, std::tuple<Ins...>, void>::MessageT(Routing routing, const Ins&... ins) : Message(routing.id, ID, PRIORITY_NORMAL) { - WriteParam(this, base::MakeRefTuple(ins...)); + WriteParam(this, std::tie(ins...)); } template <typename Meta, typename... Ins> -bool MessageT<Meta, base::Tuple<Ins...>, void>::Read(const Message* msg, +bool MessageT<Meta, std::tuple<Ins...>, void>::Read(const Message* msg, Param* p) { base::PickleIterator iter(*msg); return ReadParam(msg, &iter, p); } template <typename Meta, typename... Ins> -void MessageT<Meta, base::Tuple<Ins...>, void>::Log(std::string* name, +void MessageT<Meta, std::tuple<Ins...>, void>::Log(std::string* name, const Message* msg, std::string* l) { if (name) @@ -48,7 +50,7 @@ void MessageT<Meta, base::Tuple<Ins...>, void>::Log(std::string* name, } template <typename Meta, typename... Ins, typename... Outs> -MessageT<Meta, base::Tuple<Ins...>, base::Tuple<Outs...>>::MessageT( +MessageT<Meta, std::tuple<Ins...>, std::tuple<Outs...>>::MessageT( Routing routing, const Ins&... ins, Outs*... outs) @@ -56,12 +58,12 @@ MessageT<Meta, base::Tuple<Ins...>, base::Tuple<Outs...>>::MessageT( routing.id, ID, PRIORITY_NORMAL, - new ParamDeserializer<Outs...>(base::MakeRefTuple(*outs...))) { - WriteParam(this, base::MakeRefTuple(ins...)); + new ParamDeserializer<Outs...>(std::tie(*outs...))) { + WriteParam(this, std::tie(ins...)); } template <typename Meta, typename... Ins, typename... Outs> -bool MessageT<Meta, base::Tuple<Ins...>, base::Tuple<Outs...>>::ReadSendParam( +bool MessageT<Meta, std::tuple<Ins...>, std::tuple<Outs...>>::ReadSendParam( const Message* msg, SendParam* p) { base::PickleIterator iter = SyncMessage::GetDataIterator(msg); @@ -69,7 +71,7 @@ bool MessageT<Meta, base::Tuple<Ins...>, base::Tuple<Outs...>>::ReadSendParam( } template <typename Meta, typename... Ins, typename... Outs> -bool MessageT<Meta, base::Tuple<Ins...>, base::Tuple<Outs...>>::ReadReplyParam( +bool MessageT<Meta, std::tuple<Ins...>, std::tuple<Outs...>>::ReadReplyParam( const Message* msg, ReplyParam* p) { base::PickleIterator iter = SyncMessage::GetDataIterator(msg); @@ -78,14 +80,14 @@ bool MessageT<Meta, base::Tuple<Ins...>, base::Tuple<Outs...>>::ReadReplyParam( template <typename Meta, typename... Ins, typename... Outs> void MessageT<Meta, - base::Tuple<Ins...>, - base::Tuple<Outs...>>::WriteReplyParams(Message* reply, + std::tuple<Ins...>, + std::tuple<Outs...>>::WriteReplyParams(Message* reply, const Outs&... outs) { - WriteParam(reply, base::MakeRefTuple(outs...)); + WriteParam(reply, std::tie(outs...)); } template <typename Meta, typename... Ins, typename... Outs> -void MessageT<Meta, base::Tuple<Ins...>, base::Tuple<Outs...>>::Log( +void MessageT<Meta, std::tuple<Ins...>, std::tuple<Outs...>>::Log( std::string* name, const Message* msg, std::string* l) { diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h index 971370a..d92d833 100644 --- a/ipc/ipc_message_utils.h +++ b/ipc/ipc_message_utils.h @@ -13,6 +13,7 @@ #include <map> #include <set> #include <string> +#include <tuple> #include <vector> #include "base/containers/small_map.h" @@ -24,7 +25,6 @@ #include "base/strings/string16.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" -#include "base/tuple.h" #include "build/build_config.h" #include "ipc/brokerable_attachment.h" #include "ipc/ipc_message_start.h" @@ -666,18 +666,18 @@ template <class A> struct ParamTraits<std::tuple<A>> { typedef std::tuple<A> param_type; static void GetSize(base::PickleSizer* sizer, const param_type& p) { - GetParamSize(sizer, base::get<0>(p)); + GetParamSize(sizer, std::get<0>(p)); } static void Write(base::Pickle* m, const param_type& p) { - WriteParam(m, base::get<0>(p)); + WriteParam(m, std::get<0>(p)); } static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { - return ReadParam(m, iter, &base::get<0>(*r)); + return ReadParam(m, iter, &std::get<0>(*r)); } static void Log(const param_type& p, std::string* l) { - LogParam(base::get<0>(p), l); + LogParam(std::get<0>(p), l); } }; @@ -685,23 +685,23 @@ template <class A, class B> struct ParamTraits<std::tuple<A, B>> { typedef std::tuple<A, B> param_type; static void GetSize(base::PickleSizer* sizer, const param_type& p) { - GetParamSize(sizer, base::get<0>(p)); - GetParamSize(sizer, base::get<1>(p)); + GetParamSize(sizer, std::get<0>(p)); + GetParamSize(sizer, std::get<1>(p)); } static void Write(base::Pickle* m, const param_type& p) { - WriteParam(m, base::get<0>(p)); - WriteParam(m, base::get<1>(p)); + WriteParam(m, std::get<0>(p)); + WriteParam(m, std::get<1>(p)); } static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { - return (ReadParam(m, iter, &base::get<0>(*r)) && - ReadParam(m, iter, &base::get<1>(*r))); + return (ReadParam(m, iter, &std::get<0>(*r)) && + ReadParam(m, iter, &std::get<1>(*r))); } static void Log(const param_type& p, std::string* l) { - LogParam(base::get<0>(p), l); + LogParam(std::get<0>(p), l); l->append(", "); - LogParam(base::get<1>(p), l); + LogParam(std::get<1>(p), l); } }; @@ -709,28 +709,28 @@ template <class A, class B, class C> struct ParamTraits<std::tuple<A, B, C>> { typedef std::tuple<A, B, C> param_type; static void GetSize(base::PickleSizer* sizer, const param_type& p) { - GetParamSize(sizer, base::get<0>(p)); - GetParamSize(sizer, base::get<1>(p)); - GetParamSize(sizer, base::get<2>(p)); + GetParamSize(sizer, std::get<0>(p)); + GetParamSize(sizer, std::get<1>(p)); + GetParamSize(sizer, std::get<2>(p)); } static void Write(base::Pickle* m, const param_type& p) { - WriteParam(m, base::get<0>(p)); - WriteParam(m, base::get<1>(p)); - WriteParam(m, base::get<2>(p)); + WriteParam(m, std::get<0>(p)); + WriteParam(m, std::get<1>(p)); + WriteParam(m, std::get<2>(p)); } static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { - return (ReadParam(m, iter, &base::get<0>(*r)) && - ReadParam(m, iter, &base::get<1>(*r)) && - ReadParam(m, iter, &base::get<2>(*r))); + return (ReadParam(m, iter, &std::get<0>(*r)) && + ReadParam(m, iter, &std::get<1>(*r)) && + ReadParam(m, iter, &std::get<2>(*r))); } static void Log(const param_type& p, std::string* l) { - LogParam(base::get<0>(p), l); + LogParam(std::get<0>(p), l); l->append(", "); - LogParam(base::get<1>(p), l); + LogParam(std::get<1>(p), l); l->append(", "); - LogParam(base::get<2>(p), l); + LogParam(std::get<2>(p), l); } }; @@ -738,33 +738,33 @@ template <class A, class B, class C, class D> struct ParamTraits<std::tuple<A, B, C, D>> { typedef std::tuple<A, B, C, D> param_type; static void GetSize(base::PickleSizer* sizer, const param_type& p) { - GetParamSize(sizer, base::get<0>(p)); - GetParamSize(sizer, base::get<1>(p)); - GetParamSize(sizer, base::get<2>(p)); - GetParamSize(sizer, base::get<3>(p)); + GetParamSize(sizer, std::get<0>(p)); + GetParamSize(sizer, std::get<1>(p)); + GetParamSize(sizer, std::get<2>(p)); + GetParamSize(sizer, std::get<3>(p)); } static void Write(base::Pickle* m, const param_type& p) { - WriteParam(m, base::get<0>(p)); - WriteParam(m, base::get<1>(p)); - WriteParam(m, base::get<2>(p)); - WriteParam(m, base::get<3>(p)); + WriteParam(m, std::get<0>(p)); + WriteParam(m, std::get<1>(p)); + WriteParam(m, std::get<2>(p)); + WriteParam(m, std::get<3>(p)); } static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { - return (ReadParam(m, iter, &base::get<0>(*r)) && - ReadParam(m, iter, &base::get<1>(*r)) && - ReadParam(m, iter, &base::get<2>(*r)) && - ReadParam(m, iter, &base::get<3>(*r))); + return (ReadParam(m, iter, &std::get<0>(*r)) && + ReadParam(m, iter, &std::get<1>(*r)) && + ReadParam(m, iter, &std::get<2>(*r)) && + ReadParam(m, iter, &std::get<3>(*r))); } static void Log(const param_type& p, std::string* l) { - LogParam(base::get<0>(p), l); + LogParam(std::get<0>(p), l); l->append(", "); - LogParam(base::get<1>(p), l); + LogParam(std::get<1>(p), l); l->append(", "); - LogParam(base::get<2>(p), l); + LogParam(std::get<2>(p), l); l->append(", "); - LogParam(base::get<3>(p), l); + LogParam(std::get<3>(p), l); } }; @@ -772,38 +772,38 @@ template <class A, class B, class C, class D, class E> struct ParamTraits<std::tuple<A, B, C, D, E>> { typedef std::tuple<A, B, C, D, E> param_type; static void GetSize(base::PickleSizer* sizer, const param_type& p) { - GetParamSize(sizer, base::get<0>(p)); - GetParamSize(sizer, base::get<1>(p)); - GetParamSize(sizer, base::get<2>(p)); - GetParamSize(sizer, base::get<3>(p)); - GetParamSize(sizer, base::get<4>(p)); + GetParamSize(sizer, std::get<0>(p)); + GetParamSize(sizer, std::get<1>(p)); + GetParamSize(sizer, std::get<2>(p)); + GetParamSize(sizer, std::get<3>(p)); + GetParamSize(sizer, std::get<4>(p)); } static void Write(base::Pickle* m, const param_type& p) { - WriteParam(m, base::get<0>(p)); - WriteParam(m, base::get<1>(p)); - WriteParam(m, base::get<2>(p)); - WriteParam(m, base::get<3>(p)); - WriteParam(m, base::get<4>(p)); + WriteParam(m, std::get<0>(p)); + WriteParam(m, std::get<1>(p)); + WriteParam(m, std::get<2>(p)); + WriteParam(m, std::get<3>(p)); + WriteParam(m, std::get<4>(p)); } static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { - return (ReadParam(m, iter, &base::get<0>(*r)) && - ReadParam(m, iter, &base::get<1>(*r)) && - ReadParam(m, iter, &base::get<2>(*r)) && - ReadParam(m, iter, &base::get<3>(*r)) && - ReadParam(m, iter, &base::get<4>(*r))); + return (ReadParam(m, iter, &std::get<0>(*r)) && + ReadParam(m, iter, &std::get<1>(*r)) && + ReadParam(m, iter, &std::get<2>(*r)) && + ReadParam(m, iter, &std::get<3>(*r)) && + ReadParam(m, iter, &std::get<4>(*r))); } static void Log(const param_type& p, std::string* l) { - LogParam(base::get<0>(p), l); + LogParam(std::get<0>(p), l); l->append(", "); - LogParam(base::get<1>(p), l); + LogParam(std::get<1>(p), l); l->append(", "); - LogParam(base::get<2>(p), l); + LogParam(std::get<2>(p), l); l->append(", "); - LogParam(base::get<3>(p), l); + LogParam(std::get<3>(p), l); l->append(", "); - LogParam(base::get<4>(p), l); + LogParam(std::get<4>(p), l); } }; |