summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorcdn@chromium.org <cdn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-20 20:28:17 +0000
committercdn@chromium.org <cdn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-20 20:28:17 +0000
commit177623b42c69743828b8bd0a40c0f07b072ba86d (patch)
treea3db515744f38bdf3489d0f4c8229b3c33fc2a97 /content
parent98a9273d8b0c3f873ca66331c9d9a81ab9c9f9e9 (diff)
downloadchromium_src-177623b42c69743828b8bd0a40c0f07b072ba86d.zip
chromium_src-177623b42c69743828b8bd0a40c0f07b072ba86d.tar.gz
chromium_src-177623b42c69743828b8bd0a40c0f07b072ba86d.tar.bz2
Move handle dumpage to the renderer process (so that it works correctly) and move handle enumerator into common.
BUG=96488 TEST=N/A Review URL: http://codereview.chromium.org/7888024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102004 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/child_process_launcher.cc15
-rw-r--r--content/browser/renderer_host/browser_render_process_host.cc17
-rw-r--r--content/browser/renderer_host/browser_render_process_host.h2
-rw-r--r--content/browser/renderer_host/mock_render_process_host.cc3
-rw-r--r--content/browser/renderer_host/mock_render_process_host.h1
-rw-r--r--content/browser/renderer_host/render_process_host.cc19
-rw-r--r--content/browser/renderer_host/render_process_host.h6
-rw-r--r--content/common/child_process_messages.h6
-rw-r--r--content/common/child_thread.cc19
-rw-r--r--content/common/child_thread.h2
-rw-r--r--content/common/content_switches.cc16
-rw-r--r--content/common/content_switches.h7
-rw-r--r--content/common/handle_enumerator_win.cc (renamed from content/browser/handle_enumerator_win.cc)128
-rw-r--r--content/common/handle_enumerator_win.h (renamed from content/browser/handle_enumerator_win.h)37
-rw-r--r--content/content_browser.gypi2
-rw-r--r--content/content_common.gypi2
16 files changed, 101 insertions, 181 deletions
diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc
index e438989..1462e10 100644
--- a/content/browser/child_process_launcher.cc
+++ b/content/browser/child_process_launcher.cc
@@ -21,7 +21,6 @@
#if defined(OS_WIN)
#include "base/file_path.h"
-#include "content/browser/handle_enumerator_win.h"
#include "content/common/sandbox_policy.h"
#elif defined(OS_MACOSX)
#include "content/browser/mach_broker_mac.h"
@@ -237,20 +236,6 @@ class ChildProcessLauncher::Context
if (!terminate_child_on_shutdown_)
return;
-#if defined(OS_WIN)
- const CommandLine& browser_command_line =
- *CommandLine::ForCurrentProcess();
- if (browser_command_line.HasSwitch(switches::kAuditHandles) ||
- browser_command_line.HasSwitch(switches::kAuditAllHandles)) {
- scoped_refptr<content::HandleEnumerator> handle_enum(
- new content::HandleEnumerator(process_.handle(),
- browser_command_line.HasSwitch(switches::kAuditAllHandles)));
- handle_enum->RunHandleEnumeration();
- process_.set_handle(base::kNullProcessHandle);
- return;
- }
-#endif
-
// On Posix, EnsureProcessTerminated can lead to 2 seconds of sleep! So
// don't this on the UI/IO threads.
BrowserThread::PostTask(
diff --git a/content/browser/renderer_host/browser_render_process_host.cc b/content/browser/renderer_host/browser_render_process_host.cc
index 3abf9fc..2efd8fb 100644
--- a/content/browser/renderer_host/browser_render_process_host.cc
+++ b/content/browser/renderer_host/browser_render_process_host.cc
@@ -530,6 +530,8 @@ void BrowserRenderProcessHost::PropagateBrowserCommandLineToRenderer(
static const char* const kSwitchNames[] = {
// We propagate the Chrome Frame command line here as well in case the
// renderer is not run in the sandbox.
+ switches::kAuditAllHandles,
+ switches::kAuditHandles,
switches::kChromeFrame,
switches::kDisable3DAPIs,
switches::kDisableAcceleratedCompositing,
@@ -657,6 +659,15 @@ bool BrowserRenderProcessHost::FastShutdownIfPossible() {
return true;
}
+void BrowserRenderProcessHost::DumpHandles() {
+#if defined(OS_WIN)
+ Send(new ChildProcessMsg_DumpHandles());
+ return;
+#endif
+
+ NOTIMPLEMENTED();
+}
+
// This is a platform specific function for mapping a transport DIB given its id
TransportDIB* BrowserRenderProcessHost::MapTransportDIB(
TransportDIB::Id dib_id) {
@@ -757,6 +768,8 @@ bool BrowserRenderProcessHost::OnMessageReceived(const IPC::Message& msg) {
IPC_BEGIN_MESSAGE_MAP_EX(BrowserRenderProcessHost, msg, msg_is_ok)
IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ShutdownRequest,
OnShutdownRequest)
+ IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DumpHandlesDone,
+ OnDumpHandlesDone)
IPC_MESSAGE_HANDLER(ViewHostMsg_SuddenTerminationChanged,
SuddenTerminationChanged)
IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction,
@@ -902,6 +915,10 @@ void BrowserRenderProcessHost::OnShutdownRequest() {
Send(new ChildProcessMsg_Shutdown());
}
+void BrowserRenderProcessHost::OnDumpHandlesDone() {
+ Cleanup();
+}
+
void BrowserRenderProcessHost::SuddenTerminationChanged(bool enabled) {
set_sudden_termination_allowed(enabled);
}
diff --git a/content/browser/renderer_host/browser_render_process_host.h b/content/browser/renderer_host/browser_render_process_host.h
index d209b03..97297e9 100644
--- a/content/browser/renderer_host/browser_render_process_host.h
+++ b/content/browser/renderer_host/browser_render_process_host.h
@@ -62,6 +62,7 @@ class BrowserRenderProcessHost : public RenderProcessHost,
virtual void WidgetHidden();
virtual int VisibleWidgetCount() const;
virtual bool FastShutdownIfPossible();
+ virtual void DumpHandles();
virtual base::ProcessHandle GetHandle();
virtual TransportDIB* GetTransportDIB(TransportDIB::Id dib_id);
virtual void SetCompositingSurface(
@@ -91,6 +92,7 @@ class BrowserRenderProcessHost : public RenderProcessHost,
// Control message handlers.
void OnShutdownRequest();
+ void OnDumpHandlesDone();
void SuddenTerminationChanged(bool enabled);
void OnUserMetricsRecordAction(const std::string& action);
void OnRevealFolderInOS(const FilePath& path);
diff --git a/content/browser/renderer_host/mock_render_process_host.cc b/content/browser/renderer_host/mock_render_process_host.cc
index 87ec8de..d3f182d 100644
--- a/content/browser/renderer_host/mock_render_process_host.cc
+++ b/content/browser/renderer_host/mock_render_process_host.cc
@@ -74,6 +74,9 @@ bool MockRenderProcessHost::FastShutdownIfPossible() {
return true;
}
+void MockRenderProcessHost::DumpHandles() {
+}
+
base::ProcessHandle MockRenderProcessHost::GetHandle() {
return base::kNullProcessHandle;
}
diff --git a/content/browser/renderer_host/mock_render_process_host.h b/content/browser/renderer_host/mock_render_process_host.h
index 03e163e..c719472 100644
--- a/content/browser/renderer_host/mock_render_process_host.h
+++ b/content/browser/renderer_host/mock_render_process_host.h
@@ -50,6 +50,7 @@ class MockRenderProcessHost : public RenderProcessHost {
virtual int VisibleWidgetCount() const;
virtual void AddWord(const string16& word);
virtual bool FastShutdownIfPossible();
+ virtual void DumpHandles();
virtual base::ProcessHandle GetHandle();
virtual TransportDIB* GetTransportDIB(TransportDIB::Id dib_id);
virtual void SetCompositingSurface(
diff --git a/content/browser/renderer_host/render_process_host.cc b/content/browser/renderer_host/render_process_host.cc
index 44e52231..958a30d 100644
--- a/content/browser/renderer_host/render_process_host.cc
+++ b/content/browser/renderer_host/render_process_host.cc
@@ -4,12 +4,14 @@
#include "content/browser/renderer_host/render_process_host.h"
+#include "base/command_line.h"
#include "base/rand_util.h"
#include "base/sys_info.h"
#include "content/browser/browser_thread.h"
#include "content/browser/child_process_security_policy.h"
#include "content/common/child_process_info.h"
#include "content/common/content_constants.h"
+#include "content/common/content_switches.h"
#include "content/common/notification_service.h"
namespace {
@@ -128,6 +130,23 @@ void RenderProcessHost::Release(int listener_id) {
// Make sure that all associated resource requests are stopped.
CancelResourceRequests(listener_id);
+#if defined(OS_WIN)
+ // Dump the handle table if handle auditing is enabled.
+ const CommandLine& browser_command_line =
+ *CommandLine::ForCurrentProcess();
+ if (browser_command_line.HasSwitch(switches::kAuditHandles) ||
+ browser_command_line.HasSwitch(switches::kAuditAllHandles)) {
+ DumpHandles();
+
+ // We wait to close the channels until the child process has finished
+ // dumping handles and sends us ChildProcessHostMsg_DumpHandlesDone.
+ return;
+ }
+#endif
+ Cleanup();
+}
+
+void RenderProcessHost::Cleanup() {
// When no other owners of this object, we can delete ourselves
if (listeners_.IsEmpty()) {
NotificationService::current()->Notify(
diff --git a/content/browser/renderer_host/render_process_host.h b/content/browser/renderer_host/render_process_host.h
index 2164634..44d5dc8 100644
--- a/content/browser/renderer_host/render_process_host.h
+++ b/content/browser/renderer_host/render_process_host.h
@@ -104,6 +104,9 @@ class CONTENT_EXPORT RenderProcessHost : public IPC::Channel::Sender,
// See Attach()
void Release(int listener_id);
+ // Schedules the host for deletion and removes it from the all_hosts list.
+ void Cleanup();
+
// Listeners should call this when they've sent a "Close" message and
// they're waiting for a "Close_ACK", so that if the renderer process
// goes away we'll know that it was intentional rather than a crash.
@@ -213,6 +216,9 @@ class CONTENT_EXPORT RenderProcessHost : public IPC::Channel::Sender,
// Returns True if it was able to do fast shutdown.
virtual bool FastShutdownIfPossible() = 0;
+ // Dump the child process' handle table before shutting down.
+ virtual void DumpHandles() = 0;
+
// Returns the process object associated with the child process. In certain
// tests or single-process mode, this will actually represent the current
// process.
diff --git a/content/common/child_process_messages.h b/content/common/child_process_messages.h
index 32ff20b..b1a8b33 100644
--- a/content/common/child_process_messages.h
+++ b/content/common/child_process_messages.h
@@ -40,6 +40,9 @@ IPC_MESSAGE_CONTROL0(ChildProcessMsg_EndTracing)
// Sent to all child processes to get trace buffer fullness.
IPC_MESSAGE_CONTROL0(ChildProcessMsg_GetTraceBufferPercentFull)
+// Sent to child processes to dump their handle table.
+IPC_MESSAGE_CONTROL0(ChildProcessMsg_DumpHandles)
+
////////////////////////////////////////////////////////////////////////////////
// Messages sent from the child process to the browser.
@@ -60,6 +63,9 @@ IPC_MESSAGE_CONTROL1(ChildProcessHostMsg_TraceDataCollected,
IPC_MESSAGE_CONTROL1(ChildProcessHostMsg_TraceBufferPercentFullReply,
float /*trace buffer percent full*/)
+// Reply to ChildProcessMsg_DumpHandles when handle table dump is complete.
+IPC_MESSAGE_CONTROL0(ChildProcessHostMsg_DumpHandlesDone)
+
#if defined(OS_WIN)
// Request that the given font be loaded by the host so it's cached by the
// OS. Please see ChildProcessHost::PreCacheFont for details.
diff --git a/content/common/child_thread.cc b/content/common/child_thread.cc
index 95d0080..f76c2a5 100644
--- a/content/common/child_thread.cc
+++ b/content/common/child_thread.cc
@@ -22,6 +22,10 @@
#include "ipc/ipc_switches.h"
#include "webkit/glue/webkit_glue.h"
+#if defined(OS_WIN)
+#include "content/common/handle_enumerator_win.h"
+#endif
+
ChildThread::ChildThread() {
channel_name_ = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kProcessChannelID);
@@ -158,6 +162,7 @@ bool ChildThread::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(ChildProcessMsg_SetIPCLoggingEnabled,
OnSetIPCLoggingEnabled)
#endif
+ IPC_MESSAGE_HANDLER(ChildProcessMsg_DumpHandles, OnDumpHandles)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -191,6 +196,20 @@ void ChildThread::OnSetIPCLoggingEnabled(bool enable) {
}
#endif // IPC_MESSAGE_LOG_ENABLED
+void ChildThread::OnDumpHandles() {
+#if defined(OS_WIN)
+ scoped_refptr<content::HandleEnumerator> handle_enum(
+ new content::HandleEnumerator(
+ CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kAuditAllHandles)));
+ handle_enum->EnumerateHandles();
+ Send(new ChildProcessHostMsg_DumpHandlesDone);
+ return;
+#endif
+
+ NOTIMPLEMENTED();
+}
+
ChildThread* ChildThread::current() {
return ChildProcess::current()->main_thread();
}
diff --git a/content/common/child_thread.h b/content/common/child_thread.h
index 8956ff2..356ffd5 100644
--- a/content/common/child_thread.h
+++ b/content/common/child_thread.h
@@ -87,6 +87,8 @@ class CONTENT_EXPORT ChildThread : public IPC::Channel::Listener,
virtual void OnSetIPCLoggingEnabled(bool enable);
#endif
+ virtual void OnDumpHandles();
+
void set_on_channel_error_called(bool on_channel_error_called) {
on_channel_error_called_ = on_channel_error_called;
}
diff --git a/content/common/content_switches.cc b/content/common/content_switches.cc
index 4b232a4..6bafd31 100644
--- a/content/common/content_switches.cc
+++ b/content/common/content_switches.cc
@@ -17,6 +17,13 @@ const char kAllowRunningInsecureContent[] = "allow-running-insecure-content";
// Allows debugging of sandboxed processes (see zygote_main_linux.cc).
const char kAllowSandboxDebugging[] = "allow-sandbox-debugging";
+// Enumerates and prints a child process' most dangerous handles when it
+// is terminated.
+const char kAuditHandles[] = "enable-handle-auditing";
+
+// The same as kAuditHandles except all handles are enumerated.
+const char kAuditAllHandles[] = "enable-handle-auditing-all";
+
// Causes the browser process to throw an assertion on startup.
const char kBrowserAssertTest[] = "assert-test";
@@ -484,15 +491,6 @@ const char kZygoteCmdPrefix[] = "zygote-cmd-prefix";
// Causes the process to run as a renderer zygote.
const char kZygoteProcess[] = "zygote";
-#if defined(OS_WIN)
-// Enumerates and prints a child process' most dangerous handles when it
-// is terminated.
-const char kAuditHandles[] = "enable-handle-auditing";
-
-// The same as kAuditHandles except all handles are enumerated.
-const char kAuditAllHandles[] = "enable-handle-auditing-all";
-#endif
-
#if defined(OS_POSIX) && !defined(OS_MACOSX)
// Specify the amount the trackpad should scroll by.
const char kScrollPixels[] = "scroll-pixels";
diff --git a/content/common/content_switches.h b/content/common/content_switches.h
index ea1636b..8bf6e23 100644
--- a/content/common/content_switches.h
+++ b/content/common/content_switches.h
@@ -16,6 +16,8 @@ namespace switches {
CONTENT_EXPORT extern const char kAllowFileAccessFromFiles[];
CONTENT_EXPORT extern const char kAllowRunningInsecureContent[];
extern const char kAllowSandboxDebugging[];
+extern const char kAuditHandles[];
+extern const char kAuditAllHandles[];
CONTENT_EXPORT extern const char kBrowserAssertTest[];
CONTENT_EXPORT extern const char kBrowserCrashTest[];
extern const char kBrowserSubprocessPath[];
@@ -158,11 +160,6 @@ CONTENT_EXPORT extern const char kWorkerProcess[];
CONTENT_EXPORT extern const char kZygoteCmdPrefix[];
CONTENT_EXPORT extern const char kZygoteProcess[];
-#if defined(OS_WIN)
-extern const char kAuditHandles[];
-extern const char kAuditAllHandles[];
-#endif
-
#if defined(OS_POSIX) && !defined(OS_MACOSX)
extern const char kScrollPixels[];
#endif
diff --git a/content/browser/handle_enumerator_win.cc b/content/common/handle_enumerator_win.cc
index 0d5ba51..c95ac10 100644
--- a/content/browser/handle_enumerator_win.cc
+++ b/content/common/handle_enumerator_win.cc
@@ -2,19 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/browser/handle_enumerator_win.h"
+#include "content/common/handle_enumerator_win.h"
#include <windows.h>
#include <map>
+#include "base/command_line.h"
#include "base/logging.h"
#include "base/process.h"
#include "base/process_util.h"
#include "base/utf_string_conversions.h"
#include "base/win/windows_version.h"
-#include "content/browser/browser_child_process_host.h"
-#include "content/browser/browser_thread.h"
-#include "content/browser/renderer_host/render_process_host.h"
+#include "content/common/content_switches.h"
#include "content/common/result_codes.h"
#include "sandbox/src/handle_table.h"
@@ -53,16 +52,17 @@ HandleTypeMap& MakeHandleTypeMap() {
namespace content {
-const wchar_t kNtdllDllName[] = L"ntdll.dll";
const size_t kMaxHandleNameLength = 1024;
void HandleEnumerator::EnumerateHandles() {
sandbox::HandleTable handles;
-
- string16 output = ProcessTypeString(type_);
- output.append(ASCIIToUTF16(" Process - Handles at shutdown:\n"));
+ std::string process_type =
+ CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kProcessType);
+ string16 output = ASCIIToUTF16(process_type);
+ output.append(ASCIIToUTF16(" process - Handles at shutdown:\n"));
for (sandbox::HandleTable::Iterator sys_handle
- = handles.HandlesForProcess(::GetProcessId(handle_));
+ = handles.HandlesForProcess(::GetCurrentProcessId());
sys_handle != handles.end(); ++sys_handle) {
HandleType current_type = StringToHandleType(sys_handle->Type());
if (!all_handles_ && (current_type != ProcessHandle &&
@@ -85,116 +85,6 @@ void HandleEnumerator::EnumerateHandles() {
LOG(INFO) << output;
}
-void HandleEnumerator::RunHandleEnumeration() {
- DCHECK(status_ == Starting);
- if (BrowserThread::CurrentlyOn(BrowserThread::IO))
- FindProcessOnIOThread();
- else if (BrowserThread::CurrentlyOn(BrowserThread::UI))
- FindProcessOnUIThread();
- else
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- NewRunnableMethod(this,
- &HandleEnumerator::FindProcessOnIOThread));
-}
-
-void HandleEnumerator::FindProcessOnIOThread() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
-
- for (BrowserChildProcessHost::Iterator iter; !iter.Done(); ++iter) {
- if (iter->handle() == handle_) {
- type_ = iter->type();
- status_ = Finished;
- break;
- }
- }
-
- if (status_ == Starting) {
- status_ = InProgress;
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this,
- &HandleEnumerator::FindProcessOnUIThread));
- } else {
- status_ = Finished;
- BrowserThread::PostTask(
- BrowserThread::PROCESS_LAUNCHER, FROM_HERE,
- NewRunnableMethod(this,
- &HandleEnumerator::EnumerateHandlesAndTerminateProcess));
- }
-}
-
-void HandleEnumerator::FindProcessOnUIThread() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
- for (RenderProcessHost::iterator renderer_iter(
- RenderProcessHost::AllHostsIterator()); !renderer_iter.IsAtEnd();
- renderer_iter.Advance()) {
- RenderProcessHost* render_process_host = renderer_iter.GetCurrentValue();
- if (render_process_host->GetHandle() == handle_) {
- type_ = ChildProcessInfo::RENDER_PROCESS;
- status_ = Finished;
- break;
- }
- }
-
- if (status_ == Starting) {
- status_ = InProgress;
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- NewRunnableMethod(this,
- &HandleEnumerator::FindProcessOnIOThread));
- } else {
- status_ = Finished;
- BrowserThread::PostTask(
- BrowserThread::PROCESS_LAUNCHER, FROM_HERE,
- NewRunnableMethod(this,
- &HandleEnumerator::EnumerateHandlesAndTerminateProcess));
- }
-}
-
-void HandleEnumerator::EnumerateHandlesAndTerminateProcess() {
- HandleEnumerator::EnumerateHandles();
- base::Process process(handle_);
- process.Terminate(content::RESULT_CODE_NORMAL_EXIT);
- process.Close();
-}
-
-string16 ProcessTypeString(ChildProcessInfo::ProcessType process_type) {
- switch (process_type) {
- case ChildProcessInfo::UNKNOWN_PROCESS:
- return ASCIIToUTF16("Unknown");
- case ChildProcessInfo::BROWSER_PROCESS:
- return ASCIIToUTF16("Browser");
- case ChildProcessInfo::RENDER_PROCESS:
- return ASCIIToUTF16("Renderer");
- case ChildProcessInfo::PLUGIN_PROCESS:
- return ASCIIToUTF16("Plugin");
- case ChildProcessInfo::WORKER_PROCESS:
- return ASCIIToUTF16("Worker");
- case ChildProcessInfo::NACL_LOADER_PROCESS:
- return ASCIIToUTF16("NaCL Loader");
- case ChildProcessInfo::UTILITY_PROCESS:
- return ASCIIToUTF16("Utility");
- case ChildProcessInfo::PROFILE_IMPORT_PROCESS:
- return ASCIIToUTF16("Profile Import");
- case ChildProcessInfo::ZYGOTE_PROCESS:
- return ASCIIToUTF16("Zygote");
- case ChildProcessInfo::SANDBOX_HELPER_PROCESS:
- return ASCIIToUTF16("Sandbox Helper");
- case ChildProcessInfo::NACL_BROKER_PROCESS:
- return ASCIIToUTF16("NaCL Broker");
- case ChildProcessInfo::GPU_PROCESS:
- return ASCIIToUTF16("GPU");
- case ChildProcessInfo::PPAPI_PLUGIN_PROCESS:
- return ASCIIToUTF16("Pepper Plugin");
- case ChildProcessInfo::PPAPI_BROKER_PROCESS:
- return ASCIIToUTF16("Pepper Broker");
- default:
- return string16();
- }
-}
-
HandleType StringToHandleType(const string16& type) {
static HandleTypeMap handle_types = MakeHandleTypeMap();
HandleTypeMap::iterator result = handle_types.find(type);
diff --git a/content/browser/handle_enumerator_win.h b/content/common/handle_enumerator_win.h
index 12b426c..ada972f 100644
--- a/content/browser/handle_enumerator_win.h
+++ b/content/common/handle_enumerator_win.h
@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CONTENT_BROWSER_HANDLE_ENUMERATOR_WIN_H_
-#define CONTENT_BROWSER_HANDLE_ENUMERATOR_WIN_H_
+#ifndef CONTENT_COMMON_HANDLE_ENUMERATOR_WIN_H_
+#define CONTENT_COMMON_HANDLE_ENUMERATOR_WIN_H_
#include "base/memory/ref_counted.h"
#include "base/process.h"
-#include "content/common/child_process_info.h"
+#include "base/string16.h"
namespace content {
@@ -33,42 +33,16 @@ enum HandleType {
static HandleType StringToHandleType(const string16& type);
-static string16 ProcessTypeString(ChildProcessInfo::ProcessType process_type);
-
static string16 GetAccessString(HandleType handle_type, ACCESS_MASK access);
class HandleEnumerator : public base::RefCountedThreadSafe<HandleEnumerator> {
public:
- enum HandleEnumStatus {
- Starting,
- InProgress,
- Finished
- };
-
- HandleEnumerator(base::ProcessHandle handle, bool all_handles):
- handle_(handle),
- type_(ChildProcessInfo::UNKNOWN_PROCESS),
- status_(Starting),
+ explicit HandleEnumerator(bool all_handles):
all_handles_(all_handles) { }
- ChildProcessInfo::ProcessType type() const { return type_; }
-
- HandleEnumStatus status() const { return status_; }
-
- void RunHandleEnumeration();
-
void EnumerateHandles();
private:
- void FindProcessOnIOThread();
-
- void FindProcessOnUIThread();
-
- void EnumerateHandlesAndTerminateProcess();
-
- base::ProcessHandle handle_;
- ChildProcessInfo::ProcessType type_;
- HandleEnumStatus status_;
bool all_handles_;
DISALLOW_COPY_AND_ASSIGN(HandleEnumerator);
@@ -76,4 +50,5 @@ class HandleEnumerator : public base::RefCountedThreadSafe<HandleEnumerator> {
} // namespace content
-#endif // CONTENT_BROWSER_HANDLE_ENUMERATOR_WIN_H_
+#endif // CONTENT_COMMON_HANDLE_ENUMERATOR_WIN_H_
+
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index 2cb74f8..4e6c6d1 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -222,8 +222,6 @@
'browser/gpu/gpu_process_host.h',
'browser/gpu/gpu_process_host_ui_shim.cc',
'browser/gpu/gpu_process_host_ui_shim.h',
- 'browser/handle_enumerator_win.cc',
- 'browser/handle_enumerator_win.h',
'browser/host_zoom_map.cc',
'browser/host_zoom_map.h',
'browser/in_process_webkit/browser_webkitplatformsupport_impl.cc',
diff --git a/content/content_common.gypi b/content/content_common.gypi
index f9bc297..98e9971 100644
--- a/content/content_common.gypi
+++ b/content/content_common.gypi
@@ -123,6 +123,8 @@
'common/gpu/media/gpu_video_decode_accelerator.h',
'common/gpu/transport_texture.cc',
'common/gpu/transport_texture.h',
+ 'common/handle_enumerator_win.cc',
+ 'common/handle_enumerator_win.h',
'common/hi_res_timer_manager_posix.cc',
'common/hi_res_timer_manager_win.cc',
'common/hi_res_timer_manager.h',