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

Side by Side Diff: chrome/common/ipc_test_sink.cc

Issue 18326: Factor out the message sink from MockRenderThread to a separate class. I will... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 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
« no previous file with comments | « chrome/common/ipc_test_sink.h ('k') | chrome/renderer/mock_render_thread.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2009 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 "chrome/common/ipc_test_sink.h"
6
7 namespace IPC {
8
9 TestSink::TestSink() {
10 }
11
12 TestSink::~TestSink() {
13 }
14
15 void TestSink::OnMessageReceived(const Message& msg) {
16 messages_.push_back(Message(msg));
17 }
18
19 void TestSink::ClearMessages() {
20 messages_.clear();
21 }
22
23 const Message* TestSink::GetMessageAt(size_t index) const {
24 if (index >= messages_.size())
25 return NULL;
26 return &messages_[index];
27 }
28
29 const Message* TestSink::GetFirstMessageMatching(uint16 id) const {
30 for (size_t i = 0; i < messages_.size(); i++) {
31 if (messages_[i].type() == id)
32 return &messages_[i];
33 }
34 return NULL;
35 }
36
37 const Message* TestSink::GetUniqueMessageMatching(uint16 id) const {
38 size_t found_index = 0;
39 size_t found_count = 0;
40 for (size_t i = 0; i < messages_.size(); i++) {
41 if (messages_[i].type() == id) {
42 found_count++;
43 found_index = i;
44 }
45 }
46 if (found_count != 1)
47 return NULL; // Didn't find a unique one.
48 return &messages_[found_index];
49 }
50
51 } // namespace IPC
OLDNEW
« no previous file with comments | « chrome/common/ipc_test_sink.h ('k') | chrome/renderer/mock_render_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698