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

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

Issue 18248: CommandLine API rework (Closed)
Patch Set: fixes 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
« no previous file with comments | « chrome/common/ipc_logging.cc ('k') | chrome/common/l10n_util.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #if defined(OS_WIN) 5 #if defined(OS_WIN)
6 #include <windows.h> 6 #include <windows.h>
7 #endif 7 #endif
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <iostream> 9 #include <iostream>
10 #include <string> 10 #include <string>
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 delete message_loop_; 45 delete message_loop_;
46 message_loop_ = NULL; 46 message_loop_ = NULL;
47 47
48 MultiProcessTest::TearDown(); 48 MultiProcessTest::TearDown();
49 } 49 }
50 50
51 #if defined(OS_WIN) 51 #if defined(OS_WIN)
52 base::ProcessHandle IPCChannelTest::SpawnChild(ChildType child_type, 52 base::ProcessHandle IPCChannelTest::SpawnChild(ChildType child_type,
53 IPC::Channel *channel) { 53 IPC::Channel *channel) {
54 // kDebugChildren support. 54 // kDebugChildren support.
55 bool debug_on_start = CommandLine().HasSwitch(switches::kDebugChildren); 55 bool debug_on_start =
56 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDebugChildren);
56 57
57 switch (child_type) { 58 switch (child_type) {
58 case TEST_CLIENT: 59 case TEST_CLIENT:
59 return MultiProcessTest::SpawnChild(L"RunTestClient", debug_on_start); 60 return MultiProcessTest::SpawnChild(L"RunTestClient", debug_on_start);
60 break; 61 break;
61 case TEST_REFLECTOR: 62 case TEST_REFLECTOR:
62 return MultiProcessTest::SpawnChild(L"RunReflector", debug_on_start); 63 return MultiProcessTest::SpawnChild(L"RunReflector", debug_on_start);
63 break; 64 break;
64 case FUZZER_SERVER: 65 case FUZZER_SERVER:
65 return MultiProcessTest::SpawnChild(L"RunFuzzServer", debug_on_start); 66 return MultiProcessTest::SpawnChild(L"RunFuzzServer", debug_on_start);
66 break; 67 break;
67 default: 68 default:
68 return NULL; 69 return NULL;
69 break; 70 break;
70 } 71 }
71 } 72 }
72 #elif defined(OS_POSIX) 73 #elif defined(OS_POSIX)
73 base::ProcessHandle IPCChannelTest::SpawnChild(ChildType child_type, 74 base::ProcessHandle IPCChannelTest::SpawnChild(ChildType child_type,
74 IPC::Channel *channel) { 75 IPC::Channel *channel) {
75 // kDebugChildren support. 76 // kDebugChildren support.
76 bool debug_on_start = CommandLine().HasSwitch(switches::kDebugChildren); 77 bool debug_on_start =
78 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDebugChildren);
77 79
78 base::file_handle_mapping_vector fds_to_map; 80 base::file_handle_mapping_vector fds_to_map;
79 int src_fd; 81 int src_fd;
80 int dest_fd; 82 int dest_fd;
81 channel->GetClientFileDescriptorMapping(&src_fd, &dest_fd); 83 channel->GetClientFileDescriptorMapping(&src_fd, &dest_fd);
82 if (src_fd > -1) { 84 if (src_fd > -1) {
83 fds_to_map.push_back(std::pair<int,int>(src_fd, dest_fd)); 85 fds_to_map.push_back(std::pair<int,int>(src_fd, dest_fd));
84 } 86 }
85 87
86 base::ProcessHandle ret = NULL; 88 base::ProcessHandle ret = NULL;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 options.message_loop_type = MessageLoop::TYPE_IO; 220 options.message_loop_type = MessageLoop::TYPE_IO;
219 thread.StartWithOptions(options); 221 thread.StartWithOptions(options);
220 { 222 {
221 // setup IPC channel proxy 223 // setup IPC channel proxy
222 IPC::ChannelProxy chan(kTestClientChannel, IPC::Channel::MODE_SERVER, 224 IPC::ChannelProxy chan(kTestClientChannel, IPC::Channel::MODE_SERVER,
223 &channel_listener, NULL, thread.message_loop()); 225 &channel_listener, NULL, thread.message_loop());
224 226
225 channel_listener.Init(&chan); 227 channel_listener.Init(&chan);
226 228
227 #if defined(OS_WIN) 229 #if defined(OS_WIN)
228 base::ProcessHandle process_handle = SpawnChild(TEST_CLIENT, NULL); 230 base::ProcessHandle process_handle = SpawnChild(TEST_CLIENT, NULL);
229 #elif defined(OS_POSIX) 231 #elif defined(OS_POSIX)
230 bool debug_on_start = CommandLine().HasSwitch(switches::kDebugChildren); 232 bool debug_on_start = CommandLine::ForCurrentProcess()->HasSwitch(
233 switches::kDebugChildren);
231 base::file_handle_mapping_vector fds_to_map; 234 base::file_handle_mapping_vector fds_to_map;
232 int src_fd; 235 int src_fd;
233 int dest_fd; 236 int dest_fd;
234 chan.GetClientFileDescriptorMapping(&src_fd, &dest_fd); 237 chan.GetClientFileDescriptorMapping(&src_fd, &dest_fd);
235 if (src_fd > -1) { 238 if (src_fd > -1) {
236 fds_to_map.push_back(std::pair<int,int>(src_fd, dest_fd)); 239 fds_to_map.push_back(std::pair<int,int>(src_fd, dest_fd));
237 } 240 }
238 241
239 base::ProcessHandle process_handle = MultiProcessTest::SpawnChild( 242 base::ProcessHandle process_handle = MultiProcessTest::SpawnChild(
240 L"RunTestClient", 243 L"RunTestClient",
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 #endif // PERFORMANCE_TEST 438 #endif // PERFORMANCE_TEST
436 439
437 int main(int argc, char** argv) { 440 int main(int argc, char** argv) {
438 #ifdef PERFORMANCE_TEST 441 #ifdef PERFORMANCE_TEST
439 int retval = PerfTestSuite(argc, argv).Run(); 442 int retval = PerfTestSuite(argc, argv).Run();
440 #else 443 #else
441 int retval = TestSuite(argc, argv).Run(); 444 int retval = TestSuite(argc, argv).Run();
442 #endif 445 #endif
443 return retval; 446 return retval;
444 } 447 }
OLDNEW
« no previous file with comments | « chrome/common/ipc_logging.cc ('k') | chrome/common/l10n_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698