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

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

Issue 1159553007: Move Tuple to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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/dispatch_reply_message.h ('k') | ppapi/proxy/plugin_var_tracker_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/nacl_message_scanner.h" 5 #include "ppapi/proxy/nacl_message_scanner.h"
6 6
7 #include <vector> 7 #include <vector>
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "ipc/ipc_message.h" 9 #include "ipc/ipc_message.h"
10 #include "ipc/ipc_message_macros.h" 10 #include "ipc/ipc_message_macros.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 template <class T> 142 template <class T>
143 void ScanParam(const T& param, ScanningResults* results) { 143 void ScanParam(const T& param, ScanningResults* results) {
144 if (results->new_msg) 144 if (results->new_msg)
145 IPC::WriteParam(results->new_msg.get(), param); 145 IPC::WriteParam(results->new_msg.get(), param);
146 } 146 }
147 147
148 // These just break apart the given tuple and run ScanParam over each param. 148 // These just break apart the given tuple and run ScanParam over each param.
149 // The idea is to scan elements in the tuple which require special handling, 149 // The idea is to scan elements in the tuple which require special handling,
150 // and write them into the |results| struct. 150 // and write them into the |results| struct.
151 template <class A> 151 template <class A>
152 void ScanTuple(const Tuple<A>& t1, ScanningResults* results) { 152 void ScanTuple(const base::Tuple<A>& t1, ScanningResults* results) {
153 ScanParam(get<0>(t1), results); 153 ScanParam(base::get<0>(t1), results);
154 } 154 }
155 template <class A, class B> 155 template <class A, class B>
156 void ScanTuple(const Tuple<A, B>& t1, ScanningResults* results) { 156 void ScanTuple(const base::Tuple<A, B>& t1, ScanningResults* results) {
157 ScanParam(get<0>(t1), results); 157 ScanParam(base::get<0>(t1), results);
158 ScanParam(get<1>(t1), results); 158 ScanParam(base::get<1>(t1), results);
159 } 159 }
160 template <class A, class B, class C> 160 template <class A, class B, class C>
161 void ScanTuple(const Tuple<A, B, C>& t1, ScanningResults* results) { 161 void ScanTuple(const base::Tuple<A, B, C>& t1, ScanningResults* results) {
162 ScanParam(get<0>(t1), results); 162 ScanParam(base::get<0>(t1), results);
163 ScanParam(get<1>(t1), results); 163 ScanParam(base::get<1>(t1), results);
164 ScanParam(get<2>(t1), results); 164 ScanParam(base::get<2>(t1), results);
165 } 165 }
166 template <class A, class B, class C, class D> 166 template <class A, class B, class C, class D>
167 void ScanTuple(const Tuple<A, B, C, D>& t1, ScanningResults* results) { 167 void ScanTuple(const base::Tuple<A, B, C, D>& t1, ScanningResults* results) {
168 ScanParam(get<0>(t1), results); 168 ScanParam(base::get<0>(t1), results);
169 ScanParam(get<1>(t1), results); 169 ScanParam(base::get<1>(t1), results);
170 ScanParam(get<2>(t1), results); 170 ScanParam(base::get<2>(t1), results);
171 ScanParam(get<3>(t1), results); 171 ScanParam(base::get<3>(t1), results);
172 } 172 }
173 173
174 template <class MessageType> 174 template <class MessageType>
175 class MessageScannerImpl { 175 class MessageScannerImpl {
176 public: 176 public:
177 explicit MessageScannerImpl(const IPC::Message* msg) 177 explicit MessageScannerImpl(const IPC::Message* msg)
178 : msg_(static_cast<const MessageType*>(msg)) { 178 : msg_(static_cast<const MessageType*>(msg)) {
179 } 179 }
180 bool ScanMessage(ScanningResults* results) { 180 bool ScanMessage(ScanningResults* results) {
181 typename TupleTypes<typename MessageType::Schema::Param>::ValueTuple params; 181 typename base::TupleTypes<typename MessageType::Schema::Param>::ValueTuple
182 params;
182 if (!MessageType::Read(msg_, &params)) 183 if (!MessageType::Read(msg_, &params))
183 return false; 184 return false;
184 ScanTuple(params, results); 185 ScanTuple(params, results);
185 return true; 186 return true;
186 } 187 }
187 188
188 bool ScanReply(ScanningResults* results) { 189 bool ScanReply(ScanningResults* results) {
189 typename TupleTypes<typename MessageType::Schema::ReplyParam>::ValueTuple 190 typename base::TupleTypes<typename MessageType::Schema::ReplyParam>
190 params; 191 ::ValueTuple params;
191 if (!MessageType::ReadReplyParam(msg_, &params)) 192 if (!MessageType::ReadReplyParam(msg_, &params))
192 return false; 193 return false;
193 // If we need to rewrite the message, write the message id first. 194 // If we need to rewrite the message, write the message id first.
194 if (results->new_msg) { 195 if (results->new_msg) {
195 results->new_msg->set_reply(); 196 results->new_msg->set_reply();
196 int id = IPC::SyncMessage::GetMessageId(*msg_); 197 int id = IPC::SyncMessage::GetMessageId(*msg_);
197 results->new_msg->WriteInt(id); 198 results->new_msg->WriteInt(id);
198 } 199 }
199 ScanTuple(params, results); 200 ScanTuple(params, results);
200 return true; 201 return true;
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 fio_it->second->SetMaxWrittenOffset(offset_it->second); 515 fio_it->second->SetMaxWrittenOffset(offset_it->second);
515 } 516 }
516 } 517 }
517 break; 518 break;
518 } 519 }
519 } 520 }
520 } 521 }
521 522
522 } // namespace proxy 523 } // namespace proxy
523 } // namespace ppapi 524 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/dispatch_reply_message.h ('k') | ppapi/proxy/plugin_var_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698