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

Side by Side Diff: ppapi/host/resource_message_filter_unittest.cc

Issue 57783006: Revert https://src.chromium.org/viewvc/chrome?view=rev&revision=231330 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile (cc perftest). Created 7 years, 1 month 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
« no previous file with comments | « ipc/ipc_sync_message.cc ('k') | ppapi/proxy/nacl_message_scanner.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 "base/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "base/message_loop/message_loop_proxy.h" 6 #include "base/message_loop/message_loop_proxy.h"
7 #include "base/synchronization/waitable_event.h" 7 #include "base/synchronization/waitable_event.h"
8 #include "base/threading/thread.h" 8 #include "base/threading/thread.h"
9 #include "ipc/ipc_message.h" 9 #include "ipc/ipc_message.h"
10 #include "ppapi/c/pp_errors.h" 10 #include "ppapi/c/pp_errors.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 void AddMessageFilter(scoped_refptr<ResourceMessageFilter> filter) { 58 void AddMessageFilter(scoped_refptr<ResourceMessageFilter> filter) {
59 AddFilter(filter); 59 AddFilter(filter);
60 } 60 }
61 61
62 virtual int32_t OnResourceMessageReceived( 62 virtual int32_t OnResourceMessageReceived(
63 const IPC::Message& msg, 63 const IPC::Message& msg,
64 HostMessageContext* context) OVERRIDE { 64 HostMessageContext* context) OVERRIDE {
65 last_handled_msg_ = msg; 65 last_handled_msg_ = msg;
66 if (msg.type() == msg_type_) { 66 if (msg.type() == msg_type_) {
67 context->reply_msg = IPC::Message(0, reply_msg_type_); 67 context->reply_msg = IPC::Message(0, reply_msg_type_,
68 IPC::Message::PRIORITY_NORMAL);
68 return PP_OK; 69 return PP_OK;
69 } 70 }
70 return PP_ERROR_FAILED; 71 return PP_ERROR_FAILED;
71 } 72 }
72 73
73 virtual void SendReply(const ReplyMessageContext& context, 74 virtual void SendReply(const ReplyMessageContext& context,
74 const IPC::Message& msg) OVERRIDE { 75 const IPC::Message& msg) OVERRIDE {
75 last_reply_msg_ = msg; 76 last_reply_msg_ = msg;
76 last_reply_message_loop_ = base::MessageLoop::current(); 77 last_reply_message_loop_ = base::MessageLoop::current();
77 g_handler_completion.Signal(); 78 g_handler_completion.Signal();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 return message_loop_proxy_; 116 return message_loop_proxy_;
116 return NULL; 117 return NULL;
117 } 118 }
118 119
119 virtual int32_t OnResourceMessageReceived( 120 virtual int32_t OnResourceMessageReceived(
120 const IPC::Message& msg, 121 const IPC::Message& msg,
121 HostMessageContext* context) OVERRIDE { 122 HostMessageContext* context) OVERRIDE {
122 last_handled_msg_ = msg; 123 last_handled_msg_ = msg;
123 last_message_loop_ = base::MessageLoop::current(); 124 last_message_loop_ = base::MessageLoop::current();
124 if (msg.type() == msg_type_) { 125 if (msg.type() == msg_type_) {
125 context->reply_msg = IPC::Message(0, reply_msg_type_); 126 context->reply_msg = IPC::Message(0, reply_msg_type_,
127 IPC::Message::PRIORITY_NORMAL);
126 return PP_OK; 128 return PP_OK;
127 } 129 }
128 return PP_ERROR_FAILED; 130 return PP_ERROR_FAILED;
129 } 131 }
130 132
131 private: 133 private:
132 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; 134 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
133 uint32 msg_type_; 135 uint32 msg_type_;
134 uint32 reply_msg_type_; 136 uint32 reply_msg_type_;
135 137
(...skipping 21 matching lines...) Expand all
157 159
158 PP_Instance instance = 12345; 160 PP_Instance instance = 12345;
159 PP_Resource resource = 67890; 161 PP_Resource resource = 67890;
160 MyResourceHost host(NULL, instance, resource, MSG3_TYPE, REPLY_MSG3_TYPE); 162 MyResourceHost host(NULL, instance, resource, MSG3_TYPE, REPLY_MSG3_TYPE);
161 host.AddMessageFilter(filter1); 163 host.AddMessageFilter(filter1);
162 host.AddMessageFilter(filter2); 164 host.AddMessageFilter(filter2);
163 165
164 proxy::ResourceMessageCallParams params(resource, 1); 166 proxy::ResourceMessageCallParams params(resource, 1);
165 params.set_has_callback(); 167 params.set_has_callback();
166 HostMessageContext context(params); 168 HostMessageContext context(params);
167 IPC::Message message1(0, MSG1_TYPE); 169 IPC::Message message1(0, MSG1_TYPE, IPC::Message::PRIORITY_NORMAL);
168 IPC::Message message2(0, MSG2_TYPE); 170 IPC::Message message2(0, MSG2_TYPE, IPC::Message::PRIORITY_NORMAL);
169 IPC::Message message3(0, MSG3_TYPE); 171 IPC::Message message3(0, MSG3_TYPE, IPC::Message::PRIORITY_NORMAL);
170 172
171 // Message 1 handled by the first filter. 173 // Message 1 handled by the first filter.
172 host.HandleMessage(message1, &context); 174 host.HandleMessage(message1, &context);
173 g_handler_completion.Wait(); 175 g_handler_completion.Wait();
174 EXPECT_EQ(filter1->last_handled_msg().type(), message1.type()); 176 EXPECT_EQ(filter1->last_handled_msg().type(), message1.type());
175 EXPECT_EQ(filter1->last_message_loop(), bg_thread1.message_loop()); 177 EXPECT_EQ(filter1->last_message_loop(), bg_thread1.message_loop());
176 EXPECT_EQ(host.last_reply_msg().type(), static_cast<uint32>(REPLY_MSG1_TYPE)); 178 EXPECT_EQ(host.last_reply_msg().type(), static_cast<uint32>(REPLY_MSG1_TYPE));
177 EXPECT_EQ(host.last_reply_message_loop(), io_thread.message_loop()); 179 EXPECT_EQ(host.last_reply_message_loop(), io_thread.message_loop());
178 g_handler_completion.Reset(); 180 g_handler_completion.Reset();
179 181
(...skipping 11 matching lines...) Expand all
191 EXPECT_EQ(host.last_handled_msg().type(), message3.type()); 193 EXPECT_EQ(host.last_handled_msg().type(), message3.type());
192 EXPECT_EQ(host.last_reply_msg().type(), static_cast<uint32>(REPLY_MSG3_TYPE)); 194 EXPECT_EQ(host.last_reply_msg().type(), static_cast<uint32>(REPLY_MSG3_TYPE));
193 195
194 io_thread.Stop(); 196 io_thread.Stop();
195 bg_thread1.Stop(); 197 bg_thread1.Stop();
196 bg_thread2.Stop(); 198 bg_thread2.Stop();
197 } 199 }
198 200
199 } // namespace proxy 201 } // namespace proxy
200 } // namespace ppapi 202 } // namespace ppapi
OLDNEW
« no previous file with comments | « ipc/ipc_sync_message.cc ('k') | ppapi/proxy/nacl_message_scanner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698