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

Side by Side Diff: ipc/ipc_test_base.cc

Issue 23814006: Use base::GlobalDescriptors::kBaseDescriptor instead of magic number 3. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fd
Patch Set: CL for landing Created 7 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 | « chrome/utility/importer/firefox_importer_unittest_utils_mac.cc ('k') | no next file » | 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "ipc/ipc_test_base.h" 7 #include "ipc/ipc_test_base.h"
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/debug_on_start_win.h" 10 #include "base/debug/debug_on_start_win.h"
11 #include "base/process/kill.h" 11 #include "base/process/kill.h"
12 #include "base/threading/thread.h" 12 #include "base/threading/thread.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "ipc/ipc_descriptors.h" 14 #include "ipc/ipc_descriptors.h"
15 #include "ipc/ipc_switches.h" 15 #include "ipc/ipc_switches.h"
16 16
17 #if defined(OS_POSIX)
18 #include "base/posix/global_descriptors.h"
19 #endif
20
17 // static 21 // static
18 std::string IPCTestBase::GetChannelName(const std::string& test_client_name) { 22 std::string IPCTestBase::GetChannelName(const std::string& test_client_name) {
19 DCHECK(!test_client_name.empty()); 23 DCHECK(!test_client_name.empty());
20 return test_client_name + "__Channel"; 24 return test_client_name + "__Channel";
21 } 25 }
22 26
23 IPCTestBase::IPCTestBase() 27 IPCTestBase::IPCTestBase()
24 : client_process_(base::kNullProcessHandle) { 28 : client_process_(base::kNullProcessHandle) {
25 } 29 }
26 30
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 bool debug_on_start = 99 bool debug_on_start =
96 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDebugChildren); 100 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDebugChildren);
97 101
98 #if defined(OS_WIN) 102 #if defined(OS_WIN)
99 client_process_ = MultiProcessTest::SpawnChild(test_main, debug_on_start); 103 client_process_ = MultiProcessTest::SpawnChild(test_main, debug_on_start);
100 #elif defined(OS_POSIX) 104 #elif defined(OS_POSIX)
101 base::FileHandleMappingVector fds_to_map; 105 base::FileHandleMappingVector fds_to_map;
102 const int ipcfd = channel_.get() ? channel_->GetClientFileDescriptor() : 106 const int ipcfd = channel_.get() ? channel_->GetClientFileDescriptor() :
103 channel_proxy_->GetClientFileDescriptor(); 107 channel_proxy_->GetClientFileDescriptor();
104 if (ipcfd > -1) 108 if (ipcfd > -1)
105 fds_to_map.push_back(std::pair<int, int>(ipcfd, kPrimaryIPCChannel + 3)); 109 fds_to_map.push_back(std::pair<int, int>(ipcfd,
110 kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor));
106 111
107 client_process_ = MultiProcessTest::SpawnChild(test_main, 112 client_process_ = MultiProcessTest::SpawnChild(test_main,
108 fds_to_map, 113 fds_to_map,
109 debug_on_start); 114 debug_on_start);
110 #endif 115 #endif
111 116
112 return client_process_ != base::kNullProcessHandle; 117 return client_process_ != base::kNullProcessHandle;
113 } 118 }
114 119
115 bool IPCTestBase::WaitForClientShutdown() { 120 bool IPCTestBase::WaitForClientShutdown() {
116 DCHECK(client_process_ != base::kNullProcessHandle); 121 DCHECK(client_process_ != base::kNullProcessHandle);
117 122
118 bool rv = base::WaitForSingleProcess(client_process_, 123 bool rv = base::WaitForSingleProcess(client_process_,
119 base::TimeDelta::FromSeconds(5)); 124 base::TimeDelta::FromSeconds(5));
120 base::CloseProcessHandle(client_process_); 125 base::CloseProcessHandle(client_process_);
121 client_process_ = base::kNullProcessHandle; 126 client_process_ = base::kNullProcessHandle;
122 return rv; 127 return rv;
123 } 128 }
OLDNEW
« no previous file with comments | « chrome/utility/importer/firefox_importer_unittest_utils_mac.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698