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

Side by Side Diff: ipc/ipc_test_base.h

Issue 488003003: Add ChannelProxy benchmark to ipc_perftests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Landing. Created 6 years, 3 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 | « ipc/ipc_perftests.cc ('k') | ipc/ipc_test_base.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef IPC_IPC_TEST_BASE_H_ 5 #ifndef IPC_IPC_TEST_BASE_H_
6 #define IPC_IPC_TEST_BASE_H_ 6 #define IPC_IPC_TEST_BASE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/process/process.h" 12 #include "base/process/process.h"
13 #include "base/test/multiprocess_test.h" 13 #include "base/test/multiprocess_test.h"
14 #include "ipc/ipc_channel.h" 14 #include "ipc/ipc_channel.h"
15 #include "ipc/ipc_channel_proxy.h" 15 #include "ipc/ipc_channel_proxy.h"
16 #include "ipc/ipc_multiprocess_test.h" 16 #include "ipc/ipc_multiprocess_test.h"
17 17
18 namespace base { 18 namespace base {
19 class MessageLoopForIO; 19 class MessageLoop;
20 } 20 }
21 21
22 // A test fixture for multiprocess IPC tests. Such tests include a "client" side 22 // A test fixture for multiprocess IPC tests. Such tests include a "client" side
23 // (running in a separate process). The same client may be shared between 23 // (running in a separate process). The same client may be shared between
24 // several different tests. 24 // several different tests.
25 class IPCTestBase : public base::MultiProcessTest { 25 class IPCTestBase : public base::MultiProcessTest {
26 public: 26 public:
27 // The channel name is based on the client's name. This is a public static 27 // The channel name is based on the client's name. This is a public static
28 // helper to be used by the client-side code; server-side test code should 28 // helper to be used by the client-side code; server-side test code should
29 // usually not use this (directly). 29 // usually not use this (directly).
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 // channel or a proxy). 79 // channel or a proxy).
80 IPC::Sender* sender() { 80 IPC::Sender* sender() {
81 return channel_.get() ? static_cast<IPC::Sender*>(channel_.get()) : 81 return channel_.get() ? static_cast<IPC::Sender*>(channel_.get()) :
82 static_cast<IPC::Sender*>(channel_proxy_.get()); 82 static_cast<IPC::Sender*>(channel_proxy_.get());
83 } 83 }
84 84
85 IPC::Channel* channel() { return channel_.get(); } 85 IPC::Channel* channel() { return channel_.get(); }
86 IPC::ChannelProxy* channel_proxy() { return channel_proxy_.get(); } 86 IPC::ChannelProxy* channel_proxy() { return channel_proxy_.get(); }
87 87
88 const base::ProcessHandle& client_process() const { return client_process_; } 88 const base::ProcessHandle& client_process() const { return client_process_; }
89 scoped_refptr<base::TaskRunner> io_thread_task_runner(); 89 scoped_refptr<base::TaskRunner> task_runner();
90
91 // Some tests creates separate thread for IO message loop and Run
92 // non-IO message loop on the main thread. As IPCTestBase creates IO
93 // message loop by default, such tests might want to replace it with
94 // non-IO one using set_message_loop().
95 //
96 // The replacement should be done at the beginning of the test.
97 // You should be careful not to replace "live" message loop that has
98 // started running.
99 void set_message_loop(scoped_ptr<base::MessageLoop> loop);
90 100
91 private: 101 private:
92 std::string test_client_name_; 102 std::string test_client_name_;
93 scoped_ptr<base::MessageLoopForIO> message_loop_; 103 scoped_ptr<base::MessageLoop> message_loop_;
94 104
95 scoped_ptr<IPC::Channel> channel_; 105 scoped_ptr<IPC::Channel> channel_;
96 scoped_ptr<IPC::ChannelProxy> channel_proxy_; 106 scoped_ptr<IPC::ChannelProxy> channel_proxy_;
97 107
98 base::ProcessHandle client_process_; 108 base::ProcessHandle client_process_;
99 109
100 DISALLOW_COPY_AND_ASSIGN(IPCTestBase); 110 DISALLOW_COPY_AND_ASSIGN(IPCTestBase);
101 }; 111 };
102 112
103 // Use this to declare the client side for tests using IPCTestBase. 113 // Use this to declare the client side for tests using IPCTestBase.
104 #define MULTIPROCESS_IPC_TEST_CLIENT_MAIN(test_client_name) \ 114 #define MULTIPROCESS_IPC_TEST_CLIENT_MAIN(test_client_name) \
105 MULTIPROCESS_IPC_TEST_MAIN(test_client_name ## TestClientMain) 115 MULTIPROCESS_IPC_TEST_MAIN(test_client_name ## TestClientMain)
106 116
107 #endif // IPC_IPC_TEST_BASE_H_ 117 #endif // IPC_IPC_TEST_BASE_H_
OLDNEW
« no previous file with comments | « ipc/ipc_perftests.cc ('k') | ipc/ipc_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698