summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-11 22:35:19 +0000
committerbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-11 22:35:19 +0000
commit2f15de4cf410a5d260958a84f7ff5acb5ed93b42 (patch)
tree23154cfe6dcb10d0af1349d5926820b10c602383
parente688331d8e7086a71a55033a3ad14cc8b018799b (diff)
downloadchromium_src-2f15de4cf410a5d260958a84f7ff5acb5ed93b42.zip
chromium_src-2f15de4cf410a5d260958a84f7ff5acb5ed93b42.tar.gz
chromium_src-2f15de4cf410a5d260958a84f7ff5acb5ed93b42.tar.bz2
Remove some Windows-specific stuff from RenderProcessHost by having callers get the process handle and PID directly from the corresponding Process object.
Review URL: http://codereview.chromium.org/10608 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5219 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/process.h7
-rw-r--r--base/process_posix.cc2
-rw-r--r--base/process_win.cc2
-rw-r--r--chrome/browser/automation/automation_provider.cc7
-rw-r--r--chrome/browser/browser_about_handler.cc2
-rw-r--r--chrome/browser/debugger/debugger_node.cc4
-rw-r--r--chrome/browser/memory_details.cc2
-rw-r--r--chrome/browser/profile.cc2
-rw-r--r--chrome/browser/render_process_host.cc2
-rw-r--r--chrome/browser/render_process_host.h10
-rw-r--r--chrome/browser/render_view_host.cc2
-rw-r--r--chrome/browser/render_widget_host.cc4
-rw-r--r--chrome/browser/task_manager_resource_providers.cc10
-rw-r--r--chrome/browser/views/hung_renderer_view.cc2
-rw-r--r--chrome/browser/web_contents.cc2
15 files changed, 27 insertions, 33 deletions
diff --git a/base/process.h b/base/process.h
index 2a92fcd..806b1de 100644
--- a/base/process.h
+++ b/base/process.h
@@ -32,8 +32,9 @@ class Process {
// A handle to the current process.
static Process Current();
- // Get/Set the handle for this process.
- ProcessHandle handle() { return process_; }
+ // 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 handle) { process_ = handle; }
// Get the PID for this process.
@@ -52,7 +53,7 @@ class Process {
// A process is backgrounded when it's priority is lower than normal.
// Return true if this process is backgrounded, false otherwise.
- bool IsProcessBackgrounded();
+ 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
diff --git a/base/process_posix.cc b/base/process_posix.cc
index 2bc6b0c..73711db 100644
--- a/base/process_posix.cc
+++ b/base/process_posix.cc
@@ -6,7 +6,7 @@
#include "base/logging.h"
#include "base/process_util.h"
-bool Process::IsProcessBackgrounded() {
+bool Process::IsProcessBackgrounded() const {
return false;
}
diff --git a/base/process_win.cc b/base/process_win.cc
index 38fe63c..7a60854 100644
--- a/base/process_win.cc
+++ b/base/process_win.cc
@@ -7,7 +7,7 @@
#include "base/process_util.h"
#include "base/scoped_ptr.h"
-bool Process::IsProcessBackgrounded() {
+bool Process::IsProcessBackgrounded() const {
DCHECK(process_);
DWORD priority = GetPriorityClass(process_);
if (priority == 0)
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index b9bd059..7b4fe8d 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -5,7 +5,6 @@
#include "chrome/browser/automation/automation_provider.h"
#include "base/path_service.h"
-#include "base/process_util.h"
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/browser/automation/automation_provider_list.h"
#include "chrome/browser/automation/ui_controls.h"
@@ -1678,10 +1677,8 @@ void AutomationProvider::GetTabProcessID(
NavigationController* tab = tab_tracker_->GetResource(handle);
if (tab->active_contents()->AsWebContents()) {
WebContents* web_contents = tab->active_contents()->AsWebContents();
- if (web_contents->process()) {
- process_id =
- process_util::GetProcId(web_contents->process()->process());
- }
+ if (web_contents->process())
+ process_id = web_contents->process()->process().pid();
}
}
diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc
index 433eea89..2afa2bb 100644
--- a/chrome/browser/browser_about_handler.cc
+++ b/chrome/browser/browser_about_handler.cc
@@ -538,7 +538,7 @@ void AboutMemoryHandler::AppendProcess(ListValue* renderers,
RenderProcessHost::iterator renderer_iter;
for (renderer_iter = RenderProcessHost::begin(); renderer_iter !=
RenderProcessHost::end(); ++renderer_iter) {
- if (renderer_iter->second->pid() == info->pid)
+ if (renderer_iter->second->process().pid() == info->pid)
break;
}
if (renderer_iter != RenderProcessHost::end()) {
diff --git a/chrome/browser/debugger/debugger_node.cc b/chrome/browser/debugger/debugger_node.cc
index 23b2cef..de5d3a6 100644
--- a/chrome/browser/debugger/debugger_node.cc
+++ b/chrome/browser/debugger/debugger_node.cc
@@ -326,7 +326,7 @@ v8::Handle<v8::Value> TabNode::Attach(const v8::Arguments& args,
RenderViewHost* host = web->render_view_host();
host->DebugAttach();
RenderProcessHost* proc = host->process();
- return v8::Int32::New(process_util::GetProcId(proc->process()));
+ return v8::Int32::New(proc->process().pid());
}
v8::Handle<v8::Value> TabNode::Detach(const v8::Arguments& args,
@@ -334,7 +334,7 @@ v8::Handle<v8::Value> TabNode::Detach(const v8::Arguments& args,
RenderViewHost* host = web->render_view_host();
host->DebugDetach();
RenderProcessHost* proc = host->process();
- return v8::Int32::New(process_util::GetProcId(proc->process()));
+ return v8::Int32::New(proc->process().pid());
}
v8::Handle<v8::Value> TabNode::Break(const v8::Arguments& args,
diff --git a/chrome/browser/memory_details.cc b/chrome/browser/memory_details.cc
index b2bff98..afa01a8 100644
--- a/chrome/browser/memory_details.cc
+++ b/chrome/browser/memory_details.cc
@@ -181,7 +181,7 @@ void MemoryDetails::CollectRenderHostInformation() {
RenderProcessHost::end(); ++renderer_iter) {
DCHECK(renderer_iter->second);
if (process_data_[CHROME_BROWSER].processes[index].pid ==
- renderer_iter->second->pid()) {
+ renderer_iter->second->process().pid()) {
// The RenderProcessHost may host multiple TabContents. Any
// of them which contain diagnostics information make the whole
// process be considered a diagnostics process.
diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc
index 1890b1e..80d3ea3 100644
--- a/chrome/browser/profile.cc
+++ b/chrome/browser/profile.cc
@@ -663,7 +663,7 @@ static void BroadcastNewHistoryTable(SharedMemory* table_memory) {
continue;
SharedMemoryHandle new_table;
- HANDLE process = i->second->process();
+ HANDLE process = i->second->process().handle();
if (!process) {
// process can be null if it's started with the --single-process flag.
process = GetCurrentProcess();
diff --git a/chrome/browser/render_process_host.cc b/chrome/browser/render_process_host.cc
index a8d7d5f..450fdba 100644
--- a/chrome/browser/render_process_host.cc
+++ b/chrome/browser/render_process_host.cc
@@ -536,7 +536,7 @@ void RenderProcessHost::ReportExpectingClose(int32 listener_id) {
}
bool RenderProcessHost::FastShutdownIfPossible() {
- HANDLE proc = process();
+ HANDLE proc = process().handle();
if (!proc)
return false;
// If we're in single process mode, do nothing.
diff --git a/chrome/browser/render_process_host.h b/chrome/browser/render_process_host.h
index 5b89597..262710f 100644
--- a/chrome/browser/render_process_host.h
+++ b/chrome/browser/render_process_host.h
@@ -97,17 +97,13 @@ class RenderProcessHost : public IPC::Channel::Listener,
// goes away we'll know that it was intentional rather than a crash.
void ReportExpectingClose(int32 listener_id);
- // getters, these may return NULL if there is no connection
+ // May return NULL if there is no connection.
IPC::SyncChannel* channel() {
return channel_.get();
}
- HANDLE process() {
- return process_.handle();
- }
- // Get the process id of this renderer.
- int pid() const {
- return process_.pid();
+ const Process& process() const {
+ return process_;
}
// Try to shutdown the associated renderer process as fast as possible.
diff --git a/chrome/browser/render_view_host.cc b/chrome/browser/render_view_host.cc
index d6b7f74..cb31cda 100644
--- a/chrome/browser/render_view_host.cc
+++ b/chrome/browser/render_view_host.cc
@@ -129,7 +129,7 @@ bool RenderViewHost::CreateRenderView() {
renderer_initialized_ = true;
HANDLE modal_dialog_event;
- HANDLE renderer_process_handle = process()->process();
+ HANDLE renderer_process_handle = process()->process().handle();
if (renderer_process_handle == NULL)
renderer_process_handle = GetCurrentProcess();
diff --git a/chrome/browser/render_widget_host.cc b/chrome/browser/render_widget_host.cc
index 40047e1..7374c92 100644
--- a/chrome/browser/render_widget_host.cc
+++ b/chrome/browser/render_widget_host.cc
@@ -765,7 +765,7 @@ void RenderWidgetHost::PaintRect(HANDLE bitmap, const gfx::Rect& bitmap_rect,
bool needs_full_paint = false;
BackingStore* backing_store =
BackingStoreManager::PrepareBackingStore(this, view_rect,
- process_->process(),
+ process_->process().handle(),
bitmap, bitmap_rect,
&needs_full_paint);
DCHECK(backing_store != NULL);
@@ -800,7 +800,7 @@ void RenderWidgetHost::ScrollRect(HANDLE bitmap, const gfx::Rect& bitmap_rect,
// We expect that damaged_rect should equal bitmap_rect.
DCHECK(gfx::Rect(damaged_rect) == bitmap_rect);
- backing_store->Refresh(process_->process(), bitmap, bitmap_rect);
+ backing_store->Refresh(process_->process().handle(), bitmap, bitmap_rect);
}
void RenderWidgetHost::RestartHangMonitorTimeout() {
diff --git a/chrome/browser/task_manager_resource_providers.cc b/chrome/browser/task_manager_resource_providers.cc
index b3fe407..45c51eb 100644
--- a/chrome/browser/task_manager_resource_providers.cc
+++ b/chrome/browser/task_manager_resource_providers.cc
@@ -33,7 +33,7 @@ TaskManagerWebContentsResource::TaskManagerWebContentsResource(
: web_contents_(web_contents) {
// We cache the process as when the WebContents is closed the process
// becomes NULL and the TaskManager still needs it.
- process_ = web_contents_->process()->process();
+ process_ = web_contents_->process()->process().handle();
pid_ = process_util::GetProcId(process_);
}
@@ -93,14 +93,14 @@ TaskManager::Resource* TaskManagerWebContentsResourceProvider::GetResource(
if (!web_contents)
return NULL;
- if (!web_contents->process()->process()) {
+ if (!web_contents->process()->process().handle()) {
// We should not be holding on to a dead tab (it should have been removed
// through the NOTIFY_WEB_CONTENTS_DISCONNECTED notification.
NOTREACHED();
return NULL;
}
- int pid = process_util::GetProcId(web_contents->process()->process());
+ int pid = web_contents->process()->process().pid();
if (pid != origin_pid)
return NULL;
@@ -121,7 +121,7 @@ void TaskManagerWebContentsResourceProvider::StartUpdating() {
for (WebContentsIterator iterator; !iterator.done(); iterator++) {
WebContents* web_contents = *iterator;
// Don't add dead tabs or tabs that haven't yet connected.
- if (web_contents->process()->process() &&
+ if (web_contents->process()->process().handle() &&
web_contents->notify_disconnection())
AddToTaskManager(web_contents);
}
@@ -166,7 +166,7 @@ void TaskManagerWebContentsResourceProvider::Add(WebContents* web_contents) {
if (!updating_)
return;
- if (!web_contents->process()->process()) {
+ if (!web_contents->process()->process().handle()) {
// Don't add sad tabs, we would have no information to show for them since
// they have no associated process.
return;
diff --git a/chrome/browser/views/hung_renderer_view.cc b/chrome/browser/views/hung_renderer_view.cc
index 7202538..92f68b7 100644
--- a/chrome/browser/views/hung_renderer_view.cc
+++ b/chrome/browser/views/hung_renderer_view.cc
@@ -303,7 +303,7 @@ views::View* HungRendererWarningView::GetContentsView() {
void HungRendererWarningView::ButtonPressed(views::NativeButton* sender) {
if (sender == kill_button_) {
// Kill the process.
- HANDLE process = contents_->process()->process();
+ HANDLE process = contents_->process()->process().handle();
TerminateProcess(process, ResultCodes::HUNG);
}
}
diff --git a/chrome/browser/web_contents.cc b/chrome/browser/web_contents.cc
index e936aac..0ed5904 100644
--- a/chrome/browser/web_contents.cc
+++ b/chrome/browser/web_contents.cc
@@ -868,7 +868,7 @@ void WebContents::DidStopLoading(RenderViewHost* rvh, int32 page_id) {
if (entry) {
scoped_ptr<process_util::ProcessMetrics> metrics(
process_util::ProcessMetrics::CreateProcessMetrics(
- process()->process()));
+ process()->process().handle()));
TimeDelta elapsed = TimeTicks::Now() - current_load_start_;