зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1414631 - Remove the Chromium Process class r=jld
MozReview-Commit-ID: B5NmJPQhGYm --HG-- extra : rebase_source : 686a0877def17a2d79b33f912f20ccbd7228a4cf
This commit is contained in:
Родитель
6816c396dc
Коммит
79a24b6820
|
@ -43,7 +43,6 @@ if os_win:
|
|||
'src/base/platform_file_win.cc',
|
||||
'src/base/platform_thread_win.cc',
|
||||
'src/base/process_util_win.cc',
|
||||
'src/base/process_win.cc',
|
||||
'src/base/rand_util_win.cc',
|
||||
'src/base/shared_memory_win.cc',
|
||||
'src/base/sys_info_win.cc',
|
||||
|
@ -70,7 +69,6 @@ if os_posix:
|
|||
'src/base/message_pump_libevent.cc',
|
||||
'src/base/platform_file_posix.cc',
|
||||
'src/base/platform_thread_posix.cc',
|
||||
'src/base/process_posix.cc',
|
||||
'src/base/process_util_posix.cc',
|
||||
'src/base/rand_util_posix.cc',
|
||||
'src/base/shared_memory_posix.cc',
|
||||
|
|
|
@ -28,54 +28,6 @@ typedef pid_t ProcessHandle;
|
|||
typedef pid_t ProcessId;
|
||||
#endif
|
||||
|
||||
class Process {
|
||||
public:
|
||||
Process() : process_(0), last_working_set_size_(0) {}
|
||||
explicit Process(ProcessHandle aHandle) :
|
||||
process_(aHandle), last_working_set_size_(0) {}
|
||||
|
||||
// A handle to the current process.
|
||||
static Process Current();
|
||||
|
||||
// Get/Set the handle for this process. The handle will be 0 if the process
|
||||
// is no longer running.
|
||||
ProcessHandle handle() const { return process_; }
|
||||
void set_handle(ProcessHandle aHandle) { process_ = aHandle; }
|
||||
|
||||
// Get the PID for this process.
|
||||
ProcessId pid() const;
|
||||
|
||||
// Is the this process the current process.
|
||||
bool is_current() const;
|
||||
|
||||
// Close the process handle. This will not terminate the process.
|
||||
void Close();
|
||||
|
||||
// Terminates the process with extreme prejudice. The given result code will
|
||||
// be the exit code of the process. If the process has already exited, this
|
||||
// will do nothing.
|
||||
void Terminate(int result_code);
|
||||
|
||||
// A process is backgrounded when it's priority is lower than normal.
|
||||
// Return true if this process is backgrounded, false otherwise.
|
||||
bool IsProcessBackgrounded() const;
|
||||
|
||||
// Set a prcess as backgrounded. If value is true, the priority
|
||||
// of the process will be lowered. If value is false, the priority
|
||||
// of the process will be made "normal" - equivalent to default
|
||||
// process priority.
|
||||
// Returns true if the priority was changed, false otherwise.
|
||||
bool SetProcessBackgrounded(bool value);
|
||||
|
||||
// Releases as much of the working set back to the OS as possible.
|
||||
// Returns true if successful, false otherwise.
|
||||
bool EmptyWorkingSet();
|
||||
|
||||
private:
|
||||
ProcessHandle process_;
|
||||
size_t last_working_set_size_;
|
||||
};
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // BASE_PROCESS_H_
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
// Copyright (c) 2008 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "base/process.h"
|
||||
#include "base/process_util.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
void Process::Close() {
|
||||
process_ = 0;
|
||||
// if the process wasn't termiated (so we waited) or the state
|
||||
// wasn't already collected w/ a wait from process_utils, we're gonna
|
||||
// end up w/ a zombie when it does finally exit.
|
||||
}
|
||||
|
||||
void Process::Terminate(int result_code) {
|
||||
// result_code isn't supportable.
|
||||
if (!process_)
|
||||
return;
|
||||
// We don't wait here. It's the responsibility of other code to reap the
|
||||
// child.
|
||||
KillProcess(process_, result_code, false);
|
||||
}
|
||||
|
||||
bool Process::IsProcessBackgrounded() const {
|
||||
// http://code.google.com/p/chromium/issues/detail?id=8083
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Process::SetProcessBackgrounded(bool value) {
|
||||
// http://code.google.com/p/chromium/issues/detail?id=8083
|
||||
// Just say we did it to keep renderer happy at the moment. Need to finish
|
||||
// cleaning this up w/in higher layers since windows is probably the only
|
||||
// one that can raise priorities w/o privileges.
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Process::EmptyWorkingSet() {
|
||||
// http://code.google.com/p/chromium/issues/detail?id=8083
|
||||
return false;
|
||||
}
|
||||
|
||||
ProcessId Process::pid() const {
|
||||
if (process_ == 0)
|
||||
return 0;
|
||||
|
||||
return GetProcId(process_);
|
||||
}
|
||||
|
||||
bool Process::is_current() const {
|
||||
return process_ == GetCurrentProcessHandle();
|
||||
}
|
||||
|
||||
// static
|
||||
Process Process::Current() {
|
||||
return Process(GetCurrentProcessHandle());
|
||||
}
|
||||
|
||||
} // namspace base
|
|
@ -1,64 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "base/process.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/process_util.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
void Process::Close() {
|
||||
if (!process_)
|
||||
return;
|
||||
CloseProcessHandle(process_);
|
||||
process_ = NULL;
|
||||
}
|
||||
|
||||
void Process::Terminate(int result_code) {
|
||||
if (!process_)
|
||||
return;
|
||||
::TerminateProcess(process_, result_code);
|
||||
}
|
||||
|
||||
bool Process::IsProcessBackgrounded() const {
|
||||
DCHECK(process_);
|
||||
DWORD priority = GetPriorityClass(process_);
|
||||
if (priority == 0)
|
||||
return false; // Failure case.
|
||||
return priority == BELOW_NORMAL_PRIORITY_CLASS;
|
||||
}
|
||||
|
||||
bool Process::SetProcessBackgrounded(bool value) {
|
||||
DCHECK(process_);
|
||||
DWORD priority = value ? BELOW_NORMAL_PRIORITY_CLASS : NORMAL_PRIORITY_CLASS;
|
||||
return (SetPriorityClass(process_, priority) != 0);
|
||||
}
|
||||
|
||||
bool Process::EmptyWorkingSet() {
|
||||
if (!process_)
|
||||
return false;
|
||||
|
||||
BOOL rv = SetProcessWorkingSetSize(process_, -1, -1);
|
||||
return rv == TRUE;
|
||||
}
|
||||
|
||||
ProcessId Process::pid() const {
|
||||
if (process_ == 0)
|
||||
return 0;
|
||||
|
||||
return GetProcId(process_);
|
||||
}
|
||||
|
||||
bool Process::is_current() const {
|
||||
return process_ == GetCurrentProcess();
|
||||
}
|
||||
|
||||
// static
|
||||
Process Process::Current() {
|
||||
return Process(GetCurrentProcess());
|
||||
}
|
||||
|
||||
} // namespace base
|
|
@ -628,7 +628,7 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector<std::string>& aExt
|
|||
// send the child the PID so that it can open a ProcessHandle back to us.
|
||||
// probably don't want to do this in the long run
|
||||
char pidstring[32];
|
||||
SprintfLiteral(pidstring,"%d", base::Process::Current().pid());
|
||||
SprintfLiteral(pidstring, "%d", base::GetCurrentProcId());
|
||||
|
||||
const char* const childProcessType =
|
||||
XRE_ChildProcessTypeToString(mProcessType);
|
||||
|
|
Загрузка…
Ссылка в новой задаче