diff options
author | rvargas <rvargas@chromium.org> | 2015-01-23 16:27:25 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-24 00:29:27 +0000 |
commit | 960db8860336db15dbdbe71ebbff318833697f81 (patch) | |
tree | 330c81b9f65a29b3237b55c33e4940cb20afe121 | |
parent | 9ec42b887a697f656b4df721dbde5cd08104af96 (diff) | |
download | chromium_src-960db8860336db15dbdbe71ebbff318833697f81.zip chromium_src-960db8860336db15dbdbe71ebbff318833697f81.tar.gz chromium_src-960db8860336db15dbdbe71ebbff318833697f81.tar.bz2 |
Rename base::Process::pid() to Pid()
The method is not a simple accessor.
BUG=417532
TBR=satorux@chromium.org (chromeos)
TBR=siggi@chromium.org (browser_watcher)
TBR=mseaborn@chromium.org (nacl)
TBR=davidben@chromium.org (content)
TBR=rsesek@chromium.org (sandbox)
TBR=sadrul@chromium.org (ui)
Review URL: https://codereview.chromium.org/864163003
Cr-Commit-Position: refs/heads/master@{#312978}
26 files changed, 47 insertions, 42 deletions
diff --git a/base/process/kill_mac.cc b/base/process/kill_mac.cc index a2632f6..8c42400 100644 --- a/base/process/kill_mac.cc +++ b/base/process/kill_mac.cc @@ -166,7 +166,7 @@ void WaitForChildToDie(pid_t child, int timeout) { } // namespace void EnsureProcessTerminated(Process process) { - WaitForChildToDie(process.pid(), kWaitBeforeKillSeconds); + WaitForChildToDie(process.Pid(), kWaitBeforeKillSeconds); } } // namespace base diff --git a/base/process/kill_posix.cc b/base/process/kill_posix.cc index 9e9b5fb..5e8b61f 100644 --- a/base/process/kill_posix.cc +++ b/base/process/kill_posix.cc @@ -465,11 +465,11 @@ class BackgroundReaper : public PlatformThread::Delegate { void EnsureProcessTerminated(Process process) { // If the child is already dead, then there's nothing to do. - if (IsChildDead(process.pid())) + if (IsChildDead(process.Pid())) return; const unsigned timeout = 2; // seconds - BackgroundReaper* reaper = new BackgroundReaper(process.pid(), timeout); + BackgroundReaper* reaper = new BackgroundReaper(process.Pid(), timeout); PlatformThread::CreateNonJoinable(0, reaper); } diff --git a/base/process/process.h b/base/process/process.h index c85a248..70aca6d 100644 --- a/base/process/process.h +++ b/base/process/process.h @@ -80,7 +80,7 @@ class BASE_EXPORT Process { Process Duplicate() const; // Get the PID for this process. - ProcessId pid() const; + ProcessId Pid() const; // Returns true if this process is the current process. bool is_current() const; diff --git a/base/process/process_posix.cc b/base/process/process_posix.cc index 93dec98..5d7007c 100644 --- a/base/process/process_posix.cc +++ b/base/process/process_posix.cc @@ -75,7 +75,7 @@ Process Process::Duplicate() const { return Process(process_); } -ProcessId Process::pid() const { +ProcessId Process::Pid() const { DCHECK(IsValid()); return GetProcId(process_); } diff --git a/base/process/process_unittest.cc b/base/process/process_unittest.cc index 1a2af50..4ea7a5e 100644 --- a/base/process/process_unittest.cc +++ b/base/process/process_unittest.cc @@ -68,7 +68,7 @@ TEST_F(ProcessTest, Duplicate) { Process process2 = process1.Duplicate(); ASSERT_TRUE(process1.IsValid()); ASSERT_TRUE(process2.IsValid()); - EXPECT_EQ(process1.pid(), process2.pid()); + EXPECT_EQ(process1.Pid(), process2.Pid()); EXPECT_FALSE(process1.is_current()); EXPECT_FALSE(process2.is_current()); @@ -83,7 +83,7 @@ TEST_F(ProcessTest, DuplicateCurrent) { Process process2 = process1.Duplicate(); ASSERT_TRUE(process1.IsValid()); ASSERT_TRUE(process2.IsValid()); - EXPECT_EQ(process1.pid(), process2.pid()); + EXPECT_EQ(process1.Pid(), process2.Pid()); EXPECT_TRUE(process1.is_current()); EXPECT_TRUE(process2.is_current()); @@ -98,7 +98,7 @@ TEST_F(ProcessTest, DeprecatedGetProcessFromHandle) { Process process2 = Process::DeprecatedGetProcessFromHandle(process1.Handle()); ASSERT_TRUE(process1.IsValid()); ASSERT_TRUE(process2.IsValid()); - EXPECT_EQ(process1.pid(), process2.pid()); + EXPECT_EQ(process1.Pid(), process2.Pid()); EXPECT_FALSE(process1.is_current()); EXPECT_FALSE(process2.is_current()); diff --git a/base/process/process_util_unittest.cc b/base/process/process_util_unittest.cc index 88b4af3..33cf00f 100644 --- a/base/process/process_util_unittest.cc +++ b/base/process/process_util_unittest.cc @@ -201,7 +201,7 @@ TEST_F(ProcessUtilTest, GetProcId) { EXPECT_NE(0ul, id1); base::Process process = SpawnChild("SimpleChildProcess"); ASSERT_TRUE(process.IsValid()); - base::ProcessId id2 = process.pid(); + base::ProcessId id2 = process.Pid(); EXPECT_NE(0ul, id2); EXPECT_NE(id1, id2); } diff --git a/base/process/process_win.cc b/base/process/process_win.cc index c311c99..0107015 100644 --- a/base/process/process_win.cc +++ b/base/process/process_win.cc @@ -100,7 +100,7 @@ Process Process::Duplicate() const { return Process(out_handle); } -ProcessId Process::pid() const { +ProcessId Process::Pid() const { DCHECK(IsValid()); return GetProcId(Handle()); } diff --git a/chrome/browser/chromeos/system/input_device_settings_impl_x11.cc b/chrome/browser/chromeos/system/input_device_settings_impl_x11.cc index a4c05e4..aa41497a 100644 --- a/chrome/browser/chromeos/system/input_device_settings_impl_x11.cc +++ b/chrome/browser/chromeos/system/input_device_settings_impl_x11.cc @@ -58,7 +58,7 @@ void ExecuteScriptOnFileThread(const std::vector<std::string>& argv) { base::Process process = base::LaunchProcess(base::CommandLine(argv), base::LaunchOptions()); if (process.IsValid()) - base::EnsureProcessGetsReaped(process.pid()); + base::EnsureProcessGetsReaped(process.Pid()); } void ExecuteScript(const std::vector<std::string>& argv) { diff --git a/chrome/browser/chromeos/system_logs/debug_log_writer.cc b/chrome/browser/chromeos/system_logs/debug_log_writer.cc index 3c31f6e..1c2b089 100644 --- a/chrome/browser/chromeos/system_logs/debug_log_writer.cc +++ b/chrome/browser/chromeos/system_logs/debug_log_writer.cc @@ -99,7 +99,7 @@ void RunCommand(const std::vector<std::string>& argv, int exit_code = 0; if (!process.WaitForExit(&exit_code)) { - LOG(ERROR) << "Can't get exit code for pid " << process.pid(); + LOG(ERROR) << "Can't get exit code for pid " << process.Pid(); if (!callback.is_null()) callback.Run(false); diff --git a/chrome/browser/platform_util_linux.cc b/chrome/browser/platform_util_linux.cc index 4314762..c94f8fe 100644 --- a/chrome/browser/platform_util_linux.cc +++ b/chrome/browser/platform_util_linux.cc @@ -39,7 +39,7 @@ void XDGUtil(const std::string& util, const std::string& arg) { base::Process process = base::LaunchProcess(argv, options); if (process.IsValid()) - base::EnsureProcessGetsReaped(process.pid()); + base::EnsureProcessGetsReaped(process.Pid()); } void XDGOpen(const std::string& path) { diff --git a/chrome/browser/printing/printer_manager_dialog_linux.cc b/chrome/browser/printing/printer_manager_dialog_linux.cc index 998ea5a..8513fa7 100644 --- a/chrome/browser/printing/printer_manager_dialog_linux.cc +++ b/chrome/browser/printing/printer_manager_dialog_linux.cc @@ -54,7 +54,7 @@ void DetectAndOpenPrinterConfigDialog() { LOG(ERROR) << "Failed to open printer manager dialog "; return; } - base::EnsureProcessGetsReaped(process.pid()); + base::EnsureProcessGetsReaped(process.Pid()); } } // anonymous namespace diff --git a/chrome/browser/printing/printing_layout_browsertest.cc b/chrome/browser/printing/printing_layout_browsertest.cc index 277c507..c38d6b1 100644 --- a/chrome/browser/printing/printing_layout_browsertest.cc +++ b/chrome/browser/printing/printing_layout_browsertest.cc @@ -8,7 +8,7 @@ #include "base/files/file_util.h" #include "base/message_loop/message_loop.h" #include "base/path_service.h" -#include "base/process/process.h" +#include "base/process/process_handle.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "base/test/test_file_util.h" @@ -296,7 +296,7 @@ bool CloseDialogWindow(HWND dialog_window) { class DismissTheWindow : public base::DelegateSimpleThread::Delegate { public: DismissTheWindow() - : owner_process_(base::Process::Current().pid()) { + : owner_process_(base::GetCurrentProcId()) { } virtual void Run() { diff --git a/chrome/browser/process_info_snapshot_mac_unittest.cc b/chrome/browser/process_info_snapshot_mac_unittest.cc index fe8c338b..51d212d 100644 --- a/chrome/browser/process_info_snapshot_mac_unittest.cc +++ b/chrome/browser/process_info_snapshot_mac_unittest.cc @@ -132,12 +132,12 @@ TEST_F(ProcessInfoSnapshotMacTest, EffectiveVsRealUserIDTest) { PCHECK(HANDLE_EINTR(read(fds[0], buf, 1)) == 1); std::vector<base::ProcessId> pid_list; - pid_list.push_back(process.pid()); + pid_list.push_back(process.Pid()); ProcessInfoSnapshot snapshot; ASSERT_TRUE(snapshot.Sample(pid_list)); ProcessInfoSnapshot::ProcInfoEntry proc_info; - ASSERT_TRUE(snapshot.GetProcInfo(process.pid(), &proc_info)); + ASSERT_TRUE(snapshot.GetProcInfo(process.Pid(), &proc_info)); // Effective user ID should be 0 (root). EXPECT_EQ(proc_info.euid, 0u); // Real user ID should match the calling process's user id. diff --git a/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc b/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc index 27d0c77..5dd215a 100644 --- a/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc +++ b/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc @@ -321,7 +321,7 @@ IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, MAYBE_Backgrounding) { GURL page2("data:text/html,hello world2"); base::Process process2 = ShowSingletonTab(page2); ASSERT_TRUE(process2.IsValid()); - EXPECT_NE(process1.pid(), process2.pid()); + EXPECT_NE(process1.Pid(), process2.Pid()); EXPECT_TRUE(process1.IsProcessBackgrounded()); EXPECT_FALSE(process2.IsProcessBackgrounded()); @@ -330,15 +330,15 @@ IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, MAYBE_Backgrounding) { GURL page3("data:text/html,hello world3"); base::Process process3 = OpenBackgroundTab(page3); ASSERT_TRUE(process3.IsValid()); - EXPECT_NE(process3.pid(), process1.pid()); - EXPECT_NE(process3.pid(), process2.pid()); + EXPECT_NE(process3.Pid(), process1.Pid()); + EXPECT_NE(process3.Pid(), process2.Pid()); EXPECT_TRUE(process1.IsProcessBackgrounded()); EXPECT_FALSE(process2.IsProcessBackgrounded()); EXPECT_TRUE(process3.IsProcessBackgrounded()); // Navigate back to the first page. Its renderer should be in foreground // again while the other renderers should be backgrounded. - EXPECT_EQ(process1.pid(), ShowSingletonTab(page1).pid()); + EXPECT_EQ(process1.Pid(), ShowSingletonTab(page1).Pid()); EXPECT_FALSE(process1.IsProcessBackgrounded()); EXPECT_TRUE(process2.IsProcessBackgrounded()); EXPECT_TRUE(process3.IsProcessBackgrounded()); diff --git a/chrome/browser/ui/webui/options/advanced_options_utils_linux.cc b/chrome/browser/ui/webui/options/advanced_options_utils_linux.cc index cda35a1f..6c7f5bbf 100644 --- a/chrome/browser/ui/webui/options/advanced_options_utils_linux.cc +++ b/chrome/browser/ui/webui/options/advanced_options_utils_linux.cc @@ -97,7 +97,7 @@ bool StartProxyConfigUtil(const char* command[]) { LOG(ERROR) << "StartProxyConfigUtil failed to start " << command[0]; return false; } - base::EnsureProcessGetsReaped(process.pid()); + base::EnsureProcessGetsReaped(process.Pid()); return true; } diff --git a/chrome/service/cloud_print/cloud_print_proxy.cc b/chrome/service/cloud_print/cloud_print_proxy.cc index ae56186..a98fecb 100644 --- a/chrome/service/cloud_print/cloud_print_proxy.cc +++ b/chrome/service/cloud_print/cloud_print_proxy.cc @@ -45,7 +45,7 @@ void LaunchBrowserProcessWithSwitch(const std::string& switch_string) { #if defined(OS_POSIX) && !defined(OS_MACOSX) base::Process process = base::LaunchProcess(cmd_line, base::LaunchOptions()); if (process.IsValid()) - base::EnsureProcessGetsReaped(process.pid()); + base::EnsureProcessGetsReaped(process.Pid()); #else base::LaunchOptions launch_options; #if defined(OS_WIN) diff --git a/chromeos/process_proxy/process_proxy.cc b/chromeos/process_proxy/process_proxy.cc index 8fd976b..8a97acb 100644 --- a/chromeos/process_proxy/process_proxy.cc +++ b/chromeos/process_proxy/process_proxy.cc @@ -237,7 +237,7 @@ bool ProcessProxy::LaunchProcess(const std::string& command, int slave_fd, // TODO(rvargas) crbug/417532: This is somewhat wrong but the interface of // Open vends pid_t* so ownership is quite vague anyway, and Process::Close // doesn't do much in POSIX. - *pid = process.pid(); + *pid = process.Pid(); return process.IsValid(); } diff --git a/components/browser_watcher/exit_code_watcher_win.cc b/components/browser_watcher/exit_code_watcher_win.cc index 218978c..0e23184 100644 --- a/components/browser_watcher/exit_code_watcher_win.cc +++ b/components/browser_watcher/exit_code_watcher_win.cc @@ -30,7 +30,12 @@ ExitCodeWatcher::~ExitCodeWatcher() { } bool ExitCodeWatcher::Initialize(base::Process process) { - DWORD process_pid = process.pid(); + if (!process.IsValid()) { + LOG(ERROR) << "Invalid parent handle, can't get parent process ID."; + return false; + } + + DWORD process_pid = process.Pid(); if (process_pid == 0) { LOG(ERROR) << "Invalid parent handle, can't get parent process ID."; return false; @@ -44,7 +49,7 @@ bool ExitCodeWatcher::Initialize(base::Process process) { return false; } - // Success, take ownership of the process handle. + // Success, take ownership of the process. process_ = process.Pass(); process_creation_time_ = base::Time::FromFileTime(creation_time); @@ -68,7 +73,7 @@ bool ExitCodeWatcher::WriteProcessExitCode(int exit_code) { registry_path_.c_str(), KEY_WRITE); base::string16 value_name( - GetValueName(process_creation_time_, process_.pid())); + GetValueName(process_creation_time_, process_.Pid())); ULONG result = key.WriteValue(value_name.c_str(), exit_code); if (result != ERROR_SUCCESS) { diff --git a/components/browser_watcher/exit_code_watcher_win_unittest.cc b/components/browser_watcher/exit_code_watcher_win_unittest.cc index c4410fb..a5ba333 100644 --- a/components/browser_watcher/exit_code_watcher_win_unittest.cc +++ b/components/browser_watcher/exit_code_watcher_win_unittest.cc @@ -169,7 +169,7 @@ TEST_F(ExitCodeWatcherTest, ExitCodeWatcherOnExitedProcess) { EXPECT_TRUE(watcher.Initialize(sleeper.process().Duplicate())); // Verify that the watcher wrote a sentinel for the process. - VerifyWroteExitCode(sleeper.process().pid(), STILL_ACTIVE); + VerifyWroteExitCode(sleeper.process().Pid(), STILL_ACTIVE); // Kill the sleeper, and make sure it's exited before we continue. ASSERT_NO_FATAL_FAILURE(sleeper.Kill(kExitCode, true)); @@ -177,7 +177,7 @@ TEST_F(ExitCodeWatcherTest, ExitCodeWatcherOnExitedProcess) { watcher.WaitForExit(); EXPECT_EQ(kExitCode, watcher.exit_code()); - VerifyWroteExitCode(sleeper.process().pid(), kExitCode); + VerifyWroteExitCode(sleeper.process().Pid(), kExitCode); } } // namespace browser_watcher diff --git a/components/nacl/common/nacl_debug_exception_handler_win.cc b/components/nacl/common/nacl_debug_exception_handler_win.cc index f8efafc..7c1e9c0 100644 --- a/components/nacl/common/nacl_debug_exception_handler_win.cc +++ b/components/nacl/common/nacl_debug_exception_handler_win.cc @@ -30,7 +30,7 @@ class DebugExceptionHandler : public base::PlatformThread::Delegate { // NaClDebugExceptionHandlerRun() receives debug events for the // process. bool attached = false; - int pid = nacl_process_.pid(); + int pid = nacl_process_.Pid(); if (nacl_process_.IsValid()) { DCHECK(pid); if (!DebugActiveProcess(pid)) { diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc index 0599ffe..fbc1a55 100644 --- a/content/browser/child_process_launcher.cc +++ b/content/browser/child_process_launcher.cc @@ -440,7 +440,7 @@ void ChildProcessLauncher::Context::LaunchInternal( } if (process.IsValid()) - broker->AddPlaceholderForPid(process.pid(), child_process_id); + broker->AddPlaceholderForPid(process.Pid(), child_process_id); // After updating the broker, release the lock and let the child's // messasge be processed on the broker's thread. diff --git a/content/browser/zygote_host/zygote_host_impl_linux.cc b/content/browser/zygote_host/zygote_host_impl_linux.cc index 2a2339b..f9e69a2 100644 --- a/content/browser/zygote_host/zygote_host_impl_linux.cc +++ b/content/browser/zygote_host/zygote_host_impl_linux.cc @@ -187,15 +187,15 @@ void ZygoteHostImpl::Init(const std::string& sandbox_cmd) { fds[0], kZygoteHelloMessage, sizeof(kZygoteHelloMessage), &pid_)); CHECK_GT(pid_, 1); - if (process.pid() != pid_) { + if (process.Pid() != pid_) { // Reap the sandbox. - base::EnsureProcessGetsReaped(process.pid()); + base::EnsureProcessGetsReaped(process.Pid()); } } else { // Not using the SUID sandbox. // Note that ~base::Process() will reset the internal value, but there's no // real "handle" on POSIX so that is safe. - pid_ = process.pid(); + pid_ = process.Pid(); } close(fds[1]); @@ -481,7 +481,7 @@ void ZygoteHostImpl::AdjustRendererOOMScore(base::ProcessHandle pid, sandbox_helper_process = base::LaunchProcess(adj_oom_score_cmdline, options); if (sandbox_helper_process.IsValid()) - base::EnsureProcessGetsReaped(sandbox_helper_process.pid()); + base::EnsureProcessGetsReaped(sandbox_helper_process.Pid()); } else if (!using_suid_sandbox_) { if (!base::AdjustOOMScore(pid, score)) PLOG(ERROR) << "Failed to adjust OOM score of renderer with pid " << pid; diff --git a/content/public/browser/browser_message_filter.h b/content/public/browser/browser_message_filter.h index 00cff67..1966e58 100644 --- a/content/public/browser/browser_message_filter.h +++ b/content/public/browser/browser_message_filter.h @@ -81,7 +81,7 @@ class CONTENT_EXPORT BrowserMessageFilter base::ProcessHandle PeerHandle(); // Can be called on any thread, after OnChannelConnected is called. - base::ProcessId peer_pid() const { return peer_process_.pid(); } + base::ProcessId peer_pid() const { return peer_process_.Pid(); } void set_peer_process_for_testing(base::Process peer_process) { peer_process_ = peer_process.Pass(); diff --git a/sandbox/mac/bootstrap_sandbox_unittest.mm b/sandbox/mac/bootstrap_sandbox_unittest.mm index bd788bd..7e5e8b6 100644 --- a/sandbox/mac/bootstrap_sandbox_unittest.mm +++ b/sandbox/mac/bootstrap_sandbox_unittest.mm @@ -107,7 +107,7 @@ class BootstrapSandboxTest : public base::MultiProcessTest { EXPECT_TRUE(process.WaitForExit(&code)); EXPECT_EQ(0, code); if (out_pid) - *out_pid = process.pid(); + *out_pid = process.Pid(); } protected: @@ -129,7 +129,7 @@ TEST_F(BootstrapSandboxTest, DistributedNotifications_Unsandboxed) { [observer waitForNotification]; EXPECT_EQ(1, [observer receivedCount]); - EXPECT_EQ(process.pid(), [[observer object] intValue]); + EXPECT_EQ(process.Pid(), [[observer object] intValue]); } // Run the test with the sandbox enabled without notifications on the policy diff --git a/sandbox/mac/xpc_message_server_unittest.cc b/sandbox/mac/xpc_message_server_unittest.cc index b9f90562..91975ba 100644 --- a/sandbox/mac/xpc_message_server_unittest.cc +++ b/sandbox/mac/xpc_message_server_unittest.cc @@ -159,8 +159,8 @@ XPC_TEST_F(GetSenderPID) // { ASSERT_TRUE(child.WaitForExit(&exit_code)); EXPECT_EQ(0, exit_code); - EXPECT_EQ(child.pid(), sender_pid); - EXPECT_EQ(child.pid(), child_pid); + EXPECT_EQ(child.Pid(), sender_pid); + EXPECT_EQ(child.Pid(), child_pid); EXPECT_EQ(sender_pid, child_pid); } diff --git a/ui/base/ime/chromeos/ime_keyboard_x11.cc b/ui/base/ime/chromeos/ime_keyboard_x11.cc index 95c03bd..8b76ed0 100644 --- a/ui/base/ime/chromeos/ime_keyboard_x11.cc +++ b/ui/base/ime/chromeos/ime_keyboard_x11.cc @@ -173,7 +173,7 @@ void ImeKeyboardX11::MaybeExecuteSetLayoutCommand() { PollUntilChildFinish(process.Handle()); DVLOG(1) << "ExecuteSetLayoutCommand: " << layout_to_set - << ": pid=" << process.pid(); + << ": pid=" << process.Pid(); } // Delay and loop until child process finishes and call the callback. |