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

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

Issue 10560030: Add resource message call and reply infrastructure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ppapi/proxy/resource_message_test_sink.h"
6
7 #include "ppapi/proxy/ppapi_messages.h"
8 #include "ppapi/proxy/resource_message_params.h"
9
10 namespace ppapi {
11 namespace proxy {
12
13 namespace {
14
15 // Backend for GetFirstResource[Call|Reply]Matching.
16 template<class WrapperMessage, class Params>
17 bool GetFirstResourceMessageMatching(const ResourceMessageTestSink& sink,
18 uint32 id,
19 Params* params,
20 IPC::Message* nested_msg) {
21 for (size_t i = 0; i < sink.message_count(); i++) {
22 const IPC::Message* msg = sink.GetMessageAt(i);
23 if (msg->type() == WrapperMessage::ID) {
24 Params cur_params;
25 IPC::Message cur_msg;
26 WrapperMessage::Read(msg, &cur_params, &cur_msg);
27 if (cur_msg.type() == id) {
28 *params = cur_params;
29 *nested_msg = cur_msg;
30 return true;
31 }
32 }
33 }
34 return false;
35 }
36
37 } // namespace
38
39 ResourceMessageTestSink::ResourceMessageTestSink() {
40 }
41
42 ResourceMessageTestSink::~ResourceMessageTestSink() {
43 }
44
45 bool ResourceMessageTestSink::GetFirstResourceCallMatching(
46 uint32 id,
47 ResourceMessageCallParams* params,
48 IPC::Message* nested_msg) const {
49 return GetFirstResourceMessageMatching<PpapiHostMsg_ResourceCall,
50 ResourceMessageCallParams>(
51 *this, id, params, nested_msg);
52 }
53
54 bool ResourceMessageTestSink::GetFirstResourceReplyMatching(
55 uint32 id,
56 ResourceMessageReplyParams* params,
57 IPC::Message* nested_msg) {
58 return GetFirstResourceMessageMatching<PpapiPluginMsg_ResourceReply,
59 ResourceMessageReplyParams>(
60 *this, id, params, nested_msg);
61 }
62
63 } // namespace proxy
64 } // namespace ppapi
OLDNEW
« ppapi/proxy/resource_message_params.cc ('K') | « ppapi/proxy/resource_message_test_sink.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698