Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(321)

Side by Side Diff: ppapi/proxy/resource_message_test_sink.cc

Issue 1772763002: Replace base::Tuple in //ppapi with std::tuple (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update #include Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ppapi/proxy/ppapi_proxy_test.cc ('k') | ppapi/proxy/websocket_resource_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/proxy/resource_message_test_sink.h" 5 #include "ppapi/proxy/resource_message_test_sink.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <tuple>
10
9 #include "ppapi/proxy/ppapi_messages.h" 11 #include "ppapi/proxy/ppapi_messages.h"
10 #include "ppapi/proxy/resource_message_params.h" 12 #include "ppapi/proxy/resource_message_params.h"
11 #include "ppapi/proxy/serialized_handle.h" 13 #include "ppapi/proxy/serialized_handle.h"
12 14
13 namespace ppapi { 15 namespace ppapi {
14 namespace proxy { 16 namespace proxy {
15 17
16 namespace { 18 namespace {
17 19
18 // Backend for GetAllResource[Calls|Replies]Matching. 20 // Backend for GetAllResource[Calls|Replies]Matching.
19 template <class WrapperMessage, class Params> 21 template <class WrapperMessage, class Params>
20 std::vector<std::pair<Params, IPC::Message>> GetAllResourceMessagesMatching( 22 std::vector<std::pair<Params, IPC::Message>> GetAllResourceMessagesMatching(
21 const ResourceMessageTestSink& sink, 23 const ResourceMessageTestSink& sink,
22 uint32_t id) { 24 uint32_t id) {
23 std::vector<std::pair<Params, IPC::Message> > result; 25 std::vector<std::pair<Params, IPC::Message> > result;
24 for (size_t i = 0; i < sink.message_count(); i++) { 26 for (size_t i = 0; i < sink.message_count(); i++) {
25 const IPC::Message* msg = sink.GetMessageAt(i); 27 const IPC::Message* msg = sink.GetMessageAt(i);
26 if (msg->type() == WrapperMessage::ID) { 28 if (msg->type() == WrapperMessage::ID) {
27 typename WrapperMessage::Param params; 29 typename WrapperMessage::Param params;
28 WrapperMessage::Read(msg, &params); 30 WrapperMessage::Read(msg, &params);
29 Params cur_params = base::get<0>(params); 31 Params cur_params = std::get<0>(params);
30 IPC::Message cur_msg = base::get<1>(params); 32 IPC::Message cur_msg = std::get<1>(params);
31 if (cur_msg.type() == id) { 33 if (cur_msg.type() == id) {
32 result.push_back(std::make_pair(cur_params, cur_msg)); 34 result.push_back(std::make_pair(cur_params, cur_msg));
33 } 35 }
34 } 36 }
35 } 37 }
36 return result; 38 return result;
37 } 39 }
38 40
39 } // namespace 41 } // namespace
40 42
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 ResourceSyncCallHandler::~ResourceSyncCallHandler() { 126 ResourceSyncCallHandler::~ResourceSyncCallHandler() {
125 } 127 }
126 128
127 bool ResourceSyncCallHandler::OnMessageReceived(const IPC::Message& msg) { 129 bool ResourceSyncCallHandler::OnMessageReceived(const IPC::Message& msg) {
128 if (msg.type() != PpapiHostMsg_ResourceSyncCall::ID) 130 if (msg.type() != PpapiHostMsg_ResourceSyncCall::ID)
129 return false; 131 return false;
130 PpapiHostMsg_ResourceSyncCall::Schema::SendParam send_params; 132 PpapiHostMsg_ResourceSyncCall::Schema::SendParam send_params;
131 bool success = PpapiHostMsg_ResourceSyncCall::ReadSendParam( 133 bool success = PpapiHostMsg_ResourceSyncCall::ReadSendParam(
132 &msg, &send_params); 134 &msg, &send_params);
133 DCHECK(success); 135 DCHECK(success);
134 ResourceMessageCallParams call_params = base::get<0>(send_params); 136 ResourceMessageCallParams call_params = std::get<0>(send_params);
135 IPC::Message call_msg = base::get<1>(send_params); 137 IPC::Message call_msg = std::get<1>(send_params);
136 if (call_msg.type() != incoming_type_) 138 if (call_msg.type() != incoming_type_)
137 return false; 139 return false;
138 IPC::Message* wrapper_reply_msg = IPC::SyncMessage::GenerateReply(&msg); 140 IPC::Message* wrapper_reply_msg = IPC::SyncMessage::GenerateReply(&msg);
139 ResourceMessageReplyParams reply_params(call_params.pp_resource(), 141 ResourceMessageReplyParams reply_params(call_params.pp_resource(),
140 call_params.sequence()); 142 call_params.sequence());
141 reply_params.set_result(result_); 143 reply_params.set_result(result_);
142 if (serialized_handle_) 144 if (serialized_handle_)
143 reply_params.AppendHandle(*serialized_handle_); 145 reply_params.AppendHandle(*serialized_handle_);
144 PpapiHostMsg_ResourceSyncCall::WriteReplyParams( 146 PpapiHostMsg_ResourceSyncCall::WriteReplyParams(
145 wrapper_reply_msg, reply_params, reply_msg_); 147 wrapper_reply_msg, reply_params, reply_msg_);
146 test_sink_->SetSyncReplyMessage(wrapper_reply_msg); 148 test_sink_->SetSyncReplyMessage(wrapper_reply_msg);
147 149
148 // Stash a copy of the message for inspection later. 150 // Stash a copy of the message for inspection later.
149 last_handled_msg_ = call_msg; 151 last_handled_msg_ = call_msg;
150 return true; 152 return true;
151 } 153 }
152 154
153 } // namespace proxy 155 } // namespace proxy
154 } // namespace ppapi 156 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppapi_proxy_test.cc ('k') | ppapi/proxy/websocket_resource_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698