зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1277705
- Remove child_process_info (r=dvander)
This commit is contained in:
Родитель
4045bfae0a
Коммит
db00162c58
|
@ -27,7 +27,6 @@ UNIFIED_SOURCES += [
|
|||
'src/base/timer.cc',
|
||||
'src/chrome/common/child_process.cc',
|
||||
'src/chrome/common/child_process_host.cc',
|
||||
'src/chrome/common/child_process_info.cc',
|
||||
'src/chrome/common/child_thread.cc',
|
||||
'src/chrome/common/chrome_switches.cc',
|
||||
'src/chrome/common/ipc_channel.cc',
|
||||
|
|
|
@ -21,10 +21,8 @@ typedef mozilla::ipc::BrowserProcessSubThread ChromeThread;
|
|||
|
||||
using mozilla::ipc::FileDescriptor;
|
||||
|
||||
ChildProcessHost::ChildProcessHost(ProcessType type)
|
||||
:
|
||||
ChildProcessInfo(type),
|
||||
ALLOW_THIS_IN_INITIALIZER_LIST(listener_(this)),
|
||||
ChildProcessHost::ChildProcessHost()
|
||||
: ALLOW_THIS_IN_INITIALIZER_LIST(listener_(this)),
|
||||
opening_channel_(false) {
|
||||
}
|
||||
|
||||
|
@ -60,13 +58,6 @@ bool ChildProcessHost::CreateChannel(FileDescriptor& aFileDescriptor) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void ChildProcessHost::SetHandle(base::ProcessHandle process) {
|
||||
#if defined(OS_WIN)
|
||||
DCHECK(!handle());
|
||||
set_handle(process);
|
||||
#endif
|
||||
}
|
||||
|
||||
ChildProcessHost::ListenerHook::ListenerHook(ChildProcessHost* host)
|
||||
: host_(host) {
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include <list>
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "chrome/common/child_process_info.h"
|
||||
#include "chrome/common/ipc_channel.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
|
@ -24,14 +23,12 @@ class FileDescriptor;
|
|||
|
||||
// Plugins/workers and other child processes that live on the IO thread should
|
||||
// derive from this class.
|
||||
class ChildProcessHost :
|
||||
public ChildProcessInfo,
|
||||
public IPC::Channel::Listener {
|
||||
class ChildProcessHost : public IPC::Channel::Listener {
|
||||
public:
|
||||
virtual ~ChildProcessHost();
|
||||
|
||||
protected:
|
||||
explicit ChildProcessHost(ProcessType type);
|
||||
explicit ChildProcessHost();
|
||||
|
||||
// Derived classes return true if it's ok to shut down the child process.
|
||||
virtual bool CanShutdown() = 0;
|
||||
|
@ -41,10 +38,6 @@ class ChildProcessHost :
|
|||
|
||||
bool CreateChannel(mozilla::ipc::FileDescriptor& aFileDescriptor);
|
||||
|
||||
// Once the subclass gets a handle to the process, it needs to tell
|
||||
// ChildProcessHost using this function.
|
||||
void SetHandle(base::ProcessHandle handle);
|
||||
|
||||
// IPC::Channel::Listener implementation:
|
||||
virtual void OnMessageReceived(IPC::Message&& msg) { }
|
||||
virtual void OnChannelConnected(int32_t peer_pid) { }
|
||||
|
|
|
@ -1,46 +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) 2009 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 "chrome/common/child_process_info.h"
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include "base/logging.h"
|
||||
|
||||
std::wstring ChildProcessInfo::GetTypeNameInEnglish(
|
||||
ChildProcessInfo::ProcessType type) {
|
||||
switch (type) {
|
||||
case BROWSER_PROCESS:
|
||||
return L"Browser";
|
||||
case RENDER_PROCESS:
|
||||
return L"Tab";
|
||||
case PLUGIN_PROCESS:
|
||||
return L"Plug-in";
|
||||
case WORKER_PROCESS:
|
||||
return L"Web Worker";
|
||||
case UNKNOWN_PROCESS:
|
||||
default:
|
||||
DCHECK(false) << "Unknown child process type!";
|
||||
return L"Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring ChildProcessInfo::GetLocalizedTitle() const {
|
||||
return name_;
|
||||
}
|
||||
|
||||
ChildProcessInfo::ChildProcessInfo(ProcessType type) {
|
||||
// This constructor is only used by objects which derive from this class,
|
||||
// which means *this* is a real object that refers to a child process, and not
|
||||
// just a simple object that contains information about it. So add it to our
|
||||
// list of running processes.
|
||||
type_ = type;
|
||||
pid_ = -1;
|
||||
}
|
||||
|
||||
|
||||
ChildProcessInfo::~ChildProcessInfo() {
|
||||
}
|
|
@ -1,103 +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) 2009 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.
|
||||
|
||||
#ifndef CHROME_COMMON_CHILD_PROCESS_INFO_H_
|
||||
#define CHROME_COMMON_CHILD_PROCESS_INFO_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/process.h"
|
||||
|
||||
// Holds information about a child process.
|
||||
class ChildProcessInfo {
|
||||
public:
|
||||
enum ProcessType {
|
||||
BROWSER_PROCESS,
|
||||
RENDER_PROCESS,
|
||||
PLUGIN_PROCESS,
|
||||
WORKER_PROCESS,
|
||||
UNKNOWN_PROCESS
|
||||
};
|
||||
|
||||
// Returns the type of the process.
|
||||
ProcessType type() const { return type_; }
|
||||
|
||||
// Returns the name of the process. i.e. for plugins it might be Flash, while
|
||||
// for workers it might be the domain that it's from.
|
||||
std::wstring name() const { return name_; }
|
||||
|
||||
// Getter to the process handle.
|
||||
base::ProcessHandle handle() const { return process_.handle(); }
|
||||
|
||||
virtual int GetProcessId() const {
|
||||
if (pid_ != -1)
|
||||
return pid_;
|
||||
|
||||
pid_ = process_.pid();
|
||||
return pid_;
|
||||
}
|
||||
void SetProcessBackgrounded() const { process_.SetProcessBackgrounded(true); }
|
||||
|
||||
// Returns an English name of the process type, should only be used for non
|
||||
// user-visible strings, or debugging pages like about:memory.
|
||||
static std::wstring GetTypeNameInEnglish(ProcessType type);
|
||||
|
||||
// Returns a localized title for the child process. For example, a plugin
|
||||
// process would be "Plug-in: Flash" when name is "Flash".
|
||||
std::wstring GetLocalizedTitle() const;
|
||||
|
||||
ChildProcessInfo(const ChildProcessInfo& original) {
|
||||
type_ = original.type_;
|
||||
name_ = original.name_;
|
||||
process_ = original.process_;
|
||||
pid_ = original.pid_;
|
||||
}
|
||||
|
||||
ChildProcessInfo& operator=(const ChildProcessInfo& original) {
|
||||
if (&original != this) {
|
||||
type_ = original.type_;
|
||||
name_ = original.name_;
|
||||
process_ = original.process_;
|
||||
pid_ = original.pid_;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
virtual ~ChildProcessInfo();
|
||||
|
||||
// We define the < operator so that the ChildProcessInfo can be used as a key
|
||||
// in a std::map.
|
||||
bool operator <(const ChildProcessInfo& rhs) const {
|
||||
if (process_.handle() != rhs.process_.handle())
|
||||
return process_ .handle() < rhs.process_.handle();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator ==(const ChildProcessInfo& rhs) const {
|
||||
return process_.handle() == rhs.process_.handle();
|
||||
}
|
||||
|
||||
protected:
|
||||
void set_type(ProcessType aType) { type_ = aType; }
|
||||
void set_name(const std::wstring& aName) { name_ = aName; }
|
||||
void set_handle(base::ProcessHandle aHandle) {
|
||||
process_.set_handle(aHandle);
|
||||
pid_ = -1;
|
||||
}
|
||||
|
||||
// Derived objects need to use this constructor so we know what type we are.
|
||||
explicit ChildProcessInfo(ProcessType type);
|
||||
|
||||
private:
|
||||
ProcessType type_;
|
||||
std::wstring name_;
|
||||
mutable int pid_; // Cache of the process id.
|
||||
|
||||
// The handle to the process.
|
||||
mutable base::Process process_;
|
||||
};
|
||||
|
||||
#endif // CHROME_COMMON_CHILD_PROCESS_INFO_H_
|
|
@ -93,8 +93,7 @@ GeckoChildProcessHost::DefaultChildPrivileges()
|
|||
|
||||
GeckoChildProcessHost::GeckoChildProcessHost(GeckoProcessType aProcessType,
|
||||
ChildPrivileges aPrivileges)
|
||||
: ChildProcessHost(RENDER_PROCESS), // FIXME/cjones: we should own this enum
|
||||
mProcessType(aProcessType),
|
||||
: mProcessType(aProcessType),
|
||||
mPrivileges(aPrivileges),
|
||||
mMonitor("mozilla.ipc.GeckChildProcessHost.mMonitor"),
|
||||
mProcessState(CREATING_CHANNEL),
|
||||
|
@ -1138,7 +1137,6 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector<std::string>& aExt
|
|||
// NB: on OS X, we block much longer than we need to in order to
|
||||
// reach this call, waiting for the child process's task_t. The
|
||||
// best way to fix that is to refactor this file, hard.
|
||||
SetHandle(process);
|
||||
#if defined(MOZ_WIDGET_COCOA)
|
||||
mChildTask = child_task;
|
||||
#endif
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
|
||||
#include "base/eintr_wrapper.h"
|
||||
|
||||
#include "chrome/common/child_process_info.h"
|
||||
|
||||
#include "mozilla/ipc/Transport.h"
|
||||
#include "mozilla/ipc/FileDescriptor.h"
|
||||
#include "ProtocolUtils.h"
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "base/message_loop.h"
|
||||
#include "chrome/common/child_process_info.h"
|
||||
|
||||
#include "mozilla/ipc/Transport.h"
|
||||
#include "mozilla/ipc/ProtocolUtils.h"
|
||||
|
|
Загрузка…
Ссылка в новой задаче