summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/automation/extension_port_container.cc2
-rw-r--r--chrome/browser/automation/url_request_automation_job.cc2
-rw-r--r--chrome/browser/browser_accessibility_manager.cc7
-rw-r--r--chrome/browser/cert_store.cc2
-rw-r--r--chrome/browser/crash_recovery_browsertest.cc4
-rw-r--r--chrome/browser/download/download_file.cc14
-rw-r--r--chrome/browser/download/download_file.h4
-rw-r--r--chrome/browser/download/download_manager.cc14
-rw-r--r--chrome/browser/download/save_package.cc8
-rw-r--r--chrome/browser/extensions/extension_function_dispatcher.cc4
-rw-r--r--chrome/browser/extensions/extension_message_service.cc17
-rw-r--r--chrome/browser/extensions/extension_process_manager.cc2
-rw-r--r--chrome/browser/extensions/extensions_ui.cc2
-rw-r--r--chrome/browser/extensions/user_script_listener.cc2
-rw-r--r--chrome/browser/extensions/user_script_listener_unittest.cc4
-rw-r--r--chrome/browser/external_tab_container.cc6
-rw-r--r--chrome/browser/history/download_types.h4
-rw-r--r--chrome/browser/memory_details.cc10
-rw-r--r--chrome/browser/net/url_request_tracking.cc47
-rw-r--r--chrome/browser/net/url_request_tracking.h35
-rw-r--r--chrome/browser/plugin_process_host.cc15
-rw-r--r--chrome/browser/plugin_process_host.h2
-rw-r--r--chrome/browser/privacy_blacklist/blacklist_observer.cc6
-rw-r--r--chrome/browser/renderer_host/audio_renderer_host.cc24
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc43
-rw-r--r--chrome/browser/renderer_host/buffered_resource_handler.cc18
-rw-r--r--chrome/browser/renderer_host/download_resource_handler.cc5
-rw-r--r--chrome/browser/renderer_host/mock_render_process_host.cc3
-rw-r--r--chrome/browser/renderer_host/render_process_host.cc31
-rw-r--r--chrome/browser/renderer_host/render_process_host.h16
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc43
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_win.cc14
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host.cc232
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host.h78
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc239
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc35
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.h6
-rw-r--r--chrome/browser/renderer_host/resource_request_details.h12
-rw-r--r--chrome/browser/renderer_host/test/site_instance_unittest.cc8
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc2
-rw-r--r--chrome/browser/ssl/ssl_blocking_page.cc2
-rw-r--r--chrome/browser/ssl/ssl_error_handler.cc2
-rw-r--r--chrome/browser/ssl/ssl_manager.cc7
-rw-r--r--chrome/browser/ssl/ssl_policy.cc11
-rw-r--r--chrome/browser/ssl/ssl_policy_backend.cc4
-rw-r--r--chrome/browser/ssl/ssl_request_info.h8
-rw-r--r--chrome/browser/tab_contents/interstitial_page.cc8
-rw-r--r--chrome/browser/tab_contents/interstitial_page.h8
-rw-r--r--chrome/browser/tab_contents/render_view_host_manager.cc5
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc12
-rw-r--r--chrome/browser/task_manager.cc21
-rw-r--r--chrome/browser/task_manager.h22
-rw-r--r--chrome/browser/task_manager_resource_providers.cc2
-rw-r--r--chrome/browser/utility_process_host_unittest.cc10
-rw-r--r--chrome/browser/visitedlink_unittest.cc3
-rw-r--r--chrome/browser/worker_host/worker_process_host.cc27
-rw-r--r--chrome/browser/worker_host/worker_process_host.h4
-rw-r--r--chrome/browser/worker_host/worker_service.cc19
-rw-r--r--chrome/browser/worker_host/worker_service.h8
-rw-r--r--chrome/chrome.gyp2
-rw-r--r--chrome/common/child_process_host.cc4
-rw-r--r--chrome/common/child_process_host.h3
-rw-r--r--chrome/common/child_process_info.cc45
-rw-r--r--chrome/common/child_process_info.h59
-rw-r--r--chrome/common/plugin_messages_internal.h11
-rw-r--r--chrome/common/render_messages.h12
-rw-r--r--chrome/common/resource_dispatcher.cc4
-rw-r--r--chrome/plugin/plugin_channel.cc10
-rw-r--r--chrome/plugin/plugin_channel.h7
-rw-r--r--chrome/plugin/plugin_thread.cc7
-rw-r--r--chrome/renderer/webplugin_delegate_proxy.cc5
-rw-r--r--net/url_request/url_request.cc2
-rw-r--r--net/url_request/url_request.h10
73 files changed, 747 insertions, 639 deletions
diff --git a/chrome/browser/automation/extension_port_container.cc b/chrome/browser/automation/extension_port_container.cc
index 034988a..43ace0f 100644
--- a/chrome/browser/automation/extension_port_container.cc
+++ b/chrome/browser/automation/extension_port_container.cc
@@ -203,7 +203,7 @@ bool ExtensionPortContainer::InterceptMessageFromExternalHost(
scoped_ptr<ExtensionPortContainer> port(
new ExtensionPortContainer(automation, tab_handle));
- int process_id = view_host->process()->pid();
+ int process_id = view_host->process()->id();
if (port->Connect(extension_id, process_id, routing_id, connection_id,
channel_name)) {
// We have a successful connection.
diff --git a/chrome/browser/automation/url_request_automation_job.cc b/chrome/browser/automation/url_request_automation_job.cc
index 2811d1b..db99c6e 100644
--- a/chrome/browser/automation/url_request_automation_job.cc
+++ b/chrome/browser/automation/url_request_automation_job.cc
@@ -69,7 +69,7 @@ URLRequestJob* AutomationRequestInterceptor::MaybeIntercept(
if (request_info) {
AutomationResourceMessageFilter::AutomationDetails details;
if (AutomationResourceMessageFilter::LookupRegisteredRenderView(
- request_info->process_id, request_info->route_id, &details)) {
+ request_info->child_id, request_info->route_id, &details)) {
URLRequestAutomationJob* job = new URLRequestAutomationJob(request,
details.tab_handle, details.filter);
return job;
diff --git a/chrome/browser/browser_accessibility_manager.cc b/chrome/browser/browser_accessibility_manager.cc
index 7a7c3b3..f710629 100644
--- a/chrome/browser/browser_accessibility_manager.cc
+++ b/chrome/browser/browser_accessibility_manager.cc
@@ -53,8 +53,7 @@ STDMETHODIMP BrowserAccessibilityManager::CreateAccessibilityInstance(
// Update cache with RenderProcessHost/BrowserAccessibility pair.
if (rvh && rvh->process()) {
- render_process_host_map_.insert(
- MapEntry(rvh->process()->pid(), instance));
+ render_process_host_map_.insert(MapEntry(rvh->process()->id(), instance));
} else {
// No RenderProcess active for this instance.
return E_FAIL;
@@ -140,10 +139,10 @@ void BrowserAccessibilityManager::Observe(NotificationType type,
DCHECK(rph);
RenderProcessHostMap::iterator it =
- render_process_host_map_.lower_bound(rph->pid());
+ render_process_host_map_.lower_bound(rph->id());
RenderProcessHostMap::iterator end_of_matching_objects =
- render_process_host_map_.upper_bound(rph->pid());
+ render_process_host_map_.upper_bound(rph->id());
for (; it != end_of_matching_objects; ++it) {
if (it->second) {
diff --git a/chrome/browser/cert_store.cc b/chrome/browser/cert_store.cc
index adc7ff1..4d804ca 100644
--- a/chrome/browser/cert_store.cc
+++ b/chrome/browser/cert_store.cc
@@ -138,5 +138,5 @@ void CertStore::Observe(NotificationType type,
type == NotificationType::RENDERER_PROCESS_CLOSED);
RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr();
DCHECK(rph);
- RemoveCertsForRenderProcesHost(rph->pid());
+ RemoveCertsForRenderProcesHost(rph->id());
}
diff --git a/chrome/browser/crash_recovery_browsertest.cc b/chrome/browser/crash_recovery_browsertest.cc
index 63ddf11..e97b573 100644
--- a/chrome/browser/crash_recovery_browsertest.cc
+++ b/chrome/browser/crash_recovery_browsertest.cc
@@ -8,6 +8,7 @@
#include "chrome/common/notification_registrar.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/page_transition_types.h"
+#include "chrome/common/url_constants.h"
#include "chrome/test/in_process_browser_test.h"
#include "chrome/test/ui_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -45,11 +46,10 @@ class RendererCrashObserver : public NotificationObserver {
};
void SimulateRendererCrash(Browser* browser) {
- browser->OpenURL(GURL("about:crash"), GURL(), CURRENT_TAB,
+ browser->OpenURL(GURL(chrome::kAboutCrashURL), GURL(), CURRENT_TAB,
PageTransition::TYPED);
RendererCrashObserver crash_observer;
crash_observer.WaitForRendererCrash();
-
}
} // namespace
diff --git a/chrome/browser/download/download_file.cc b/chrome/browser/download/download_file.cc
index bf439f0..246e5b8 100644
--- a/chrome/browser/download/download_file.cc
+++ b/chrome/browser/download/download_file.cc
@@ -60,7 +60,7 @@ DownloadFile::DownloadFile(const DownloadCreateInfo* info)
source_url_(info->url),
referrer_url_(info->referrer_url),
id_(info->download_id),
- render_process_id_(info->render_process_id),
+ child_id_(info->child_id),
render_view_id_(info->render_view_id),
request_id_(info->request_id),
bytes_so_far_(0),
@@ -244,7 +244,7 @@ void DownloadFileManager::StartDownload(DownloadCreateInfo* info) {
// on the UI thread is the safe way to do that.
ui_loop_->PostTask(FROM_HERE,
NewRunnableFunction(&DownloadManager::CancelDownloadRequest,
- info->render_process_id,
+ info->child_id,
info->request_id));
delete info;
delete download;
@@ -370,12 +370,10 @@ void DownloadFileManager::UpdateInProgressDownloads() {
// there will be no 'render_process_id' or 'render_view_id'.
void DownloadFileManager::OnStartDownload(DownloadCreateInfo* info) {
DCHECK(MessageLoop::current() == ui_loop_);
- DownloadManager* manager =
- DownloadManagerFromRenderIds(info->render_process_id,
- info->render_view_id);
+ DownloadManager* manager = DownloadManagerFromRenderIds(info->child_id,
+ info->render_view_id);
if (!manager) {
- DownloadManager::CancelDownloadRequest(info->render_process_id,
- info->request_id);
+ DownloadManager::CancelDownloadRequest(info->child_id, info->request_id);
delete info;
return;
}
@@ -585,7 +583,7 @@ void DownloadFileManager::OnFinalDownloadName(int id,
} else {
ui_loop_->PostTask(FROM_HERE,
NewRunnableFunction(&DownloadManager::CancelDownloadRequest,
- download->render_process_id(),
+ download->child_id(),
download->request_id()));
}
}
diff --git a/chrome/browser/download/download_file.h b/chrome/browser/download/download_file.h
index 3527131..4d2336b 100644
--- a/chrome/browser/download/download_file.h
+++ b/chrome/browser/download/download_file.h
@@ -103,7 +103,7 @@ class DownloadFile {
int64 bytes_so_far() const { return bytes_so_far_; }
int id() const { return id_; }
FilePath full_path() const { return full_path_; }
- int render_process_id() const { return render_process_id_; }
+ int child_id() const { return child_id_; }
int render_view_id() const { return render_view_id_; }
int request_id() const { return request_id_; }
bool path_renamed() const { return path_renamed_; }
@@ -131,7 +131,7 @@ class DownloadFile {
int id_;
// IDs for looking up the tab we are associated with.
- int render_process_id_;
+ int child_id_;
int render_view_id_;
// Handle for informing the ResourceDispatcherHost of a UI based cancel.
diff --git a/chrome/browser/download/download_manager.cc b/chrome/browser/download/download_manager.cc
index 9477925..4c4dc9e 100644
--- a/chrome/browser/download/download_manager.cc
+++ b/chrome/browser/download/download_manager.cc
@@ -652,8 +652,8 @@ void DownloadManager::OnPathExistenceAvailable(DownloadCreateInfo* info) {
if (!select_file_dialog_.get())
select_file_dialog_ = SelectFileDialog::Create(this);
- TabContents* contents = tab_util::GetTabContentsByID(
- info->render_process_id, info->render_view_id);
+ TabContents* contents = tab_util::GetTabContentsByID(info->child_id,
+ info->render_view_id);
SelectFileDialog::FileTypeInfo file_type_info;
file_type_info.extensions.resize(1);
file_type_info.extensions[0].push_back(info->suggested_path.Extension());
@@ -690,7 +690,7 @@ void DownloadManager::ContinueStartDownload(DownloadCreateInfo* info,
info->original_name,
info->start_time,
info->total_bytes,
- info->render_process_id,
+ info->child_id,
info->request_id,
info->is_dangerous);
download->set_manager(this);
@@ -1110,7 +1110,7 @@ void DownloadManager::DownloadUrl(const GURL& url,
request_context_->set_referrer_charset(referrer_charset);
file_manager_->DownloadUrl(url,
referrer,
- tab_contents->process()->pid(),
+ tab_contents->process()->id(),
tab_contents->render_view_host()->routing_id(),
request_context_.get());
}
@@ -1385,7 +1385,7 @@ void DownloadManager::FileSelectionCanceled(void* params) {
// download that's already in progress to the temporary location.
DownloadCreateInfo* info = reinterpret_cast<DownloadCreateInfo*>(params);
DownloadCancelledInternal(info->download_id,
- info->render_process_id,
+ info->child_id,
info->request_id);
}
@@ -1508,8 +1508,8 @@ void DownloadManager::ShowDownloadInBrowser(const DownloadCreateInfo& info,
// The 'contents' may no longer exist if the user closed the tab before we get
// this start completion event. If it does, tell the origin TabContents to
// display its download shelf.
- TabContents* contents =
- tab_util::GetTabContentsByID(info.render_process_id, info.render_view_id);
+ TabContents* contents = tab_util::GetTabContentsByID(info.child_id,
+ info.render_view_id);
// If the contents no longer exists, we start the download in the last active
// browser. This is not ideal but better than fully hiding the download from
diff --git a/chrome/browser/download/save_package.cc b/chrome/browser/download/save_package.cc
index c6003e7..e268c34 100644
--- a/chrome/browser/download/save_package.cc
+++ b/chrome/browser/download/save_package.cc
@@ -132,7 +132,7 @@ SavePackage::SavePackage(TabContents* web_content,
save_type_(save_type),
all_save_items_count_(0),
wait_state_(INITIALIZE),
- tab_id_(web_content->process()->pid()) {
+ tab_id_(web_content->process()->id()) {
DCHECK(web_content);
const GURL& current_page_url = tab_contents_->GetURL();
DCHECK(current_page_url.is_valid());
@@ -154,7 +154,7 @@ SavePackage::SavePackage(TabContents* tab_contents)
disk_error_occurred_(false),
all_save_items_count_(0),
wait_state_(INITIALIZE),
- tab_id_(tab_contents->process()->pid()) {
+ tab_id_(tab_contents->process()->id()) {
const GURL& current_page_url = tab_contents_->GetURL();
DCHECK(current_page_url.is_valid());
page_url_ = current_page_url;
@@ -577,7 +577,7 @@ void SavePackage::CheckFinish() {
&SaveFileManager::RenameAllFiles,
final_names,
dir,
- tab_contents_->process()->pid(),
+ tab_contents_->process()->id(),
tab_contents_->render_view_host()->routing_id()));
}
@@ -720,7 +720,7 @@ void SavePackage::SaveNextFile(bool process_all_remaining_items) {
save_item->Start();
file_manager_->SaveURL(save_item->url(),
save_item->referrer(),
- tab_contents_->process()->pid(),
+ tab_contents_->process()->id(),
tab_contents_->render_view_host()->routing_id(),
save_item->save_source(),
save_item->full_path(),
diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc
index 812e277..0a0b8c9 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.cc
+++ b/chrome/browser/extensions/extension_function_dispatcher.cc
@@ -219,7 +219,7 @@ ExtensionFunctionDispatcher::ExtensionFunctionDispatcher(
// Notify the ExtensionProcessManager that the view was created.
ExtensionProcessManager* epm = profile()->GetExtensionProcessManager();
epm->RegisterExtensionProcess(extension_id(),
- render_view_host->process()->pid());
+ render_view_host->process()->id());
// Update the extension permissions. Doing this each time we create an EFD
// ensures that new processes are informed of permissions for newly installed
@@ -264,7 +264,7 @@ void ExtensionFunctionDispatcher::SendResponse(ExtensionFunction* function,
void ExtensionFunctionDispatcher::HandleBadMessage(ExtensionFunction* api) {
LOG(ERROR) << "bad extension message " <<
- api->name() <<
+ api->name() <<
" : terminating renderer.";
if (RenderProcessHost::run_renderer_in_process()) {
// In single process mode it is better if we don't suicide but just crash.
diff --git a/chrome/browser/extensions/extension_message_service.cc b/chrome/browser/extensions/extension_message_service.cc
index 3b7e1fa..70396c4 100644
--- a/chrome/browser/extensions/extension_message_service.cc
+++ b/chrome/browser/extensions/extension_message_service.cc
@@ -202,15 +202,16 @@ int ExtensionMessageService::OpenChannelToExtension(
ui_loop_->PostTask(FROM_HERE,
NewRunnableMethod(this,
&ExtensionMessageService::OpenChannelToExtensionOnUIThread,
- source->GetProcessId(), routing_id, port2_id, extension_id,
- channel_name));
+ source->id(), routing_id, port2_id, extension_id, channel_name));
return port1_id;
}
-int ExtensionMessageService::OpenChannelToTab(
- int routing_id, int tab_id, const std::string& extension_id,
- const std::string& channel_name, ResourceMessageFilter* source) {
+int ExtensionMessageService::OpenChannelToTab(int routing_id,
+ int tab_id,
+ const std::string& extension_id,
+ const std::string& channel_name,
+ ResourceMessageFilter* source) {
DCHECK_EQ(MessageLoop::current(),
ChromeThread::GetMessageLoop(ChromeThread::IO));
@@ -224,7 +225,7 @@ int ExtensionMessageService::OpenChannelToTab(
ui_loop_->PostTask(FROM_HERE,
NewRunnableMethod(this,
&ExtensionMessageService::OpenChannelToTabOnUIThread,
- source->GetProcessId(), routing_id, port2_id, tab_id, extension_id,
+ source->id(), routing_id, port2_id, tab_id, extension_id,
channel_name));
return port1_id;
@@ -434,8 +435,8 @@ void ExtensionMessageService::Observe(NotificationType type,
for (ListenerMap::iterator it = listeners_.begin();
it != listeners_.end(); ) {
ListenerMap::iterator current = it++;
- if (current->second.count(renderer->pid()) != 0)
- RemoveEventListener(current->first, renderer->pid());
+ if (current->second.count(renderer->id()) != 0)
+ RemoveEventListener(current->first, renderer->id());
}
break;
}
diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc
index 05a61a1..a8731d9 100644
--- a/chrome/browser/extensions/extension_process_manager.cc
+++ b/chrome/browser/extensions/extension_process_manager.cc
@@ -185,7 +185,7 @@ void ExtensionProcessManager::Observe(NotificationType type,
case NotificationType::RENDERER_PROCESS_TERMINATED:
case NotificationType::RENDERER_PROCESS_CLOSED: {
RenderProcessHost* host = Source<RenderProcessHost>(source).ptr();
- UnregisterExtensionProcess(host->pid());
+ UnregisterExtensionProcess(host->id());
break;
}
diff --git a/chrome/browser/extensions/extensions_ui.cc b/chrome/browser/extensions/extensions_ui.cc
index 998ed32..8942c8d 100644
--- a/chrome/browser/extensions/extensions_ui.cc
+++ b/chrome/browser/extensions/extensions_ui.cc
@@ -317,7 +317,7 @@ std::vector<ExtensionPage> ExtensionsDOMHandler::GetActivePagesForExtension(
RenderViewHost* view = (*iter)->render_view_host();
if ((*iter)->extension_id() == extension_id && view) {
result.push_back(ExtensionPage((*iter)->url(),
- view->process()->pid(),
+ view->process()->id(),
view->routing_id()));
}
}
diff --git a/chrome/browser/extensions/user_script_listener.cc b/chrome/browser/extensions/user_script_listener.cc
index 94b58bf..086fc38 100644
--- a/chrome/browser/extensions/user_script_listener.cc
+++ b/chrome/browser/extensions/user_script_listener.cc
@@ -66,7 +66,7 @@ bool UserScriptListener::ShouldStartRequest(URLRequest* request) {
// Queue this request up.
delayed_request_ids_.push_front(ResourceDispatcherHost::GlobalRequestID(
- info->process_id, info->request_id));
+ info->child_id, info->request_id));
return false;
}
diff --git a/chrome/browser/extensions/user_script_listener_unittest.cc b/chrome/browser/extensions/user_script_listener_unittest.cc
index d4fb326..ee5299f 100644
--- a/chrome/browser/extensions/user_script_listener_unittest.cc
+++ b/chrome/browser/extensions/user_script_listener_unittest.cc
@@ -65,7 +65,7 @@ class ResourceDispatcherHostTester :
public base::RefCountedThreadSafe<ResourceDispatcherHostTester> {
public:
ResourceDispatcherHostTester(MessageLoop* io_loop)
- : Receiver(ChildProcessInfo::RENDER_PROCESS),
+ : Receiver(ChildProcessInfo::RENDER_PROCESS, -1),
host_(io_loop),
ui_loop_(MessageLoop::current()),
io_loop_(io_loop) {
@@ -136,7 +136,7 @@ class ResourceDispatcherHostTester :
// init the rest to default values to prevent getting UMR.
request.frame_origin = "null";
request.main_frame_origin = "null";
- request.origin_pid = 0;
+ request.origin_child_id = 0;
request.request_context = 0;
request.appcache_host_id = appcache::kNoHostId;
return request;
diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc
index 59c8a34..38d748e 100644
--- a/chrome/browser/external_tab_container.cc
+++ b/chrome/browser/external_tab_container.cc
@@ -429,8 +429,8 @@ void ExternalTabContainer::Observe(NotificationType type,
RenderViewHost* rvh = Details<RenderViewHost>(details).ptr();
if (rvh) {
AutomationResourceMessageFilter::RegisterRenderView(
- rvh->process()->pid(), rvh->routing_id(), tab_handle_,
- automation_resource_message_filter_);
+ rvh->process()->id(), rvh->routing_id(),
+ tab_handle_, automation_resource_message_filter_);
}
}
break;
@@ -440,7 +440,7 @@ void ExternalTabContainer::Observe(NotificationType type,
RenderViewHost* rvh = Details<RenderViewHost>(details).ptr();
if (rvh) {
AutomationResourceMessageFilter::UnRegisterRenderView(
- rvh->process()->pid(), rvh->routing_id());
+ rvh->process()->id(), rvh->routing_id());
}
}
break;
diff --git a/chrome/browser/history/download_types.h b/chrome/browser/history/download_types.h
index d3c80ed..80a2c5e 100644
--- a/chrome/browser/history/download_types.h
+++ b/chrome/browser/history/download_types.h
@@ -34,7 +34,7 @@ struct DownloadCreateInfo {
total_bytes(total_bytes),
state(state),
download_id(download_id),
- render_process_id(-1),
+ child_id(-1),
render_view_id(-1),
request_id(-1),
db_handle(0),
@@ -57,7 +57,7 @@ struct DownloadCreateInfo {
int64 total_bytes;
int32 state;
int32 download_id;
- int render_process_id;
+ int child_id;
int render_view_id;
int request_id;
int64 db_handle;
diff --git a/chrome/browser/memory_details.cc b/chrome/browser/memory_details.cc
index 124d33c..cfdafc3 100644
--- a/chrome/browser/memory_details.cc
+++ b/chrome/browser/memory_details.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// 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.
@@ -7,6 +7,7 @@
#include "app/l10n_util.h"
#include "base/file_version_info.h"
+#include "base/process_util.h"
#include "base/string_util.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_thread.h"
@@ -37,10 +38,9 @@ static ProcessData g_process_template[MemoryDetails::MAX_BROWSERS];
// expensive parts of this operation over on the file thread.
//
-MemoryDetails::MemoryDetails()
- : ui_loop_(NULL) {
+MemoryDetails::MemoryDetails() : ui_loop_(NULL) {
static const std::wstring google_browser_name =
- l10n_util::GetString(IDS_PRODUCT_NAME);
+ l10n_util::GetString(IDS_PRODUCT_NAME);
ProcessData g_process_template[MemoryDetails::MAX_BROWSERS] = {
{ google_browser_name.c_str(), L"chrome.exe", },
{ L"IE", L"iexplore.exe", },
@@ -78,7 +78,7 @@ void MemoryDetails::CollectChildInfoOnIOThread() {
// Collect the list of child processes.
for (ChildProcessHost::Iterator iter; !iter.Done(); ++iter) {
ProcessMemoryInformation info;
- info.pid = iter->GetProcessId();
+ info.pid = base::GetProcId(iter->handle());
if (!info.pid)
continue;
diff --git a/chrome/browser/net/url_request_tracking.cc b/chrome/browser/net/url_request_tracking.cc
new file mode 100644
index 0000000..f877782
--- /dev/null
+++ b/chrome/browser/net/url_request_tracking.cc
@@ -0,0 +1,47 @@
+// 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/browser/net/url_request_tracking.h"
+
+#include "base/basictypes.h"
+#include "net/url_request/url_request.h"
+
+namespace {
+
+// The value is not important, this address is used as the unique key for the
+// PID.
+const void* kOriginProcessUniqueIDKey = 0;
+
+class UniqueIDData : public URLRequest::UserData {
+ public:
+ UniqueIDData(int id) : id_(id) {}
+ virtual ~UniqueIDData() {}
+
+ int id() const { return id_; }
+ void set_id(int id) { id_ = id; }
+
+ private:
+ int id_;
+
+ DISALLOW_COPY_AND_ASSIGN(UniqueIDData);
+};
+
+} // namespace
+
+namespace chrome_browser_net {
+
+void SetOriginProcessUniqueIDForRequest(int id, URLRequest* request) {
+ // The request will take ownership.
+ request->SetUserData(&kOriginProcessUniqueIDKey, new UniqueIDData(id));
+}
+
+int GetOriginProcessUniqueIDForRequest(const URLRequest* request) {
+ const UniqueIDData* data = static_cast<const UniqueIDData*>(
+ request->GetUserData(&kOriginProcessUniqueIDKey));
+ if (!data)
+ return -1;
+ return data->id();
+}
+
+} // namespace chrome_browser_net
diff --git a/chrome/browser/net/url_request_tracking.h b/chrome/browser/net/url_request_tracking.h
new file mode 100644
index 0000000..c0a3e9e
--- /dev/null
+++ b/chrome/browser/net/url_request_tracking.h
@@ -0,0 +1,35 @@
+// 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_BROWSER_NET_URL_REQUEST_TRACKING_H_
+#define CHROME_BROWSER_NET_URL_REQUEST_TRACKING_H_
+
+class URLRequest;
+
+namespace chrome_browser_net {
+
+// Sets the given ID on the given request for later retrieval. This information
+// duplicates a field in the ResourceDispatcherHost's user data, but is also
+// set for non-ResourceDispatcher-related requests. Having this one global
+// place allows us to do more general things, such as assigning traffic for the
+// network view in the task manager.
+//
+// If you make a request on behalf of a child process, please call this
+// function. The default value will be -1 which will be interprepreted as
+// originating from the browser itself.
+//
+// The ID is the child process' unique ID (not a PID) of the process originating
+// the request. This is normally the renderer corresponding to the load. If a
+// plugin process does a request through a renderer process this will be the
+// plugin (the originator of the request).
+void SetOriginProcessUniqueIDForRequest(int id, URLRequest* request);
+
+// Returns the child process' unique ID that has been previously set by
+// SetOriginProcessUniqueIDForRequest. If no ID has been set, the return
+// value is -1. We use this to identify requests made by the browser process.
+int GetOriginProcessUniqueIDForRequest(const URLRequest* request);
+
+} // namespace chrome_browser_net
+
+#endif // CHROME_BROWSER_NET_URL_REQUEST_TRACKING_H_
diff --git a/chrome/browser/plugin_process_host.cc b/chrome/browser/plugin_process_host.cc
index 5987c5e..4bb2924 100644
--- a/chrome/browser/plugin_process_host.cc
+++ b/chrome/browser/plugin_process_host.cc
@@ -31,6 +31,7 @@
#include "chrome/browser/child_process_security_policy.h"
#include "chrome/browser/chrome_plugin_browsing_context.h"
#include "chrome/browser/chrome_thread.h"
+#include "chrome/browser/net/url_request_tracking.h"
#include "chrome/browser/plugin_service.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/renderer_host/browser_render_process_host.h"
@@ -114,19 +115,20 @@ class PluginDownloadUrlHelper : public URLRequest::Delegate {
gfx::NativeWindow download_file_caller_window_;
std::string download_url_;
- int download_source_pid_;
+ int download_source_child_unique_id_;
DISALLOW_EVIL_CONSTRUCTORS(PluginDownloadUrlHelper);
};
PluginDownloadUrlHelper::PluginDownloadUrlHelper(
const std::string& download_url,
- int source_pid, gfx::NativeWindow caller_window)
+ int source_child_unique_id,
+ gfx::NativeWindow caller_window)
: download_file_request_(NULL),
download_file_buffer_(new net::IOBuffer(kDownloadFileBufferSize)),
download_file_caller_window_(caller_window),
download_url_(download_url),
- download_source_pid_(source_pid) {
+ download_source_child_unique_id_(source_child_unique_id) {
DCHECK(::IsWindow(caller_window));
memset(download_file_buffer_->data(), 0, kDownloadFileBufferSize);
download_file_.reset(new net::FileStream());
@@ -140,8 +142,9 @@ PluginDownloadUrlHelper::~PluginDownloadUrlHelper() {
}
void PluginDownloadUrlHelper::InitiateDownload() {
- download_file_request_= new URLRequest(GURL(download_url_), this);
- download_file_request_->set_origin_pid(download_source_pid_);
+ download_file_request_ = new URLRequest(GURL(download_url_), this);
+ chrome_browser_net::SetOriginProcessUniqueIDForRequest(
+ download_source_child_unique_id_, download_file_request_);
download_file_request_->set_context(Profile::GetDefaultRequestContext());
download_file_request_->Start();
}
@@ -592,7 +595,7 @@ void PluginProcessHost::RequestPluginChannel(
// a deadlock can occur if the plugin creation request from the renderer is
// a result of a sync message by the plugin process.
PluginProcessMsg_CreateChannel* msg = new PluginProcessMsg_CreateChannel(
- renderer_message_filter->GetProcessId(),
+ renderer_message_filter->id(),
renderer_message_filter->off_the_record());
msg->set_unblock(true);
if (Send(msg)) {
diff --git a/chrome/browser/plugin_process_host.h b/chrome/browser/plugin_process_host.h
index 22e9249..cf526b4 100644
--- a/chrome/browser/plugin_process_host.h
+++ b/chrome/browser/plugin_process_host.h
@@ -108,7 +108,7 @@ class PluginProcessHost : public ChildProcessHost,
#if defined(OS_WIN)
void OnPluginWindowDestroyed(HWND window, HWND parent);
- void OnDownloadUrl(const std::string& url, int source_pid,
+ void OnDownloadUrl(const std::string& url, int source_child_unique_id,
gfx::NativeWindow caller_window);
#endif
diff --git a/chrome/browser/privacy_blacklist/blacklist_observer.cc b/chrome/browser/privacy_blacklist/blacklist_observer.cc
index d93dbfe..77f1177 100644
--- a/chrome/browser/privacy_blacklist/blacklist_observer.cc
+++ b/chrome/browser/privacy_blacklist/blacklist_observer.cc
@@ -24,7 +24,7 @@ class BlockedContentNotice : public Task {
const ResourceDispatcherHost::ExtraRequestInfo* info)
: gurl_(gurl),
match_(match),
- process_id_(info->process_id),
+ child_id_(info->child_id),
route_id_(info->route_id) {
if (match_->attributes() & Blacklist::kDontStoreCookies) {
// No cookies stored.
@@ -39,7 +39,7 @@ class BlockedContentNotice : public Task {
}
virtual void Run() {
- RenderViewHost* view = RenderViewHost::FromID(process_id_, route_id_);
+ RenderViewHost* view = RenderViewHost::FromID(child_id_, route_id_);
if (!view)
return; // The view may be gone by the time we get here.
@@ -49,7 +49,7 @@ class BlockedContentNotice : public Task {
private:
const GURL gurl_;
const Blacklist::Match* match_;
- const int process_id_;
+ const int child_id_;
const int route_id_;
string16 reason_;
diff --git a/chrome/browser/renderer_host/audio_renderer_host.cc b/chrome/browser/renderer_host/audio_renderer_host.cc
index e552f81..c66e0b13 100644
--- a/chrome/browser/renderer_host/audio_renderer_host.cc
+++ b/chrome/browser/renderer_host/audio_renderer_host.cc
@@ -62,18 +62,18 @@ AudioRendererHost::IPCAudioSource::~IPCAudioSource() {
// static
AudioRendererHost::IPCAudioSource*
- AudioRendererHost::IPCAudioSource::CreateIPCAudioSource(
- AudioRendererHost* host,
- int process_id,
- int route_id,
- int stream_id,
- base::ProcessHandle process_handle,
- AudioManager::Format format,
- int channels,
- int sample_rate,
- char bits_per_sample,
- size_t decoded_packet_size,
- size_t buffer_capacity) {
+AudioRendererHost::IPCAudioSource::CreateIPCAudioSource(
+ AudioRendererHost* host,
+ int process_id,
+ int route_id,
+ int stream_id,
+ base::ProcessHandle process_handle,
+ AudioManager::Format format,
+ int channels,
+ int sample_rate,
+ char bits_per_sample,
+ size_t decoded_packet_size,
+ size_t buffer_capacity) {
// Perform come preliminary checks on the parameters.
// Make sure the renderer didn't ask for too much memory.
if (buffer_capacity > kMaxBufferCapacity ||
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index 688fa82..65b948a5 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -214,19 +214,11 @@ BrowserRenderProcessHost::BrowserRenderProcessHost(Profile* profile)
registrar_.Add(this, NotificationType::USER_SCRIPTS_UPDATED,
NotificationService::AllSources());
-
- if (run_renderer_in_process()) {
- // We need a "renderer pid", but we don't have one when there's no renderer
- // process. So pick a value that won't clash with other child process pids.
- // Linux has PID_MAX_LIMIT which is 2^22. Windows always uses pids that are
- // divisible by 4. So...
- static int next_pid = 4 * 1024 * 1024;
- next_pid += 3;
- SetProcessID(next_pid);
- }
-
visited_link_updater_.reset(new VisitedLinkUpdater());
+ WebCacheManager::GetInstance()->Add(id());
+ ChildProcessSecurityPolicy::GetInstance()->Add(id());
+
// Note: When we create the BrowserRenderProcessHost, it's technically
// backgrounded, because it has no visible listeners. But the process
// doesn't actually exist yet, so we'll Background it later, after
@@ -234,10 +226,8 @@ BrowserRenderProcessHost::BrowserRenderProcessHost(Profile* profile)
}
BrowserRenderProcessHost::~BrowserRenderProcessHost() {
- if (pid() >= 0) {
- WebCacheManager::GetInstance()->Remove(pid());
- ChildProcessSecurityPolicy::GetInstance()->Remove(pid());
- }
+ WebCacheManager::GetInstance()->Remove(id());
+ ChildProcessSecurityPolicy::GetInstance()->Remove(id());
// We may have some unsent messages at this point, but that's OK.
channel_.reset();
@@ -274,6 +264,7 @@ bool BrowserRenderProcessHost::Init() {
scoped_refptr<ResourceMessageFilter> resource_message_filter =
new ResourceMessageFilter(g_browser_process->resource_dispatcher_host(),
+ id(),
audio_renderer_host_.get(),
PluginService::GetInstance(),
g_browser_process->print_job_manager(),
@@ -463,12 +454,9 @@ bool BrowserRenderProcessHost::Init() {
return false;
}
process_.set_handle(process);
- SetProcessID(process_.pid());
}
- resource_message_filter->Init(pid());
- WebCacheManager::GetInstance()->Add(pid());
- ChildProcessSecurityPolicy::GetInstance()->Add(pid());
+ resource_message_filter->Init();
// Now that the process is created, set its backgrounding accordingly.
SetBackgrounded(backgrounded_);
@@ -855,8 +843,7 @@ void BrowserRenderProcessHost::OnChannelError() {
if (child_exited)
process_.Close();
- WebCacheManager::GetInstance()->Remove(pid());
- ChildProcessSecurityPolicy::GetInstance()->Remove(pid());
+ WebCacheManager::GetInstance()->Remove(id());
channel_.reset();
@@ -874,8 +861,8 @@ void BrowserRenderProcessHost::OnChannelError() {
}
void BrowserRenderProcessHost::OnPageContents(const GURL& url,
- int32 page_id,
- const std::wstring& contents) {
+ int32 page_id,
+ const std::wstring& contents) {
Profile* p = profile();
if (!p || p->IsOffTheRecord())
return;
@@ -887,7 +874,7 @@ void BrowserRenderProcessHost::OnPageContents(const GURL& url,
void BrowserRenderProcessHost::OnUpdatedCacheStats(
const WebCache::UsageStats& stats) {
- WebCacheManager::GetInstance()->ObserveStats(pid(), stats);
+ WebCacheManager::GetInstance()->ObserveStats(id(), stats);
}
void BrowserRenderProcessHost::SuddenTerminationChanged(bool enabled) {
@@ -961,16 +948,16 @@ void BrowserRenderProcessHost::Observe(NotificationType type,
void BrowserRenderProcessHost::OnExtensionAddListener(
const std::string& event_name) {
if (profile()->GetExtensionMessageService()) {
- profile()->GetExtensionMessageService()->AddEventListener(event_name,
- pid());
+ profile()->GetExtensionMessageService()->AddEventListener(
+ event_name, id());
}
}
void BrowserRenderProcessHost::OnExtensionRemoveListener(
const std::string& event_name) {
if (profile()->GetExtensionMessageService()) {
- profile()->GetExtensionMessageService()->RemoveEventListener(event_name,
- pid());
+ profile()->GetExtensionMessageService()->RemoveEventListener(
+ event_name, id());
}
}
diff --git a/chrome/browser/renderer_host/buffered_resource_handler.cc b/chrome/browser/renderer_host/buffered_resource_handler.cc
index 1494f2a..bfe9005 100644
--- a/chrome/browser/renderer_host/buffered_resource_handler.cc
+++ b/chrome/browser/renderer_host/buffered_resource_handler.cc
@@ -291,12 +291,12 @@ bool BufferedResourceHandler::CompleteResponseStarted(int request_id,
scoped_refptr<DownloadThrottlingResourceHandler> download_handler =
new DownloadThrottlingResourceHandler(host_,
- request_,
- request_->url(),
- info->process_id,
- info->route_id,
- request_id,
- in_complete);
+ request_,
+ request_->url(),
+ info->child_id,
+ info->route_id,
+ request_id,
+ in_complete);
if (bytes_read_) {
// a Read has already occurred and we need to copy the data into the
// EventHandler.
@@ -329,7 +329,7 @@ bool BufferedResourceHandler::ShouldWaitForPlugins() {
// We don't want to keep buffering as our buffer will fill up.
ResourceDispatcherHost::ExtraRequestInfo* info =
ResourceDispatcherHost::ExtraInfoForRequest(request_);
- host_->PauseRequest(info->process_id, info->request_id, true);
+ host_->PauseRequest(info->child_id, info->request_id, true);
// Schedule plugin loading on the file thread.
// Note: it's possible that the only reference to this object is the task. If
@@ -429,9 +429,9 @@ void BufferedResourceHandler::OnPluginsLoaded() {
if (request_) {
ResourceDispatcherHost::ExtraRequestInfo* info =
ResourceDispatcherHost::ExtraInfoForRequest(request_);
- host_->PauseRequest(info->process_id, info->request_id, false);
+ host_->PauseRequest(info->child_id, info->request_id, false);
if (!CompleteResponseStarted(info->request_id, false))
- host_->CancelRequest(info->process_id, info->request_id, false);
+ host_->CancelRequest(info->child_id, info->request_id, false);
}
Release();
}
diff --git a/chrome/browser/renderer_host/download_resource_handler.cc b/chrome/browser/renderer_host/download_resource_handler.cc
index 8b189bf..8ac8ac0 100644
--- a/chrome/browser/renderer_host/download_resource_handler.cc
+++ b/chrome/browser/renderer_host/download_resource_handler.cc
@@ -61,7 +61,7 @@ bool DownloadResourceHandler::OnResponseStarted(int request_id,
info->total_bytes = content_length_;
info->state = DownloadItem::IN_PROGRESS;
info->download_id = download_id_;
- info->render_process_id = global_id_.process_id;
+ info->child_id = global_id_.child_id;
info->render_view_id = render_view_id_;
info->request_id = global_id_.request_id;
info->content_disposition = content_disposition_;
@@ -166,8 +166,7 @@ void DownloadResourceHandler::CheckWriteProgress() {
StartPauseTimer();
if (is_paused_ != should_pause) {
- rdh_->PauseRequest(global_id_.process_id,
- global_id_.request_id,
+ rdh_->PauseRequest(global_id_.child_id, global_id_.request_id,
should_pause);
is_paused_ = should_pause;
}
diff --git a/chrome/browser/renderer_host/mock_render_process_host.cc b/chrome/browser/renderer_host/mock_render_process_host.cc
index 1dadafd..951a648b 100644
--- a/chrome/browser/renderer_host/mock_render_process_host.cc
+++ b/chrome/browser/renderer_host/mock_render_process_host.cc
@@ -8,12 +8,9 @@ MockRenderProcessHost::MockRenderProcessHost(Profile* profile)
: RenderProcessHost(profile),
transport_dib_(NULL),
bad_msg_count_(0) {
- static int prev_pid = 0;
- SetProcessID(++prev_pid);
}
MockRenderProcessHost::~MockRenderProcessHost() {
- RemoveFromList();
delete transport_dib_;
}
diff --git a/chrome/browser/renderer_host/render_process_host.cc b/chrome/browser/renderer_host/render_process_host.cc
index bbec190..1dd4ec4 100644
--- a/chrome/browser/renderer_host/render_process_host.cc
+++ b/chrome/browser/renderer_host/render_process_host.cc
@@ -7,6 +7,7 @@
#include "base/rand_util.h"
#include "base/sys_info.h"
#include "chrome/browser/child_process_security_policy.h"
+#include "chrome/common/child_process_info.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/notification_service.h"
@@ -55,19 +56,14 @@ size_t GetMaxRendererProcessCount() {
// associated with the given profile.
static bool IsSuitableHost(RenderProcessHost* host, Profile* profile,
RenderProcessHost::Type type) {
- // If the host doesn't have a PID yet, we don't know what it will be used
- // for, so just say it's unsuitable to be safe.
- if (host->pid() == -1)
- return false;
-
if (host->profile() != profile)
return false;
RenderProcessHost::Type host_type = RenderProcessHost::TYPE_NORMAL;
- if (ChildProcessSecurityPolicy::GetInstance()->HasDOMUIBindings(host->pid()))
+ if (ChildProcessSecurityPolicy::GetInstance()->HasDOMUIBindings(host->id()))
host_type = RenderProcessHost::TYPE_DOMUI;
if (ChildProcessSecurityPolicy::GetInstance()->
- HasExtensionBindings(host->pid()))
+ HasExtensionBindings(host->id()))
host_type = RenderProcessHost::TYPE_EXTENSION;
return host_type == type;
@@ -82,14 +78,16 @@ bool RenderProcessHost::run_renderer_in_process_ = false;
RenderProcessHost::RenderProcessHost(Profile* profile)
: max_page_id_(-1),
- pid_(-1),
+ id_(ChildProcessInfo::GenerateChildProcessUniqueId()),
profile_(profile),
sudden_termination_allowed_(true),
ignore_input_events_(false) {
+ all_hosts.AddWithID(this, id());
all_hosts.set_check_on_null_data(true);
}
RenderProcessHost::~RenderProcessHost() {
+ all_hosts.Remove(id());
}
void RenderProcessHost::Attach(IPC::Channel::Listener* listener,
@@ -109,8 +107,6 @@ void RenderProcessHost::Release(int listener_id) {
NotificationService::current()->Notify(
NotificationType::RENDERER_PROCESS_TERMINATED,
Source<RenderProcessHost>(this), NotificationService::NoDetails());
- if (pid_ >= 0)
- all_hosts.Remove(pid_);
MessageLoop::current()->DeleteSoon(FROM_HERE, this);
}
}
@@ -173,18 +169,3 @@ RenderProcessHost* RenderProcessHost::GetExistingProcessHost(Profile* profile,
return NULL;
}
-
-void RenderProcessHost::SetProcessID(int pid) {
- if (pid_ != -1) {
- // This object is being reused after a renderer crash. Remove the old pid.
- all_hosts.Remove(pid_);
- }
-
- pid_ = pid;
- all_hosts.AddWithID(this, pid);
-}
-
-void RenderProcessHost::RemoveFromList() {
- if (all_hosts.Lookup(pid_))
- all_hosts.Remove(pid_);
-}
diff --git a/chrome/browser/renderer_host/render_process_host.h b/chrome/browser/renderer_host/render_process_host.h
index 4c12084..22d5b90 100644
--- a/chrome/browser/renderer_host/render_process_host.h
+++ b/chrome/browser/renderer_host/render_process_host.h
@@ -46,10 +46,13 @@ class RenderProcessHost : public IPC::Channel::Sender,
// Returns the user profile associated with this renderer process.
Profile* profile() const { return profile_; }
- // Returns the process id for this host. This can be used later in
+ // Returns the unique ID for this child process. This can be used later in
// a call to FromID() to get back to this object (this is used to avoid
// sending non-threadsafe pointers to other threads).
- int pid() const { return pid_; }
+ //
+ // This ID will be unique for all child processes, including workers, plugins,
+ // etc. It is generated by ChildProcessInfo.
+ int id() const { return id_; }
// Returns the process object associated with the child process. In certain
// tests or single-process mode, this will actually represent the current
@@ -211,12 +214,6 @@ class RenderProcessHost : public IPC::Channel::Sender,
static RenderProcessHost* GetExistingProcessHost(Profile* profile, Type type);
protected:
- // Sets the process of this object, so that others access it using FromID.
- void SetProcessID(int pid);
-
- // For testing. Removes this host from the list of hosts.
- void RemoveFromList();
-
base::Process process_;
// A proxy for our IPC::Channel that lives on the IO thread (see
@@ -231,7 +228,8 @@ class RenderProcessHost : public IPC::Channel::Sender,
int32 max_page_id_;
private:
- int pid_;
+ // The globally-uniqe identifier for this RPH.
+ int id_;
Profile* profile_;
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 1f3c10a..41cbd00 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -137,7 +137,7 @@ RenderViewHost::~RenderViewHost() {
// Be sure to clean up any leftover state from cross-site requests.
Singleton<CrossSiteRequestManager>()->SetHasPendingCrossSiteRequest(
- process()->pid(), routing_id(), false);
+ process()->id(), routing_id(), false);
}
void RenderViewHost::Observe(NotificationType type,
@@ -176,12 +176,12 @@ bool RenderViewHost::CreateRenderView() {
if (BindingsPolicy::is_dom_ui_enabled(enabled_bindings_)) {
ChildProcessSecurityPolicy::GetInstance()->GrantDOMUIBindings(
- process()->pid());
+ process()->id());
}
if (BindingsPolicy::is_extension_enabled(enabled_bindings_)) {
ChildProcessSecurityPolicy::GetInstance()->GrantExtensionBindings(
- process()->pid());
+ process()->id());
}
renderer_initialized_ = true;
@@ -252,7 +252,7 @@ void RenderViewHost::SyncRendererPrefs() {
void RenderViewHost::Navigate(const ViewMsg_Navigate_Params& params) {
ChildProcessSecurityPolicy::GetInstance()->GrantRequestURL(
- process()->pid(), params.url);
+ process()->id(), params.url);
ViewMsg_Navigate* nav_message = new ViewMsg_Navigate(routing_id(), params);
@@ -354,7 +354,7 @@ void RenderViewHost::ClosePage(bool for_cross_site_transition,
StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS));
ViewMsg_ClosePage_Params params;
- params.closing_process_id = process()->pid();
+ params.closing_process_id = process()->id();
params.closing_route_id = routing_id();
params.for_cross_site_transition = for_cross_site_transition;
params.new_render_process_host_id = new_render_process_host_id;
@@ -380,7 +380,7 @@ void RenderViewHost::ClosePageIgnoringUnloadEvents() {
void RenderViewHost::SetHasPendingCrossSiteRequest(bool has_pending_request,
int request_id) {
Singleton<CrossSiteRequestManager>()->SetHasPendingCrossSiteRequest(
- process()->pid(), routing_id(), has_pending_request);
+ process()->id(), routing_id(), has_pending_request);
pending_request_id_ = request_id;
}
@@ -464,12 +464,13 @@ void RenderViewHost::DragTargetDragEnter(
// Grant the renderer the ability to load the drop_data.
ChildProcessSecurityPolicy* policy =
ChildProcessSecurityPolicy::GetInstance();
- policy->GrantRequestURL(process()->pid(), drop_data.url);
+ policy->GrantRequestURL(process()->id(), drop_data.url);
for (std::vector<string16>::const_iterator iter(drop_data.filenames.begin());
iter != drop_data.filenames.end(); ++iter) {
FilePath path = FilePath::FromWStringHack(UTF16ToWideHack(*iter));
- policy->GrantRequestURL(process()->pid(), net::FilePathToFileURL(path));
- policy->GrantUploadFile(process()->pid(), path);
+ policy->GrantRequestURL(process()->id(),
+ net::FilePathToFileURL(path));
+ policy->GrantUploadFile(process()->id(), path);
}
Send(new ViewMsg_DragTargetDragEnter(routing_id(), drop_data, client_pt,
screen_pt));
@@ -680,8 +681,8 @@ void RenderViewHost::InstallMissingPlugin() {
}
void RenderViewHost::FileSelected(const FilePath& path) {
- ChildProcessSecurityPolicy::GetInstance()->GrantUploadFile(process()->pid(),
- path);
+ ChildProcessSecurityPolicy::GetInstance()->GrantUploadFile(
+ process()->id(), path);
std::vector<FilePath> files;
files.push_back(path);
Send(new ViewMsg_RunFileChooserResponse(routing_id(), files));
@@ -692,7 +693,7 @@ void RenderViewHost::MultiFilesSelected(
for (std::vector<FilePath>::const_iterator file = files.begin();
file != files.end(); ++file) {
ChildProcessSecurityPolicy::GetInstance()->GrantUploadFile(
- process()->pid(), *file);
+ process()->id(), *file);
}
Send(new ViewMsg_RunFileChooserResponse(routing_id(), files));
}
@@ -935,7 +936,7 @@ void RenderViewHost::OnMsgNavigate(const IPC::Message& msg) {
Read(&msg, &iter, &validated_params))
return;
- const int renderer_id = process()->pid();
+ const int renderer_id = process()->id();
ChildProcessSecurityPolicy* policy =
ChildProcessSecurityPolicy::GetInstance();
// Without this check, an evil renderer can trick the browser into creating
@@ -1047,7 +1048,7 @@ void RenderViewHost::OnMsgDidStartProvisionalLoadForFrame(bool is_main_frame,
const GURL& url) {
GURL validated_url(url);
FilterURL(ChildProcessSecurityPolicy::GetInstance(),
- process()->pid(), &validated_url);
+ process()->id(), &validated_url);
RenderViewHostDelegate::Resource* resource_delegate =
delegate_->GetResourceDelegate();
@@ -1064,7 +1065,7 @@ void RenderViewHost::OnMsgDidFailProvisionalLoadWithError(
bool showing_repost_interstitial) {
GURL validated_url(url);
FilterURL(ChildProcessSecurityPolicy::GetInstance(),
- process()->pid(), &validated_url);
+ process()->id(), &validated_url);
RenderViewHostDelegate::Resource* resource_delegate =
delegate_->GetResourceDelegate();
@@ -1139,7 +1140,7 @@ void RenderViewHost::OnMsgContextMenu(const ContextMenuParams& params) {
// Validate the URLs in |params|. If the renderer can't request the URLs
// directly, don't show them in the context menu.
ContextMenuParams validated_params(params);
- const int renderer_id = process()->pid();
+ int renderer_id = process()->id();
ChildProcessSecurityPolicy* policy =
ChildProcessSecurityPolicy::GetInstance();
@@ -1158,7 +1159,7 @@ void RenderViewHost::OnMsgOpenURL(const GURL& url,
WindowOpenDisposition disposition) {
GURL validated_url(url);
FilterURL(ChildProcessSecurityPolicy::GetInstance(),
- process()->pid(), &validated_url);
+ process()->id(), &validated_url);
delegate_->RequestOpenURL(validated_url, referrer, disposition);
}
@@ -1184,7 +1185,7 @@ void RenderViewHost::OnMsgDomOperationResponse(
void RenderViewHost::OnMsgDOMUISend(
const std::string& message, const std::string& content) {
if (!ChildProcessSecurityPolicy::GetInstance()->
- HasDOMUIBindings(process()->pid())) {
+ HasDOMUIBindings(process()->id())) {
NOTREACHED() << "Blocked unauthorized use of DOMUIBindings.";
return;
}
@@ -1607,7 +1608,7 @@ void RenderViewHost::OnExtensionRequest(const std::string& name,
int request_id,
bool has_callback) {
if (!ChildProcessSecurityPolicy::GetInstance()->
- HasExtensionBindings(process()->pid())) {
+ HasExtensionBindings(process()->id())) {
NOTREACHED() << "Blocked unauthorized use of extension bindings.";
return;
}
@@ -1632,8 +1633,8 @@ void RenderViewHost::OnExtensionPostMessage(
void RenderViewHost::OnAccessibilityFocusChange(int acc_obj_id) {
#if defined(OS_WIN)
- BrowserAccessibilityManager::GetInstance()->
- ChangeAccessibilityFocus(acc_obj_id, process()->pid(), routing_id());
+ BrowserAccessibilityManager::GetInstance()->ChangeAccessibilityFocus(
+ acc_obj_id, process()->id(), routing_id());
#else
// TODO(port): accessibility not yet implemented. See http://crbug.com/8288.
#endif
diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.cc b/chrome/browser/renderer_host/render_widget_host_view_win.cc
index d4d51bb..8409006 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_win.cc
+++ b/chrome/browser/renderer_host/render_widget_host_view_win.cc
@@ -12,6 +12,7 @@
#include "base/gfx/gdi_util.h"
#include "base/gfx/rect.h"
#include "base/histogram.h"
+#include "base/process_util.h"
#include "base/thread.h"
#include "base/win_util.h"
#include "chrome/browser/browser_accessibility_manager.h"
@@ -171,7 +172,7 @@ class NotifyPluginProcessHostTask : public Task {
for (ChildProcessHost::Iterator iter(ChildProcessInfo::PLUGIN_PROCESS);
!iter.Done(); ++iter) {
PluginProcessHost* plugin = static_cast<PluginProcessHost*>(*iter);
- if (plugin->GetProcessId() == plugin_process_id) {
+ if (base::GetProcId(plugin->handle()) == plugin_process_id) {
plugin->AddWindow(parent_);
return;
}
@@ -1216,12 +1217,11 @@ LRESULT RenderWidgetHostViewWin::OnGetObject(UINT message, WPARAM wparam,
if (!browser_accessibility_root_) {
// Create a new instance of IAccessible. Root id is 1000, to avoid
// conflicts with the ids used by MSAA.
- BrowserAccessibilityManager::GetInstance()->
- CreateAccessibilityInstance(IID_IAccessible, 1000,
- render_widget_host_->routing_id(),
- render_widget_host_->process()->pid(),
- m_hWnd, reinterpret_cast<void **>
- (&browser_accessibility_root_));
+ BrowserAccessibilityManager::GetInstance()->CreateAccessibilityInstance(
+ IID_IAccessible, 1000,
+ render_widget_host_->routing_id(),
+ render_widget_host_->process()->id(),
+ m_hWnd, reinterpret_cast<void **>(&browser_accessibility_root_));
if (!browser_accessibility_root_) {
// No valid root found, return with failure.
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.cc b/chrome/browser/renderer_host/resource_dispatcher_host.cc
index b205fd0..7d42929 100644
--- a/chrome/browser/renderer_host/resource_dispatcher_host.cc
+++ b/chrome/browser/renderer_host/resource_dispatcher_host.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// 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.
@@ -26,6 +26,7 @@
#include "chrome/browser/in_process_webkit/webkit_thread.h"
#include "chrome/browser/login_prompt.h"
#include "chrome/browser/net/chrome_url_request_context.h"
+#include "chrome/browser/net/url_request_tracking.h"
#include "chrome/browser/plugin_service.h"
#include "chrome/browser/privacy_blacklist/blacklist.h"
#include "chrome/browser/privacy_blacklist/blocked_response.h"
@@ -195,7 +196,7 @@ class RVHDelegateNotificationTask : public Task {
// disallowed if the renderer is not authorized to retrieve the request URL or
// if the renderer is attempting to upload an unauthorized file.
bool ShouldServiceRequest(ChildProcessInfo::ProcessType process_type,
- int process_id,
+ int child_id,
const ViewHostMsg_Resource_Request& request_data) {
if (process_type == ChildProcessInfo::PLUGIN_PROCESS)
return true;
@@ -204,7 +205,7 @@ bool ShouldServiceRequest(ChildProcessInfo::ProcessType process_type,
ChildProcessSecurityPolicy::GetInstance();
// Check if the renderer is permitted to request the requested URL.
- if (!policy->CanRequestURL(process_id, request_data.url)) {
+ if (!policy->CanRequestURL(child_id, request_data.url)) {
LOG(INFO) << "Denied unauthorized request for " <<
request_data.url.possibly_invalid_spec();
return false;
@@ -217,7 +218,7 @@ bool ShouldServiceRequest(ChildProcessInfo::ProcessType process_type,
std::vector<net::UploadData::Element>::const_iterator iter;
for (iter = uploads.begin(); iter != uploads.end(); ++iter) {
if (iter->type() == net::UploadData::TYPE_FILE &&
- !policy->CanUploadFile(process_id, iter->file_path())) {
+ !policy->CanUploadFile(child_id, iter->file_path())) {
NOTREACHED() << "Denied unauthorized upload of "
<< iter->file_path().value();
return false;
@@ -314,7 +315,7 @@ void ResourceDispatcherHost::OnShutdown() {
}
bool ResourceDispatcherHost::HandleExternalProtocol(int request_id,
- int process_id,
+ int child_id,
int route_id,
const GURL& url,
ResourceType::Type type,
@@ -323,7 +324,7 @@ bool ResourceDispatcherHost::HandleExternalProtocol(int request_id,
return false;
ui_loop_->PostTask(FROM_HERE, NewRunnableFunction(
- &ExternalProtocolHandler::LaunchUrl, url, process_id, route_id));
+ &ExternalProtocolHandler::LaunchUrl, url, child_id, route_id));
handler->OnResponseCompleted(request_id, URLRequestStatus(
URLRequestStatus::FAILED,
@@ -384,15 +385,16 @@ void ResourceDispatcherHost::BeginRequest(
IPC::Message* sync_result, // only valid for sync
int route_id) {
ChildProcessInfo::ProcessType process_type = receiver_->type();
- int process_id = receiver_->GetProcessId();
+ int child_id = receiver_->id();
ChromeURLRequestContext* context = static_cast<ChromeURLRequestContext*>(
receiver_->GetRequestContext(request_id, request_data));
- if (!context)
+ if (!context) {
context = static_cast<ChromeURLRequestContext*>(
Profile::GetDefaultRequestContext());
+ }
if (is_shutdown_ ||
- !ShouldServiceRequest(process_type, process_id, request_data)) {
+ !ShouldServiceRequest(process_type, child_id, request_data)) {
URLRequestStatus status(URLRequestStatus::FAILED, net::ERR_ABORTED);
if (sync_result) {
SyncLoadResult result;
@@ -479,14 +481,14 @@ void ResourceDispatcherHost::BeginRequest(
handler = new SyncResourceHandler(receiver_, request_data.url, sync_result);
} else {
handler = new AsyncResourceHandler(receiver_,
- process_id,
+ child_id,
route_id,
receiver_->handle(),
request_data.url,
this);
}
- if (HandleExternalProtocol(request_id, process_id, route_id,
+ if (HandleExternalProtocol(request_id, child_id, route_id,
request_data.url, request_data.resource_type,
handler)) {
return;
@@ -513,7 +515,6 @@ void ResourceDispatcherHost::BeginRequest(
load_flags |= net::LOAD_VERIFY_EV_CERT;
request->set_load_flags(load_flags);
request->set_context(context);
- request->set_origin_pid(request_data.origin_pid);
if (IsHttpPrioritizationEnabled()) {
// If the request is for the top level page or a frame/iframe, then we
@@ -540,11 +541,11 @@ void ResourceDispatcherHost::BeginRequest(
if (request_data.resource_type == ResourceType::MAIN_FRAME &&
process_type == ChildProcessInfo::RENDER_PROCESS &&
Singleton<CrossSiteRequestManager>::get()->
- HasPendingCrossSiteRequest(process_id, route_id)) {
+ HasPendingCrossSiteRequest(child_id, route_id)) {
// Wrap the event handler to be sure the current page's onunload handler
// has a chance to run before we render the new page.
handler = new CrossSiteResourceHandler(handler,
- process_id,
+ child_id,
route_id,
this);
}
@@ -552,7 +553,7 @@ void ResourceDispatcherHost::BeginRequest(
if (safe_browsing_->enabled() &&
safe_browsing_->CanCheckUrl(request_data.url)) {
handler = new SafeBrowsingResourceHandler(handler,
- process_id,
+ child_id,
route_id,
request_data.url,
request_data.resource_type,
@@ -568,7 +569,7 @@ void ResourceDispatcherHost::BeginRequest(
ExtraRequestInfo* extra_info =
new ExtraRequestInfo(handler,
process_type,
- process_id,
+ child_id,
route_id,
request_id,
request_data.frame_origin,
@@ -577,18 +578,21 @@ void ResourceDispatcherHost::BeginRequest(
upload_size);
extra_info->allow_download =
ResourceType::IsFrame(request_data.resource_type);
- SetExtraInfoForRequest(request, extra_info); // request takes ownership
+ SetExtraInfoForRequest(request, extra_info); // Request takes ownership.
+ chrome_browser_net::SetOriginProcessUniqueIDForRequest(
+ request_data.origin_child_id, request);
BeginRequestInternal(request);
}
void ResourceDispatcherHost::OnDataReceivedACK(int request_id) {
- DataReceivedACK(receiver_->GetProcessId(), request_id);
+ DataReceivedACK(receiver_->id(), request_id);
}
-void ResourceDispatcherHost::DataReceivedACK(int process_id, int request_id) {
+void ResourceDispatcherHost::DataReceivedACK(int child_id,
+ int request_id) {
PendingRequestList::iterator i = pending_requests_.find(
- GlobalRequestID(process_id, request_id));
+ GlobalRequestID(child_id, request_id));
if (i == pending_requests_.end())
return;
@@ -604,14 +608,14 @@ void ResourceDispatcherHost::DataReceivedACK(int process_id, int request_id) {
info->pending_data_count--;
// Resume the request.
- PauseRequest(process_id, request_id, false);
+ PauseRequest(child_id, request_id, false);
}
}
void ResourceDispatcherHost::OnUploadProgressACK(int request_id) {
- int process_id = receiver_->GetProcessId();
+ int child_id = receiver_->id();
PendingRequestList::iterator i = pending_requests_.find(
- GlobalRequestID(process_id, request_id));
+ GlobalRequestID(child_id, request_id));
if (i == pending_requests_.end())
return;
@@ -620,11 +624,11 @@ void ResourceDispatcherHost::OnUploadProgressACK(int request_id) {
}
void ResourceDispatcherHost::OnCancelRequest(int request_id) {
- CancelRequest(receiver_->GetProcessId(), request_id, true, true);
+ CancelRequest(receiver_->id(), request_id, true, true);
}
void ResourceDispatcherHost::OnFollowRedirect(int request_id) {
- FollowDeferredRedirect(receiver_->GetProcessId(), request_id);
+ FollowDeferredRedirect(receiver_->id(), request_id);
}
void ResourceDispatcherHost::OnClosePageACK(
@@ -655,7 +659,7 @@ void ResourceDispatcherHost::OnClosePageACK(
// We are explicitly forcing the download of 'url'.
void ResourceDispatcherHost::BeginDownload(const GURL& url,
const GURL& referrer,
- int process_id,
+ int child_id,
int route_id,
URLRequestContext* request_context) {
if (is_shutdown_)
@@ -663,7 +667,7 @@ void ResourceDispatcherHost::BeginDownload(const GURL& url,
// Check if the renderer is permitted to request the requested URL.
if (!ChildProcessSecurityPolicy::GetInstance()->
- CanRequestURL(process_id, url)) {
+ CanRequestURL(child_id, url)) {
LOG(INFO) << "Denied unauthorized download request for " <<
url.possibly_invalid_spec();
return;
@@ -678,7 +682,7 @@ void ResourceDispatcherHost::BeginDownload(const GURL& url,
scoped_refptr<ResourceHandler> handler =
new DownloadResourceHandler(this,
- process_id,
+ child_id,
route_id,
request_id_,
url,
@@ -689,7 +693,7 @@ void ResourceDispatcherHost::BeginDownload(const GURL& url,
if (safe_browsing_->enabled() && safe_browsing_->CanCheckUrl(url)) {
handler = new SafeBrowsingResourceHandler(handler,
- process_id,
+ child_id,
route_id,
url,
ResourceType::MAIN_FRAME,
@@ -712,7 +716,7 @@ void ResourceDispatcherHost::BeginDownload(const GURL& url,
ExtraRequestInfo* extra_info =
new ExtraRequestInfo(handler,
ChildProcessInfo::RENDER_PROCESS,
- process_id,
+ child_id,
route_id,
request_id_,
"null", // frame_origin
@@ -722,6 +726,8 @@ void ResourceDispatcherHost::BeginDownload(const GURL& url,
extra_info->allow_download = true;
extra_info->is_download = true;
SetExtraInfoForRequest(request, extra_info); // request takes ownership
+ chrome_browser_net::SetOriginProcessUniqueIDForRequest(child_id,
+ request);
BeginRequestInternal(request);
}
@@ -729,7 +735,7 @@ void ResourceDispatcherHost::BeginDownload(const GURL& url,
// This function is only used for saving feature.
void ResourceDispatcherHost::BeginSaveFile(const GURL& url,
const GURL& referrer,
- int process_id,
+ int child_id,
int route_id,
URLRequestContext* request_context) {
if (is_shutdown_)
@@ -740,7 +746,7 @@ void ResourceDispatcherHost::BeginSaveFile(const GURL& url,
PluginService::GetInstance()->LoadChromePlugins(this);
scoped_refptr<ResourceHandler> handler =
- new SaveFileResourceHandler(process_id,
+ new SaveFileResourceHandler(child_id,
route_id,
url,
save_file_manager_.get());
@@ -766,7 +772,7 @@ void ResourceDispatcherHost::BeginSaveFile(const GURL& url,
ExtraRequestInfo* extra_info =
new ExtraRequestInfo(handler,
ChildProcessInfo::RENDER_PROCESS,
- process_id,
+ child_id,
route_id,
request_id_,
"null", // frame_origin
@@ -777,20 +783,21 @@ void ResourceDispatcherHost::BeginSaveFile(const GURL& url,
extra_info->allow_download = false;
extra_info->is_download = false;
SetExtraInfoForRequest(request, extra_info); // request takes ownership
+ chrome_browser_net::SetOriginProcessUniqueIDForRequest(child_id, request);
BeginRequestInternal(request);
}
-void ResourceDispatcherHost::CancelRequest(int process_id,
+void ResourceDispatcherHost::CancelRequest(int child_id,
int request_id,
bool from_renderer) {
- CancelRequest(process_id, request_id, from_renderer, true);
+ CancelRequest(child_id, request_id, from_renderer, true);
}
-void ResourceDispatcherHost::FollowDeferredRedirect(int process_id,
+void ResourceDispatcherHost::FollowDeferredRedirect(int child_id,
int request_id) {
PendingRequestList::iterator i = pending_requests_.find(
- GlobalRequestID(process_id, request_id));
+ GlobalRequestID(child_id, request_id));
if (i == pending_requests_.end()) {
DLOG(WARNING) << "FollowDeferredRedirect for invalid request";
return;
@@ -799,10 +806,10 @@ void ResourceDispatcherHost::FollowDeferredRedirect(int process_id,
i->second->FollowDeferredRedirect();
}
-bool ResourceDispatcherHost::WillSendData(int process_id,
+bool ResourceDispatcherHost::WillSendData(int child_id,
int request_id) {
PendingRequestList::iterator i = pending_requests_.find(
- GlobalRequestID(process_id, request_id));
+ GlobalRequestID(child_id, request_id));
if (i == pending_requests_.end()) {
NOTREACHED() << "WillSendData for invalid request";
return false;
@@ -815,17 +822,17 @@ bool ResourceDispatcherHost::WillSendData(int process_id,
// We reached the max number of data messages that can be sent to
// the renderer for a given request. Pause the request and wait for
// the renderer to start processing them before resuming it.
- PauseRequest(process_id, request_id, true);
+ PauseRequest(child_id, request_id, true);
return false;
}
return true;
}
-void ResourceDispatcherHost::PauseRequest(int process_id,
+void ResourceDispatcherHost::PauseRequest(int child_id,
int request_id,
bool pause) {
- GlobalRequestID global_id(process_id, request_id);
+ GlobalRequestID global_id(child_id, request_id);
PendingRequestList::iterator i = pending_requests_.find(global_id);
if (i == pending_requests_.end()) {
DLOG(WARNING) << "Pausing a request that wasn't found";
@@ -853,9 +860,9 @@ void ResourceDispatcherHost::PauseRequest(int process_id,
}
int ResourceDispatcherHost::GetOutstandingRequestsMemoryCost(
- int process_id) const {
+ int child_id) const {
OutstandingRequestsMemoryCostMap::const_iterator entry =
- outstanding_requests_memory_cost_map_.find(process_id);
+ outstanding_requests_memory_cost_map_.find(child_id);
return (entry == outstanding_requests_memory_cost_map_.end()) ?
0 : entry->second;
}
@@ -863,13 +870,12 @@ int ResourceDispatcherHost::GetOutstandingRequestsMemoryCost(
// The object died, so cancel and detach all requests associated with it except
// for downloads, which belong to the browser process even if initiated via a
// renderer.
-void ResourceDispatcherHost::CancelRequestsForProcess(int process_id) {
- CancelRequestsForRoute(process_id, -1 /* cancel all */);
+void ResourceDispatcherHost::CancelRequestsForProcess(int child_id) {
+ CancelRequestsForRoute(child_id, -1 /* cancel all */);
}
-void ResourceDispatcherHost::CancelRequestsForRoute(
- int process_id,
- int route_id) {
+void ResourceDispatcherHost::CancelRequestsForRoute(int child_id,
+ int route_id) {
// Since pending_requests_ is a map, we first build up a list of all of the
// matching requests to be cancelled, and then we cancel them. Since there
// may be more than one request to cancel, we cannot simply hold onto the map
@@ -879,12 +885,12 @@ void ResourceDispatcherHost::CancelRequestsForRoute(
std::vector<GlobalRequestID> matching_requests;
for (PendingRequestList::const_iterator i = pending_requests_.begin();
i != pending_requests_.end(); ++i) {
- if (i->first.process_id == process_id) {
+ if (i->first.child_id == child_id) {
ExtraRequestInfo* info = ExtraInfoForRequest(i->second);
if (!info->is_download && (route_id == -1 ||
route_id == info->route_id)) {
matching_requests.push_back(
- GlobalRequestID(process_id, i->first.request_id));
+ GlobalRequestID(child_id, i->first.request_id));
}
}
}
@@ -907,33 +913,33 @@ void ResourceDispatcherHost::CancelRequestsForRoute(
// Now deal with blocked requests if any.
if (route_id != -1) {
- if (blocked_requests_map_.find(std::pair<int, int>(process_id, route_id)) !=
+ if (blocked_requests_map_.find(std::pair<int, int>(child_id, route_id)) !=
blocked_requests_map_.end()) {
- CancelBlockedRequestsForRoute(process_id, route_id);
+ CancelBlockedRequestsForRoute(child_id, route_id);
}
} else {
- // We have to do all render views for the process |process_id|.
+ // We have to do all render views for the process |child_id|.
// Note that we have to do this in 2 passes as we cannot call
// CancelBlockedRequestsForRoute while iterating over
// blocked_requests_map_, as it modifies it.
std::set<int> route_ids;
for (BlockedRequestMap::const_iterator iter = blocked_requests_map_.begin();
iter != blocked_requests_map_.end(); ++iter) {
- if (iter->first.first == process_id)
+ if (iter->first.first == child_id)
route_ids.insert(iter->first.second);
}
for (std::set<int>::const_iterator iter = route_ids.begin();
iter != route_ids.end(); ++iter) {
- CancelBlockedRequestsForRoute(process_id, *iter);
+ CancelBlockedRequestsForRoute(child_id, *iter);
}
}
}
// Cancels the request and removes it from the list.
-void ResourceDispatcherHost::RemovePendingRequest(int process_id,
+void ResourceDispatcherHost::RemovePendingRequest(int child_id,
int request_id) {
PendingRequestList::iterator i = pending_requests_.find(
- GlobalRequestID(process_id, request_id));
+ GlobalRequestID(child_id, request_id));
if (i == pending_requests_.end()) {
NOTREACHED() << "Trying to remove a request that's not here";
return;
@@ -948,7 +954,7 @@ void ResourceDispatcherHost::RemovePendingRequest(
// Remove the memory credit that we added when pushing the request onto
// the pending list.
IncrementOutstandingRequestsMemoryCost(-1 * info->memory_cost,
- info->process_id);
+ info->child_id);
// Notify the login handler that this request object is going away.
if (info && info->login_handler)
@@ -974,22 +980,22 @@ void ResourceDispatcherHost::OnReceivedRedirect(URLRequest* request,
if (info->process_type != ChildProcessInfo::PLUGIN_PROCESS &&
!ChildProcessSecurityPolicy::GetInstance()->
- CanRequestURL(info->process_id, new_url)) {
+ CanRequestURL(info->child_id, new_url)) {
LOG(INFO) << "Denied unauthorized request for " <<
new_url.possibly_invalid_spec();
// Tell the renderer that this request was disallowed.
- CancelRequest(info->process_id, info->request_id, false);
+ CancelRequest(info->child_id, info->request_id, false);
return;
}
- NotifyReceivedRedirect(request, info->process_id, new_url);
+ NotifyReceivedRedirect(request, info->child_id, new_url);
- if (HandleExternalProtocol(info->request_id, info->process_id,
+ if (HandleExternalProtocol(info->request_id, info->child_id,
info->route_id, new_url,
info->resource_type, info->resource_handler)) {
// The request is complete so we can remove it.
- RemovePendingRequest(info->process_id, info->request_id);
+ RemovePendingRequest(info->child_id, info->request_id);
return;
}
@@ -997,7 +1003,7 @@ void ResourceDispatcherHost::OnReceivedRedirect(URLRequest* request,
PopulateResourceResponse(request, info->filter_policy, response);
if (!info->resource_handler->OnRequestRedirected(info->request_id, new_url,
response, defer_redirect))
- CancelRequest(info->process_id, info->request_id, false);
+ CancelRequest(info->child_id, info->request_id, false);
}
void ResourceDispatcherHost::OnAuthRequired(
@@ -1058,7 +1064,7 @@ void ResourceDispatcherHost::OnResponseStarted(URLRequest* request) {
MaybeUpdateUploadProgress(info, request);
if (!CompleteResponseStarted(request)) {
- CancelRequest(info->process_id, info->request_id, false);
+ CancelRequest(info->child_id, info->request_id, false);
} else {
// Check if the handler paused the request in their OnResponseStarted.
if (PauseRequestIfNeeded(info)) {
@@ -1091,9 +1097,8 @@ bool ResourceDispatcherHost::CompleteResponseStarted(URLRequest* request) {
if (request->ssl_info().cert) {
int cert_id =
- CertStore::GetSharedInstance()->StoreCert(
- request->ssl_info().cert,
- info->process_id);
+ CertStore::GetSharedInstance()->StoreCert(request->ssl_info().cert,
+ info->child_id);
response->response_head.security_info =
SSLManager::SerializeSecurityInfo(cert_id,
request->ssl_info().cert_status,
@@ -1105,18 +1110,18 @@ bool ResourceDispatcherHost::CompleteResponseStarted(URLRequest* request) {
request->ssl_info().security_bits == 0));
}
- NotifyResponseStarted(request, info->process_id);
+ NotifyResponseStarted(request, info->child_id);
info->called_on_response_started = true;
return info->resource_handler->OnResponseStarted(info->request_id,
response.get());
}
-void ResourceDispatcherHost::CancelRequest(int process_id,
+void ResourceDispatcherHost::CancelRequest(int child_id,
int request_id,
bool from_renderer,
bool allow_delete) {
PendingRequestList::iterator i = pending_requests_.find(
- GlobalRequestID(process_id, request_id));
+ GlobalRequestID(child_id, request_id));
if (i == pending_requests_.end()) {
// We probably want to remove this warning eventually, but I wanted to be
// able to notice when this happens during initial development since it
@@ -1143,7 +1148,7 @@ void ResourceDispatcherHost::CancelRequest(int process_id,
// TODO(sky): removing the request in this manner means we're not
// notifying anyone. We need make sure the event handlers and others are
// notified so that everything is cleaned up properly.
- RemovePendingRequest(info->process_id, info->request_id);
+ RemovePendingRequest(info->child_id, info->request_id);
} else {
i->second->Cancel();
}
@@ -1155,10 +1160,11 @@ void ResourceDispatcherHost::CancelRequest(int process_id,
}
int ResourceDispatcherHost::IncrementOutstandingRequestsMemoryCost(
- int cost, int process_id) {
+ int cost,
+ int child_id) {
// Retrieve the previous value (defaulting to 0 if not found).
OutstandingRequestsMemoryCostMap::iterator prev_entry =
- outstanding_requests_memory_cost_map_.find(process_id);
+ outstanding_requests_memory_cost_map_.find(child_id);
int new_cost = 0;
if (prev_entry != outstanding_requests_memory_cost_map_.end())
new_cost = prev_entry->second;
@@ -1169,7 +1175,7 @@ int ResourceDispatcherHost::IncrementOutstandingRequestsMemoryCost(
if (new_cost == 0)
outstanding_requests_memory_cost_map_.erase(prev_entry);
else
- outstanding_requests_memory_cost_map_[process_id] = new_cost;
+ outstanding_requests_memory_cost_map_[child_id] = new_cost;
return new_cost;
}
@@ -1217,9 +1223,8 @@ void ResourceDispatcherHost::BeginRequestInternal(URLRequest* request) {
// Add the memory estimate that starting this request will consume.
info->memory_cost = CalculateApproximateMemoryCost(request);
- int memory_cost = IncrementOutstandingRequestsMemoryCost(
- info->memory_cost,
- info->process_id);
+ int memory_cost = IncrementOutstandingRequestsMemoryCost(info->memory_cost,
+ info->child_id);
// If enqueing/starting this request will exceed our per-process memory
// bound, abort it right away.
@@ -1230,13 +1235,13 @@ void ResourceDispatcherHost::BeginRequestInternal(URLRequest* request) {
// TODO(eroman): this is kinda funky -- we insert the unstarted request into
// |pending_requests_| simply to please OnResponseCompleted().
- GlobalRequestID global_id(info->process_id, info->request_id);
+ GlobalRequestID global_id(info->child_id, info->request_id);
pending_requests_[global_id] = request;
OnResponseCompleted(request);
return;
}
- std::pair<int, int> pair_id(info->process_id, info->route_id);
+ std::pair<int, int> pair_id(info->child_id, info->route_id);
BlockedRequestMap::const_iterator iter = blocked_requests_map_.find(pair_id);
if (iter != blocked_requests_map_.end()) {
// The request should be blocked.
@@ -1244,7 +1249,7 @@ void ResourceDispatcherHost::BeginRequestInternal(URLRequest* request) {
return;
}
- GlobalRequestID global_id(info->process_id, info->request_id);
+ GlobalRequestID global_id(info->child_id, info->request_id);
pending_requests_[global_id] = request;
if (!SSLManager::ShouldStartRequest(this, request, ui_loop_)) {
// The SSLManager has told us that we shouldn't start the request yet. The
@@ -1354,7 +1359,7 @@ void ResourceDispatcherHost::OnReadCompleted(URLRequest* request,
// thread and starving other IO operations from running.
info->paused_read_bytes = bytes_read;
info->is_paused = true;
- GlobalRequestID id(info->process_id, info->request_id);
+ GlobalRequestID id(info->child_id, info->request_id);
MessageLoop::current()->PostTask(
FROM_HERE,
method_runner_.NewRunnableMethod(
@@ -1390,7 +1395,7 @@ bool ResourceDispatcherHost::CompleteRead(URLRequest* request,
// Pass in false as the last arg to indicate we don't want |request|
// deleted. We do this as callers of us assume |request| is valid after we
// return.
- CancelRequest(info->process_id, info->request_id, false, false);
+ CancelRequest(info->child_id, info->request_id, false, false);
return false;
}
@@ -1404,8 +1409,8 @@ void ResourceDispatcherHost::OnResponseCompleted(URLRequest* request) {
std::string security_info;
const net::SSLInfo& ssl_info = request->ssl_info();
if (ssl_info.cert != NULL) {
- int cert_id = CertStore::GetSharedInstance()->
- StoreCert(ssl_info.cert, info->process_id);
+ int cert_id = CertStore::GetSharedInstance()->StoreCert(ssl_info.cert,
+ info->child_id);
security_info = SSLManager::SerializeSecurityInfo(cert_id,
ssl_info.cert_status,
ssl_info.security_bits);
@@ -1414,10 +1419,10 @@ void ResourceDispatcherHost::OnResponseCompleted(URLRequest* request) {
if (info->resource_handler->OnResponseCompleted(info->request_id,
request->status(),
security_info)) {
- NotifyResponseCompleted(request, info->process_id);
+ NotifyResponseCompleted(request, info->child_id);
// The request is complete so we can remove it.
- RemovePendingRequest(info->process_id, info->request_id);
+ RemovePendingRequest(info->child_id, info->request_id);
}
// If the handler's OnResponseCompleted returns false, we are deferring the
// call until later. We will notify the world and clean up when we resume.
@@ -1451,7 +1456,7 @@ bool ResourceDispatcherHost::RenderViewForRequest(const URLRequest* request,
return false;
}
- *render_process_host_id = info->process_id;
+ *render_process_host_id = info->child_id;
*render_view_host_id = info->route_id;
return true;
}
@@ -1477,10 +1482,10 @@ URLRequest* ResourceDispatcherHost::GetURLRequest(
return i->second;
}
-static int GetCertID(URLRequest* request, int process_id) {
+static int GetCertID(URLRequest* request, int child_id) {
if (request->ssl_info().cert) {
return CertStore::GetSharedInstance()->StoreCert(request->ssl_info().cert,
- process_id);
+ child_id);
}
// If there is no SSL info attached to this request, we must either be a non
// secure request, or the request has been canceled or failed (before the SSL
@@ -1495,33 +1500,31 @@ static int GetCertID(URLRequest* request, int process_id) {
}
void ResourceDispatcherHost::NotifyResponseStarted(URLRequest* request,
- int process_id) {
+ int child_id) {
// Notify the observers on the IO thread.
FOR_EACH_OBSERVER(Observer, observer_list_, OnRequestStarted(this, request));
// Notify the observers on the UI thread.
ui_loop_->PostTask(FROM_HERE, new RVHDelegateNotificationTask(request,
&RenderViewHostDelegate::Resource::DidStartReceivingResourceResponse,
- new ResourceRequestDetails(request,
- GetCertID(request, process_id))));
+ new ResourceRequestDetails(request, GetCertID(request, child_id))));
}
-void ResourceDispatcherHost::NotifyResponseCompleted(
- URLRequest* request,
- int process_id) {
+void ResourceDispatcherHost::NotifyResponseCompleted(URLRequest* request,
+ int child_id) {
// Notify the observers on the IO thread.
FOR_EACH_OBSERVER(Observer, observer_list_,
OnResponseCompleted(this, request));
}
void ResourceDispatcherHost::NotifyReceivedRedirect(URLRequest* request,
- int process_id,
+ int child_id,
const GURL& new_url) {
// Notify the observers on the IO thread.
FOR_EACH_OBSERVER(Observer, observer_list_,
OnReceivedRedirect(this, request, new_url));
- int cert_id = GetCertID(request, process_id);
+ int cert_id = GetCertID(request, child_id);
// Notify the observers on the UI thread.
ui_loop_->PostTask(FROM_HERE,
@@ -1597,7 +1600,7 @@ void ResourceDispatcherHost::UpdateLoadStates() {
if (info->last_load_state != load_state) {
info->last_load_state = load_state;
- std::pair<int, int> key(info->process_id, info->route_id);
+ std::pair<int, int> key(info->child_id, info->route_id);
net::LoadState to_insert;
LoadInfoMap::iterator existing = info_map.find(key);
if (existing == info_map.end()) {
@@ -1651,33 +1654,30 @@ void ResourceDispatcherHost::MaybeUpdateUploadProgress(ExtraRequestInfo *info,
}
}
-void ResourceDispatcherHost::BlockRequestsForRoute(
- int process_id,
- int route_id) {
- std::pair<int, int> key(process_id, route_id);
+void ResourceDispatcherHost::BlockRequestsForRoute(int child_id,
+ int route_id) {
+ std::pair<int, int> key(child_id, route_id);
DCHECK(blocked_requests_map_.find(key) == blocked_requests_map_.end()) <<
"BlockRequestsForRoute called multiple time for the same RVH";
blocked_requests_map_[key] = new BlockedRequestsList();
}
-void ResourceDispatcherHost::ResumeBlockedRequestsForRoute(
- int process_id,
- int route_id) {
- ProcessBlockedRequestsForRoute(process_id, route_id, false);
+void ResourceDispatcherHost::ResumeBlockedRequestsForRoute(int child_id,
+ int route_id) {
+ ProcessBlockedRequestsForRoute(child_id, route_id, false);
}
-void ResourceDispatcherHost::CancelBlockedRequestsForRoute(
- int process_id,
- int route_id) {
- ProcessBlockedRequestsForRoute(process_id, route_id, true);
+void ResourceDispatcherHost::CancelBlockedRequestsForRoute(int child_id,
+ int route_id) {
+ ProcessBlockedRequestsForRoute(child_id, route_id, true);
}
void ResourceDispatcherHost::ProcessBlockedRequestsForRoute(
- int process_id,
+ int child_id,
int route_id,
bool cancel_requests) {
- BlockedRequestMap::iterator iter =
- blocked_requests_map_.find(std::pair<int, int>(process_id, route_id));
+ BlockedRequestMap::iterator iter = blocked_requests_map_.find(
+ std::pair<int, int>(child_id, route_id));
if (iter == blocked_requests_map_.end()) {
// It's possible to reach here if the renderer crashed while an interstitial
// page was showing.
@@ -1696,7 +1696,7 @@ void ResourceDispatcherHost::ProcessBlockedRequestsForRoute(
URLRequest* request = *req_iter;
ExtraRequestInfo* info = ExtraInfoForRequest(request);
IncrementOutstandingRequestsMemoryCost(-1 * info->memory_cost,
- info->process_id);
+ info->child_id);
if (cancel_requests)
delete request;
else
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.h b/chrome/browser/renderer_host/resource_dispatcher_host.h
index 5fff4b9..1bd2441 100644
--- a/chrome/browser/renderer_host/resource_dispatcher_host.h
+++ b/chrome/browser/renderer_host/resource_dispatcher_host.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// 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.
@@ -67,8 +67,8 @@ class ResourceDispatcherHost : public URLRequest::Delegate {
const ViewHostMsg_Resource_Request& request_data) = 0;
protected:
- explicit Receiver(ChildProcessInfo::ProcessType type)
- : ChildProcessInfo(type) {}
+ explicit Receiver(ChildProcessInfo::ProcessType type, int child_id)
+ : ChildProcessInfo(type, child_id) {}
virtual ~Receiver() {}
};
@@ -78,7 +78,7 @@ class ResourceDispatcherHost : public URLRequest::Delegate {
public:
ExtraRequestInfo(ResourceHandler* handler,
ChildProcessInfo::ProcessType process_type,
- int process_id,
+ int child_id,
int route_id,
int request_id,
std::string frame_origin,
@@ -90,7 +90,7 @@ class ResourceDispatcherHost : public URLRequest::Delegate {
login_handler(NULL),
ssl_client_auth_handler(NULL),
process_type(process_type),
- process_id(process_id),
+ child_id(child_id),
route_id(route_id),
request_id(request_id),
pending_data_count(0),
@@ -126,7 +126,10 @@ class ResourceDispatcherHost : public URLRequest::Delegate {
ChildProcessInfo::ProcessType process_type;
- int process_id;
+ // The child process unique ID of the requestor. This duplicates the value
+ // stored on the request by SetChildProcessUniqueIDForRequest in
+ // url_request_tracking.
+ int child_id;
int route_id;
@@ -203,19 +206,20 @@ class ResourceDispatcherHost : public URLRequest::Delegate {
// Uniquely identifies a URLRequest.
struct GlobalRequestID {
- GlobalRequestID() : process_id(-1), request_id(-1) {
+ GlobalRequestID() : child_id(-1), request_id(-1) {
}
- GlobalRequestID(int process_id, int request_id)
- : process_id(process_id), request_id(request_id) {
+ GlobalRequestID(int child_id, int request_id)
+ : child_id(child_id),
+ request_id(request_id) {
}
- int process_id;
+ int child_id;
int request_id;
bool operator<(const GlobalRequestID& other) const {
- if (process_id == other.process_id)
+ if (child_id == other.child_id)
return request_id < other.request_id;
- return process_id < other.process_id;
+ return child_id < other.child_id;
}
};
@@ -238,7 +242,7 @@ class ResourceDispatcherHost : public URLRequest::Delegate {
// request from the renderer or another child process).
void BeginDownload(const GURL& url,
const GURL& referrer,
- int process_id,
+ int process_unique_id,
int route_id,
URLRequestContext* request_context);
@@ -246,27 +250,27 @@ class ResourceDispatcherHost : public URLRequest::Delegate {
// request from the renderer or another child process).
void BeginSaveFile(const GURL& url,
const GURL& referrer,
- int process_id,
+ int process_unique_id,
int route_id,
URLRequestContext* request_context);
// Cancels the given request if it still exists. We ignore cancels from the
// renderer in the event of a download.
- void CancelRequest(int process_id,
+ void CancelRequest(int process_unique_id,
int request_id,
bool from_renderer);
// Follows a deferred redirect for the given request.
- void FollowDeferredRedirect(int process_id,
+ void FollowDeferredRedirect(int process_unique_id,
int request_id);
// Returns true if it's ok to send the data. If there are already too many
// data messages pending, it pauses the request and returns false. In this
// case the caller should not send the data.
- bool WillSendData(int process_id, int request_id);
+ bool WillSendData(int process_unique_id, int request_id);
// Pauses or resumes network activity for a particular request.
- void PauseRequest(int process_id, int request_id, bool pause);
+ void PauseRequest(int process_unique_id, int request_id, bool pause);
// Returns the number of pending requests. This is designed for the unittests
int pending_requests() const {
@@ -274,8 +278,8 @@ class ResourceDispatcherHost : public URLRequest::Delegate {
}
// Intended for unit-tests only. Returns the memory cost of all the
- // outstanding requests (pending and blocked) for |process_id|.
- int GetOutstandingRequestsMemoryCost(int process_id) const;
+ // outstanding requests (pending and blocked) for |process_unique_id|.
+ int GetOutstandingRequestsMemoryCost(int process_unique_id) const;
// Intended for unit-tests only. Overrides the outstanding requests bound.
void set_max_outstanding_requests_cost_per_process(int limit) {
@@ -312,11 +316,11 @@ class ResourceDispatcherHost : public URLRequest::Delegate {
void OnClosePageACK(const ViewMsg_ClosePage_Params& params);
// Force cancels any pending requests for the given process.
- void CancelRequestsForProcess(int process_id);
+ void CancelRequestsForProcess(int process_unique_id);
// Force cancels any pending requests for the given route id. This method
// acts like CancelRequestsForProcess when route_id is -1.
- void CancelRequestsForRoute(int process_id, int route_id);
+ void CancelRequestsForRoute(int process_unique_id, int route_id);
// URLRequest::Delegate
virtual void OnReceivedRedirect(URLRequest* request,
@@ -359,26 +363,26 @@ class ResourceDispatcherHost : public URLRequest::Delegate {
URLRequest* GetURLRequest(GlobalRequestID request_id) const;
// Notifies our observers that a request has been cancelled.
- void NotifyResponseCompleted(URLRequest* request, int process_id);
+ void NotifyResponseCompleted(URLRequest* request, int process_unique_id);
- void RemovePendingRequest(int process_id, int request_id);
+ void RemovePendingRequest(int process_unique_id, int request_id);
// Causes all new requests for the route identified by
- // |process_id| and |route_id| to be blocked (not being
+ // |process_unique_id| and |route_id| to be blocked (not being
// started) until ResumeBlockedRequestsForRoute or
// CancelBlockedRequestsForRoute is called.
- void BlockRequestsForRoute(int process_id, int route_id);
+ void BlockRequestsForRoute(int process_unique_id, int route_id);
// Resumes any blocked request for the specified route id.
- void ResumeBlockedRequestsForRoute(int process_id, int route_id);
+ void ResumeBlockedRequestsForRoute(int process_unique_id, int route_id);
// Cancels any blocked request for the specified route id.
- void CancelBlockedRequestsForRoute(int process_id, int route_id);
+ void CancelBlockedRequestsForRoute(int process_unique_id, int route_id);
// Decrements the pending_data_count for the request and resumes
// the request if it was paused due to too many pending data
// messages sent.
- void DataReceivedACK(int process_id, int request_id);
+ void DataReceivedACK(int process_unique_id, int request_id);
// Needed for the sync IPC message dispatcher macros.
bool Send(IPC::Message* message) {
@@ -438,7 +442,7 @@ class ResourceDispatcherHost : public URLRequest::Delegate {
// Cancels the given request if it still exists. We ignore cancels from the
// renderer in the event of a download. If |allow_delete| is true and no IO
// is pending, the request is removed and deleted.
- void CancelRequest(int process_id,
+ void CancelRequest(int process_unique_id,
int request_id,
bool from_renderer,
bool allow_delete);
@@ -446,14 +450,14 @@ class ResourceDispatcherHost : public URLRequest::Delegate {
// Helper function for regular and download requests.
void BeginRequestInternal(URLRequest* request);
- // Updates the "cost" of outstanding requests for |process_id|.
+ // Updates the "cost" of outstanding requests for |process_unique_id|.
// The "cost" approximates how many bytes are consumed by all the in-memory
// data structures supporting this request (URLRequest object,
// HttpNetworkTransaction, etc...).
// The value of |cost| is added to the running total, and the resulting
// sum is returned.
int IncrementOutstandingRequestsMemoryCost(int cost,
- int process_id);
+ int process_unique_id);
// Estimate how much heap space |request| will consume to run.
static int CalculateApproximateMemoryCost(URLRequest* request);
@@ -473,17 +477,17 @@ class ResourceDispatcherHost : public URLRequest::Delegate {
void RemovePendingRequest(const PendingRequestList::iterator& iter);
// Notify our observers that we started receiving a response for a request.
- void NotifyResponseStarted(URLRequest* request, int process_id);
+ void NotifyResponseStarted(URLRequest* request, int process_unique_id);
// Notify our observers that a request has been redirected.
void NotifyReceivedRedirect(URLRequest* request,
- int process_id,
+ int process_unique_id,
const GURL& new_url);
// Tries to handle the url with an external protocol. If the request is
// handled, the function returns true. False otherwise.
bool HandleExternalProtocol(int request_id,
- int process_id,
+ int process_unique_id,
int route_id,
const GURL& url,
ResourceType::Type resource_type,
@@ -494,7 +498,7 @@ class ResourceDispatcherHost : public URLRequest::Delegate {
void MaybeUpdateUploadProgress(ExtraRequestInfo *info, URLRequest *request);
// Resumes or cancels (if |cancel_requests| is true) any blocked requests.
- void ProcessBlockedRequestsForRoute(int process_id,
+ void ProcessBlockedRequestsForRoute(int process_unique_id,
int route_id,
bool cancel_requests);
@@ -568,7 +572,7 @@ class ResourceDispatcherHost : public URLRequest::Delegate {
typedef std::map<ProcessRouteIDs, BlockedRequestsList*> BlockedRequestMap;
BlockedRequestMap blocked_requests_map_;
- // Maps the process_ids to the approximate number of bytes
+ // Maps the process_unique_ids to the approximate number of bytes
// being used to service its resource requests. No entry implies 0 cost.
typedef std::map<int, int> OutstandingRequestsMemoryCostMap;
OutstandingRequestsMemoryCostMap outstanding_requests_memory_cost_map_;
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc b/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc
index 3b94b48..1dc5989 100644
--- a/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc
+++ b/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc
@@ -42,13 +42,18 @@ static ViewHostMsg_Resource_Request CreateResourceRequest(const char* method,
request.frame_origin = "null";
request.main_frame_origin = "null";
request.load_flags = 0;
- request.origin_pid = 0;
+ request.origin_child_id = 0;
request.resource_type = ResourceType::SUB_RESOURCE;
request.request_context = 0;
request.appcache_host_id = appcache::kNoHostId;
return request;
}
+// Spin up the message loop to kick off the request.
+static void KickOffRequest() {
+ MessageLoop::current()->RunAllPending();
+}
+
// We may want to move this to a shared space if it is useful for something else
class ResourceIPCAccumulator {
public:
@@ -88,11 +93,40 @@ void ResourceIPCAccumulator::GetClassifiedMessages(ClassifiedMessages* msgs) {
}
}
+// This class forwards the incoming messages to the ResourceDispatcherHostTest.
+// This is used to emulate different sub-procseses, since this receiver will
+// have a different ID than the original. For the test, we want all the incoming
+// messages to go to the same place, which is why this forwards.
+class ForwardingReceiver : public ResourceDispatcherHost::Receiver {
+ public:
+ ForwardingReceiver(ResourceDispatcherHost::Receiver* dest)
+ : ResourceDispatcherHost::Receiver(dest->type(), -1),
+ dest_(dest) {
+ set_handle(dest->handle());
+ }
+
+ // ResourceDispatcherHost::Receiver implementation
+ virtual bool Send(IPC::Message* msg) {
+ return dest_->Send(msg);
+ }
+ URLRequestContext* GetRequestContext(
+ uint32 request_id,
+ const ViewHostMsg_Resource_Request& request_data) {
+ return dest_->GetRequestContext(request_id, request_data);
+ }
+
+ private:
+ ResourceDispatcherHost::Receiver* dest_;
+
+ DISALLOW_COPY_AND_ASSIGN(ForwardingReceiver);
+};
+
class ResourceDispatcherHostTest : public testing::Test,
public ResourceDispatcherHost::Receiver {
public:
ResourceDispatcherHostTest()
- : Receiver(ChildProcessInfo::RENDER_PROCESS), host_(NULL), pid_(-1) {
+ : Receiver(ChildProcessInfo::RENDER_PROCESS, -1),
+ host_(NULL) {
set_handle(base::GetCurrentProcessHandle());
}
// ResourceDispatcherHost::Receiver implementation
@@ -103,13 +137,11 @@ class ResourceDispatcherHostTest : public testing::Test,
}
URLRequestContext* GetRequestContext(
- uint32 request_id,
- const ViewHostMsg_Resource_Request& request_data) {
+ uint32 request_id,
+ const ViewHostMsg_Resource_Request& request_data) {
return NULL;
}
- virtual int GetProcessId() const { return pid_; }
-
protected:
// testing::Test
virtual void SetUp() {
@@ -129,15 +161,18 @@ class ResourceDispatcherHostTest : public testing::Test,
message_loop_.RunAllPending();
}
- void MakeTestRequest(int render_process_id,
- int render_view_id,
+ // Creates a request using the current test object as the receiver.
+ void MakeTestRequest(int render_view_id,
int request_id,
const GURL& url);
+
+ // Generates a request using the given receiver. This will probably be a
+ // ForwardingReceiver.
void MakeTestRequest(ResourceDispatcherHost::Receiver* receiver,
- int render_process_id,
int render_view_id,
int request_id,
const GURL& url);
+
void MakeCancelRequest(int request_id);
void EnsureTestSchemeIsAllowed() {
@@ -152,38 +187,28 @@ class ResourceDispatcherHostTest : public testing::Test,
MessageLoopForIO message_loop_;
ResourceDispatcherHost host_;
ResourceIPCAccumulator accum_;
- int pid_;
};
-// Spin up the message loop to kick off the request.
-static void KickOffRequest() {
- MessageLoop::current()->RunAllPending();
-}
-
-void ResourceDispatcherHostTest::MakeTestRequest(int render_process_id,
- int render_view_id,
+void ResourceDispatcherHostTest::MakeTestRequest(int render_view_id,
int request_id,
const GURL& url) {
- MakeTestRequest(this, render_process_id, render_view_id, request_id, url);
+ MakeTestRequest(this, render_view_id, request_id, url);
}
void ResourceDispatcherHostTest::MakeTestRequest(
- ResourceDispatcherHost::Receiver* receiver,
- int render_process_id,
+ ResourceDispatcherHost::Receiver* receiver,
int render_view_id,
int request_id,
const GURL& url) {
- pid_ = render_process_id;
ViewHostMsg_Resource_Request request = CreateResourceRequest("GET", url);
ViewHostMsg_RequestResource msg(render_view_id, request_id, request);
bool msg_was_ok;
host_.OnMessageReceived(msg, receiver, &msg_was_ok);
KickOffRequest();
- pid_ = -1;
}
void ResourceDispatcherHostTest::MakeCancelRequest(int request_id) {
- host_.CancelRequest(0, request_id, false);
+ host_.CancelRequest(id(), request_id, false);
}
void CheckSuccessfulRequest(const std::vector<IPC::Message>& messages,
@@ -230,9 +255,9 @@ void CheckSuccessfulRequest(const std::vector<IPC::Message>& messages,
TEST_F(ResourceDispatcherHostTest, TestMany) {
EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0));
- MakeTestRequest(0, 0, 1, URLRequestTestJob::test_url_1());
- MakeTestRequest(0, 0, 2, URLRequestTestJob::test_url_2());
- MakeTestRequest(0, 0, 3, URLRequestTestJob::test_url_3());
+ MakeTestRequest(0, 1, URLRequestTestJob::test_url_1());
+ MakeTestRequest(0, 2, URLRequestTestJob::test_url_2());
+ MakeTestRequest(0, 3, URLRequestTestJob::test_url_3());
// flush all the pending requests
while (URLRequestTestJob::ProcessOnePendingMessage());
@@ -256,9 +281,9 @@ TEST_F(ResourceDispatcherHostTest, TestMany) {
TEST_F(ResourceDispatcherHostTest, Cancel) {
EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0));
- MakeTestRequest(0, 0, 1, URLRequestTestJob::test_url_1());
- MakeTestRequest(0, 0, 2, URLRequestTestJob::test_url_2());
- MakeTestRequest(0, 0, 3, URLRequestTestJob::test_url_3());
+ MakeTestRequest(0, 1, URLRequestTestJob::test_url_1());
+ MakeTestRequest(0, 2, URLRequestTestJob::test_url_2());
+ MakeTestRequest(0, 3, URLRequestTestJob::test_url_3());
MakeCancelRequest(2);
// flush all the pending requests
@@ -298,10 +323,12 @@ TEST_F(ResourceDispatcherHostTest, TestProcessCancel) {
class TestReceiver : public ResourceDispatcherHost::Receiver {
public:
TestReceiver()
- : Receiver(ChildProcessInfo::RENDER_PROCESS),
- has_canceled_(false),
- received_after_canceled_(0) { }
- // ResourceDispatcherHost::Receiver implementation
+ : Receiver(ChildProcessInfo::RENDER_PROCESS, -1),
+ has_canceled_(false),
+ received_after_canceled_(0) {
+ }
+
+ // ResourceDispatcherHost::Receiver implementation
virtual bool Send(IPC::Message* msg) {
// no messages should be received when the process has been canceled
if (has_canceled_)
@@ -325,13 +352,13 @@ TEST_F(ResourceDispatcherHostTest, TestProcessCancel) {
EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0));
- MakeTestRequest(&test_receiver, 0, 0, 1, URLRequestTestJob::test_url_1());
+ MakeTestRequest(&test_receiver, 0, 1, URLRequestTestJob::test_url_1());
// request 2 goes to us
- MakeTestRequest(0, 0, 2, URLRequestTestJob::test_url_2());
+ MakeTestRequest(0, 2, URLRequestTestJob::test_url_2());
// request 3 goes to the test delegate
- MakeTestRequest(&test_receiver, 0, 0, 3, URLRequestTestJob::test_url_3());
+ MakeTestRequest(&test_receiver, 0, 3, URLRequestTestJob::test_url_3());
// TODO(mbelshe):
// Now that the async IO path is in place, the IO always completes on the
@@ -339,24 +366,25 @@ TEST_F(ResourceDispatcherHostTest, TestProcessCancel) {
// breaks the whole test.
//EXPECT_EQ(3, host_.pending_requests());
- // process each request for one level so one callback is called
+ // Process each request for one level so one callback is called.
for (int i = 0; i < 3; i++)
EXPECT_TRUE(URLRequestTestJob::ProcessOnePendingMessage());
- // cancel the requests to the test process
- host_.CancelRequestsForProcess(0);
+ // Cancel the requests to the test process.
+ host_.CancelRequestsForProcess(id());
test_receiver.has_canceled_ = true;
- // flush all the pending requests
+ // Flush all the pending requests.
while (URLRequestTestJob::ProcessOnePendingMessage());
EXPECT_EQ(0, host_.pending_requests());
- EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0));
+ EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(
+ id()));
- // the test delegate should not have gotten any messages after being canceled
+ // The test delegate should not have gotten any messages after being canceled.
ASSERT_EQ(0, test_receiver.received_after_canceled_);
- // we should have gotten exactly one result
+ // We should have gotten exactly one result.
ResourceIPCAccumulator::ClassifiedMessages msgs;
accum_.GetClassifiedMessages(&msgs);
ASSERT_EQ(1U, msgs.size());
@@ -365,18 +393,19 @@ TEST_F(ResourceDispatcherHostTest, TestProcessCancel) {
// Tests blocking and resuming requests.
TEST_F(ResourceDispatcherHostTest, TestBlockingResumingRequests) {
- EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0));
+ EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(
+ id()));
- host_.BlockRequestsForRoute(0, 1);
- host_.BlockRequestsForRoute(0, 2);
- host_.BlockRequestsForRoute(0, 3);
+ host_.BlockRequestsForRoute(id(), 1);
+ host_.BlockRequestsForRoute(id(), 2);
+ host_.BlockRequestsForRoute(id(), 3);
- MakeTestRequest(0, 0, 1, URLRequestTestJob::test_url_1());
- MakeTestRequest(0, 1, 2, URLRequestTestJob::test_url_2());
- MakeTestRequest(0, 0, 3, URLRequestTestJob::test_url_3());
- MakeTestRequest(0, 1, 4, URLRequestTestJob::test_url_1());
- MakeTestRequest(0, 2, 5, URLRequestTestJob::test_url_2());
- MakeTestRequest(0, 3, 6, URLRequestTestJob::test_url_3());
+ MakeTestRequest(0, 1, URLRequestTestJob::test_url_1());
+ MakeTestRequest(1, 2, URLRequestTestJob::test_url_2());
+ MakeTestRequest(0, 3, URLRequestTestJob::test_url_3());
+ MakeTestRequest(1, 4, URLRequestTestJob::test_url_1());
+ MakeTestRequest(2, 5, URLRequestTestJob::test_url_2());
+ MakeTestRequest(3, 6, URLRequestTestJob::test_url_3());
// Flush all the pending requests
while (URLRequestTestJob::ProcessOnePendingMessage());
@@ -392,7 +421,7 @@ TEST_F(ResourceDispatcherHostTest, TestBlockingResumingRequests) {
CheckSuccessfulRequest(msgs[1], URLRequestTestJob::test_data_3());
// Resume requests for RVH 1 and flush pending requests.
- host_.ResumeBlockedRequestsForRoute(0, 1);
+ host_.ResumeBlockedRequestsForRoute(id(), 1);
KickOffRequest();
while (URLRequestTestJob::ProcessOnePendingMessage());
@@ -403,7 +432,7 @@ TEST_F(ResourceDispatcherHostTest, TestBlockingResumingRequests) {
CheckSuccessfulRequest(msgs[1], URLRequestTestJob::test_data_1());
// Test that new requests are not blocked for RVH 1.
- MakeTestRequest(0, 1, 7, URLRequestTestJob::test_url_1());
+ MakeTestRequest(1, 7, URLRequestTestJob::test_url_1());
while (URLRequestTestJob::ProcessOnePendingMessage());
msgs.clear();
accum_.GetClassifiedMessages(&msgs);
@@ -411,12 +440,13 @@ TEST_F(ResourceDispatcherHostTest, TestBlockingResumingRequests) {
CheckSuccessfulRequest(msgs[0], URLRequestTestJob::test_data_1());
// Now resumes requests for all RVH (2 and 3).
- host_.ResumeBlockedRequestsForRoute(0, 2);
- host_.ResumeBlockedRequestsForRoute(0, 3);
+ host_.ResumeBlockedRequestsForRoute(id(), 2);
+ host_.ResumeBlockedRequestsForRoute(id(), 3);
KickOffRequest();
while (URLRequestTestJob::ProcessOnePendingMessage());
- EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0));
+ EXPECT_EQ(0,
+ host_.GetOutstandingRequestsMemoryCost(id()));
msgs.clear();
accum_.GetClassifiedMessages(&msgs);
@@ -427,14 +457,15 @@ TEST_F(ResourceDispatcherHostTest, TestBlockingResumingRequests) {
// Tests blocking and canceling requests.
TEST_F(ResourceDispatcherHostTest, TestBlockingCancelingRequests) {
- EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0));
+ EXPECT_EQ(0,
+ host_.GetOutstandingRequestsMemoryCost(id()));
- host_.BlockRequestsForRoute(0, 1);
+ host_.BlockRequestsForRoute(id(), 1);
- MakeTestRequest(0, 0, 1, URLRequestTestJob::test_url_1());
- MakeTestRequest(0, 1, 2, URLRequestTestJob::test_url_2());
- MakeTestRequest(0, 0, 3, URLRequestTestJob::test_url_3());
- MakeTestRequest(0, 1, 4, URLRequestTestJob::test_url_1());
+ MakeTestRequest(0, 1, URLRequestTestJob::test_url_1());
+ MakeTestRequest(1, 2, URLRequestTestJob::test_url_2());
+ MakeTestRequest(0, 3, URLRequestTestJob::test_url_3());
+ MakeTestRequest(1, 4, URLRequestTestJob::test_url_1());
// Flush all the pending requests.
while (URLRequestTestJob::ProcessOnePendingMessage());
@@ -450,11 +481,12 @@ TEST_F(ResourceDispatcherHostTest, TestBlockingCancelingRequests) {
CheckSuccessfulRequest(msgs[1], URLRequestTestJob::test_data_3());
// Cancel requests for RVH 1.
- host_.CancelBlockedRequestsForRoute(0, 1);
+ host_.CancelBlockedRequestsForRoute(id(), 1);
KickOffRequest();
while (URLRequestTestJob::ProcessOnePendingMessage());
- EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0));
+ EXPECT_EQ(0,
+ host_.GetOutstandingRequestsMemoryCost(id()));
msgs.clear();
accum_.GetClassifiedMessages(&msgs);
@@ -463,24 +495,31 @@ TEST_F(ResourceDispatcherHostTest, TestBlockingCancelingRequests) {
// Tests that blocked requests are canceled if their associated process dies.
TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsProcessDies) {
- EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0));
- EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(1));
+ // This second receiver is used to emulate a second process.
+ ForwardingReceiver second_receiver(this);
+
+ EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(
+ id()));
+ EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(
+ second_receiver.id()));
- host_.BlockRequestsForRoute(1, 0);
+ host_.BlockRequestsForRoute(second_receiver.id(), 0);
- MakeTestRequest(0, 0, 1, URLRequestTestJob::test_url_1());
- MakeTestRequest(1, 0, 2, URLRequestTestJob::test_url_2());
- MakeTestRequest(0, 0, 3, URLRequestTestJob::test_url_3());
- MakeTestRequest(1, 0, 4, URLRequestTestJob::test_url_1());
+ MakeTestRequest(this, 0, 1, URLRequestTestJob::test_url_1());
+ MakeTestRequest(&second_receiver, 0, 2, URLRequestTestJob::test_url_2());
+ MakeTestRequest(this, 0, 3, URLRequestTestJob::test_url_3());
+ MakeTestRequest(&second_receiver, 0, 4, URLRequestTestJob::test_url_1());
// Simulate process death.
- host_.CancelRequestsForProcess(1);
+ host_.CancelRequestsForProcess(second_receiver.id());
// Flush all the pending requests.
while (URLRequestTestJob::ProcessOnePendingMessage());
- EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0));
- EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(1));
+ EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(
+ id()));
+ EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(
+ second_receiver.id()));
// Sort out all the messages we saw by request.
ResourceIPCAccumulator::ClassifiedMessages msgs;
@@ -500,16 +539,19 @@ TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsProcessDies) {
// If this test turns the Purify bot red, check the ResourceDispatcherHost
// destructor to make sure the blocked requests are deleted.
TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsDontLeak) {
- host_.BlockRequestsForRoute(0, 1);
- host_.BlockRequestsForRoute(0, 2);
- host_.BlockRequestsForRoute(1, 1);
+ // This second receiver is used to emulate a second process.
+ ForwardingReceiver second_receiver(this);
+
+ host_.BlockRequestsForRoute(id(), 1);
+ host_.BlockRequestsForRoute(id(), 2);
+ host_.BlockRequestsForRoute(second_receiver.id(), 1);
- MakeTestRequest(0, 0, 1, URLRequestTestJob::test_url_1());
- MakeTestRequest(0, 1, 2, URLRequestTestJob::test_url_2());
- MakeTestRequest(0, 0, 3, URLRequestTestJob::test_url_3());
- MakeTestRequest(1, 1, 4, URLRequestTestJob::test_url_1());
- MakeTestRequest(0, 2, 5, URLRequestTestJob::test_url_2());
- MakeTestRequest(0, 2, 6, URLRequestTestJob::test_url_3());
+ MakeTestRequest(this, 0, 1, URLRequestTestJob::test_url_1());
+ MakeTestRequest(this, 1, 2, URLRequestTestJob::test_url_2());
+ MakeTestRequest(this, 0, 3, URLRequestTestJob::test_url_3());
+ MakeTestRequest(&second_receiver, 1, 4, URLRequestTestJob::test_url_1());
+ MakeTestRequest(this, 2, 5, URLRequestTestJob::test_url_2());
+ MakeTestRequest(this, 2, 6, URLRequestTestJob::test_url_3());
// Flush all the pending requests.
while (URLRequestTestJob::ProcessOnePendingMessage());
@@ -574,7 +616,8 @@ TEST_F(ResourceDispatcherHostTest, IncrementOutstandingRequestsMemoryCost) {
// Test that when too many requests are outstanding for a particular
// render_process_host_id, any subsequent request from it fails.
TEST_F(ResourceDispatcherHostTest, TooManyOutstandingRequests) {
- EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0));
+ EXPECT_EQ(0,
+ host_.GetOutstandingRequestsMemoryCost(id()));
// Expected cost of each request as measured by
// ResourceDispatcherHost::CalculateApproximateMemoryCost().
@@ -591,24 +634,30 @@ TEST_F(ResourceDispatcherHostTest, TooManyOutstandingRequests) {
// throttling kicks in.
size_t kMaxRequests = kMaxCostPerProcess / kMemoryCostOfTest2Req;
- // Saturate the number of outstanding requests for process 0.
+ // This second receiver is used to emulate a second process.
+ ForwardingReceiver second_receiver(this);
+
+ // Saturate the number of outstanding requests for our process.
for (size_t i = 0; i < kMaxRequests; ++i)
- MakeTestRequest(0, 0, i + 1, URLRequestTestJob::test_url_2());
+ MakeTestRequest(this, 0, i + 1, URLRequestTestJob::test_url_2());
- // Issue two more requests for process 0 -- these should fail immediately.
- MakeTestRequest(0, 0, kMaxRequests + 1, URLRequestTestJob::test_url_2());
- MakeTestRequest(0, 0, kMaxRequests + 2, URLRequestTestJob::test_url_2());
+ // Issue two more requests for our process -- these should fail immediately.
+ MakeTestRequest(this, 0, kMaxRequests + 1, URLRequestTestJob::test_url_2());
+ MakeTestRequest(this, 0, kMaxRequests + 2, URLRequestTestJob::test_url_2());
- // Issue two requests for process 1 -- these should succeed since
+ // Issue two requests for the second process -- these should succeed since
// it is just process 0 that is saturated.
- MakeTestRequest(1, 0, kMaxRequests + 3, URLRequestTestJob::test_url_2());
- MakeTestRequest(1, 0, kMaxRequests + 4, URLRequestTestJob::test_url_2());
+ MakeTestRequest(&second_receiver, 0, kMaxRequests + 3,
+ URLRequestTestJob::test_url_2());
+ MakeTestRequest(&second_receiver, 0, kMaxRequests + 4,
+ URLRequestTestJob::test_url_2());
// Flush all the pending requests.
while (URLRequestTestJob::ProcessOnePendingMessage());
MessageLoop::current()->RunAllPending();
- EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0));
+ EXPECT_EQ(0,
+ host_.GetOutstandingRequestsMemoryCost(id()));
// Sorts out all the messages we saw by request.
ResourceIPCAccumulator::ClassifiedMessages msgs;
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index c8183bb..61debd5 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -135,18 +135,18 @@ void RenderParamsFromPrintSettings(const printing::PrintSettings& settings,
ResourceMessageFilter::ResourceMessageFilter(
ResourceDispatcherHost* resource_dispatcher_host,
+ int child_id,
AudioRendererHost* audio_renderer_host,
PluginService* plugin_service,
printing::PrintJobManager* print_job_manager,
Profile* profile,
RenderWidgetHelper* render_widget_helper,
SpellChecker* spellchecker)
- : Receiver(RENDER_PROCESS),
+ : Receiver(RENDER_PROCESS, child_id),
channel_(NULL),
resource_dispatcher_host_(resource_dispatcher_host),
plugin_service_(plugin_service),
print_job_manager_(print_job_manager),
- render_process_id_(-1),
spellchecker_(spellchecker),
ALLOW_THIS_IN_INITIALIZER_LIST(resolve_proxy_msg_helper_(this, NULL)),
request_context_(profile->GetRequestContext()),
@@ -191,9 +191,8 @@ ResourceMessageFilter::~ResourceMessageFilter() {
base::CloseProcessHandle(handle());
}
-void ResourceMessageFilter::Init(int render_process_id) {
- render_process_id_ = render_process_id;
- render_widget_helper_->Init(render_process_id, resource_dispatcher_host_);
+void ResourceMessageFilter::Init() {
+ render_widget_helper_->Init(id(), resource_dispatcher_host_);
appcache_dispatcher_host_->Initialize(this);
}
@@ -217,16 +216,9 @@ void ResourceMessageFilter::OnChannelConnected(int32 peer_pid) {
}
set_handle(peer_handle);
- // Set the process ID if Init hasn't been called yet. This doesn't work in
- // single-process mode since peer_pid won't be the special fake PID we use
- // for RenderProcessHost in that mode, so we just have to hope that Init
- // is called first in that case.
- if (render_process_id_ == -1)
- render_process_id_ = peer_pid;
-
// Hook AudioRendererHost to this object after channel is connected so it can
// this object for sending messages.
- audio_renderer_host_->IPCChannelConnected(render_process_id_, handle(), this);
+ audio_renderer_host_->IPCChannelConnected(id(), handle(), this);
WorkerService::GetInstance()->Initialize(
resource_dispatcher_host_, ui_loop());
@@ -245,7 +237,7 @@ void ResourceMessageFilter::OnChannelClosing() {
// Unhook us from all pending network requests so they don't get sent to a
// deleted object.
- resource_dispatcher_host_->CancelRequestsForProcess(render_process_id_);
+ resource_dispatcher_host_->CancelRequestsForProcess(id());
// Unhook AudioRendererHost.
audio_renderer_host_->IPCChannelClosing();
@@ -389,7 +381,7 @@ void ResourceMessageFilter::OnReceiveContextMenuMsg(const IPC::Message& msg) {
// Create a new ViewHostMsg_ContextMenu message.
const ViewHostMsg_ContextMenu context_menu_message(msg.routing_id(), params);
ui_loop()->PostTask(FROM_HERE, new ContextMenuMessageDispatcher(
- render_process_id_, context_menu_message));
+ id(), context_menu_message));
}
// Called on the IPC thread:
@@ -574,17 +566,15 @@ void ResourceMessageFilter::OnCreateDedicatedWorker(const GURL& url,
int* route_id) {
*route_id = render_widget_helper_->GetNextRoutingID();
WorkerService::GetInstance()->CreateDedicatedWorker(
- url, render_process_id_, render_view_route_id, this, render_process_id_,
- *route_id);
+ url, id(), render_view_route_id, this, id(), *route_id);
}
void ResourceMessageFilter::OnCancelCreateDedicatedWorker(int route_id) {
- WorkerService::GetInstance()->CancelCreateDedicatedWorker(
- render_process_id_, route_id);
+ WorkerService::GetInstance()->CancelCreateDedicatedWorker(id(), route_id);
}
void ResourceMessageFilter::OnForwardToWorker(const IPC::Message& message) {
- WorkerService::GetInstance()->ForwardMessage(message, render_process_id_);
+ WorkerService::GetInstance()->ForwardMessage(message, id());
}
void ResourceMessageFilter::OnDownloadUrl(const IPC::Message& message,
@@ -592,7 +582,7 @@ void ResourceMessageFilter::OnDownloadUrl(const IPC::Message& message,
const GURL& referrer) {
resource_dispatcher_host_->BeginDownload(url,
referrer,
- render_process_id_,
+ id(),
message.routing_id(),
request_context_);
}
@@ -972,8 +962,7 @@ void ResourceMessageFilter::OnGetFileSize(const FilePath& path,
// Get file size only when the child process has been granted permission to
// upload the file.
- if (ChildProcessSecurityPolicy::GetInstance()->CanUploadFile(
- render_process_id_, path)) {
+ if (ChildProcessSecurityPolicy::GetInstance()->CanUploadFile(id(), path)) {
FileSystemAccessor::RequestFileSize(
path,
reply_msg,
diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h
index f3087a8..825422b 100644
--- a/chrome/browser/renderer_host/resource_message_filter.h
+++ b/chrome/browser/renderer_host/resource_message_filter.h
@@ -70,6 +70,7 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
// ResourceMessageFilter is 'given' ownership of the spellchecker
// object and must clean it up on exit.
ResourceMessageFilter(ResourceDispatcherHost* resource_dispatcher_host,
+ int child_id,
AudioRendererHost* audio_renderer_host,
PluginService* plugin_service,
printing::PrintJobManager* print_job_manager,
@@ -78,7 +79,7 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
SpellChecker* spellchecker);
virtual ~ResourceMessageFilter();
- void Init(int render_process_id);
+ void Init();
// IPC::ChannelProxy::MessageFilter methods:
virtual void OnFilterAdded(IPC::Channel* channel);
@@ -92,7 +93,6 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
virtual URLRequestContext* GetRequestContext(
uint32 request_id,
const ViewHostMsg_Resource_Request& request_data);
- virtual int GetProcessId() const { return render_process_id_; }
SpellChecker* spellchecker() { return spellchecker_.get(); }
ResourceDispatcherHost* resource_dispatcher_host() {
@@ -273,7 +273,7 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
// used by the ResourceDispatcherHost to look up the TabContents that
// originated URLRequest. Since the RenderProcessHost can be destroyed
// before this object, we only hold an ID for lookup.
- int render_process_id_;
+ int child_id_;
// Our spellchecker object.
scoped_refptr<SpellChecker> spellchecker_;
diff --git a/chrome/browser/renderer_host/resource_request_details.h b/chrome/browser/renderer_host/resource_request_details.h
index f8a5459..e08e0b2 100644
--- a/chrome/browser/renderer_host/resource_request_details.h
+++ b/chrome/browser/renderer_host/resource_request_details.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// 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.
@@ -28,7 +28,6 @@ class ResourceRequestDetails {
referrer_(request->referrer()),
has_upload_(request->has_upload()),
load_flags_(request->load_flags()),
- origin_pid_(request->origin_pid()),
status_(request->status()),
ssl_cert_id_(cert_id),
ssl_cert_status_(request->ssl_info().cert_status) {
@@ -39,9 +38,10 @@ class ResourceRequestDetails {
frame_origin_ = info->frame_origin;
main_frame_origin_ = info->main_frame_origin;
filter_policy_ = info->filter_policy;
+ origin_child_id_ = info->child_id;
}
- virtual ~ResourceRequestDetails() { }
+ virtual ~ResourceRequestDetails() {}
const GURL& url() const { return url_; }
const GURL& original_url() const { return original_url_; }
@@ -51,7 +51,7 @@ class ResourceRequestDetails {
const std::string& main_frame_origin() const { return main_frame_origin_; }
bool has_upload() const { return has_upload_; }
int load_flags() const { return load_flags_; }
- int origin_pid() const { return origin_pid_; }
+ int origin_child_id() const { return origin_child_id_; }
const URLRequestStatus& status() const { return status_; }
int ssl_cert_id() const { return ssl_cert_id_; }
int ssl_cert_status() const { return ssl_cert_status_; }
@@ -67,7 +67,7 @@ class ResourceRequestDetails {
std::string main_frame_origin_;
bool has_upload_;
int load_flags_;
- int origin_pid_;
+ int origin_child_id_;
URLRequestStatus status_;
int ssl_cert_id_;
int ssl_cert_status_;
@@ -84,7 +84,7 @@ class ResourceRedirectDetails : public ResourceRequestDetails {
int cert_id,
const GURL& new_url)
: ResourceRequestDetails(request, cert_id),
- new_url_(new_url) { }
+ new_url_(new_url) {}
// The URL to which we are being redirected.
const GURL& new_url() const { return new_url_; }
diff --git a/chrome/browser/renderer_host/test/site_instance_unittest.cc b/chrome/browser/renderer_host/test/site_instance_unittest.cc
index 818ca8e..6953f36 100644
--- a/chrome/browser/renderer_host/test/site_instance_unittest.cc
+++ b/chrome/browser/renderer_host/test/site_instance_unittest.cc
@@ -423,8 +423,8 @@ TEST_F(SiteInstanceTest, ProcessSharingByType) {
// Create some extension instances and make sure they share a process.
scoped_refptr<SiteInstance> extension1_instance(
CreateSiteInstance(&rph_factory, GURL("chrome-extension://foo/bar")));
- policy->Add(extension1_instance->GetProcess()->pid());
- policy->GrantExtensionBindings(extension1_instance->GetProcess()->pid());
+ policy->Add(extension1_instance->GetProcess()->id());
+ policy->GrantExtensionBindings(extension1_instance->GetProcess()->id());
scoped_refptr<SiteInstance> extension2_instance(
CreateSiteInstance(&rph_factory, GURL("chrome-extension://baz/bar")));
@@ -437,8 +437,8 @@ TEST_F(SiteInstanceTest, ProcessSharingByType) {
// Create some DOMUI instances and make sure they share a process.
scoped_refptr<SiteInstance> dom1_instance(
CreateSiteInstance(&rph_factory, GURL("chrome://newtab")));
- policy->Add(dom1_instance->GetProcess()->pid());
- policy->GrantDOMUIBindings(dom1_instance->GetProcess()->pid());
+ policy->Add(dom1_instance->GetProcess()->id());
+ policy->GrantDOMUIBindings(dom1_instance->GetProcess()->id());
scoped_refptr<SiteInstance> dom2_instance(
CreateSiteInstance(&rph_factory, GURL("chrome://history")));
diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc
index 43e77a8..e0a0f77 100644
--- a/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc
@@ -144,7 +144,7 @@ class SafeBrowsingBlockingPageTest : public RenderViewHostTestHarness,
resource->url = url;
resource->resource_type = resource_type;
resource->threat_type = SafeBrowsingService::URL_MALWARE;
- resource->render_process_host_id = contents_->process()->pid();
+ resource->render_process_host_id = contents_->process()->id();
resource->render_view_id = contents_->render_view_host()->routing_id();
}
diff --git a/chrome/browser/ssl/ssl_blocking_page.cc b/chrome/browser/ssl/ssl_blocking_page.cc
index 5d3e821..a25fda3 100644
--- a/chrome/browser/ssl/ssl_blocking_page.cc
+++ b/chrome/browser/ssl/ssl_blocking_page.cc
@@ -91,7 +91,7 @@ std::string SSLBlockingPage::GetHTMLContents() {
void SSLBlockingPage::UpdateEntry(NavigationEntry* entry) {
const net::SSLInfo& ssl_info = handler_->ssl_info();
int cert_id = CertStore::GetSharedInstance()->StoreCert(
- ssl_info.cert, tab()->render_view_host()->process()->pid());
+ ssl_info.cert, tab()->render_view_host()->process()->id());
entry->ssl().set_security_style(SECURITY_STYLE_AUTHENTICATION_BROKEN);
entry->ssl().set_cert_id(cert_id);
diff --git a/chrome/browser/ssl/ssl_error_handler.cc b/chrome/browser/ssl/ssl_error_handler.cc
index b7f3fd2..ed04c6fb 100644
--- a/chrome/browser/ssl/ssl_error_handler.cc
+++ b/chrome/browser/ssl/ssl_error_handler.cc
@@ -32,7 +32,7 @@ SSLErrorHandler::SSLErrorHandler(ResourceDispatcherHost* rdh,
ResourceDispatcherHost::ExtraRequestInfo* info =
ResourceDispatcherHost::ExtraInfoForRequest(request);
- request_id_.process_id = info->process_id;
+ request_id_.child_id = info->child_id;
request_id_.request_id = info->request_id;
if (!ResourceDispatcherHost::RenderViewForRequest(request,
diff --git a/chrome/browser/ssl/ssl_manager.cc b/chrome/browser/ssl/ssl_manager.cc
index 573597c..63e590d 100644
--- a/chrome/browser/ssl/ssl_manager.cc
+++ b/chrome/browser/ssl/ssl_manager.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// 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.
@@ -7,6 +7,7 @@
#include "app/l10n_util.h"
#include "base/message_loop.h"
#include "chrome/browser/load_from_memory_cache_details.h"
+#include "chrome/browser/net/url_request_tracking.h"
#include "chrome/browser/renderer_host/resource_request_details.h"
#include "chrome/browser/ssl/ssl_cert_error_handler.h"
#include "chrome/browser/ssl/ssl_mixed_content_handler.h"
@@ -109,7 +110,7 @@ bool SSLManager::ShouldStartRequest(ResourceDispatcherHost* rdh,
info->resource_type,
info->frame_origin,
info->main_frame_origin,
- info->process_id,
+ info->child_id,
ui_loop),
&SSLMixedContentHandler::Dispatch));
return false;
@@ -241,7 +242,7 @@ void SSLManager::DidStartResourceResponse(ResourceRequestDetails* details) {
details->frame_origin(),
details->main_frame_origin(),
details->filter_policy(),
- details->origin_pid(),
+ details->origin_child_id(),
details->ssl_cert_id(),
details->ssl_cert_status());
diff --git a/chrome/browser/ssl/ssl_policy.cc b/chrome/browser/ssl/ssl_policy.cc
index cbef647..dd536ef 100644
--- a/chrome/browser/ssl/ssl_policy.cc
+++ b/chrome/browser/ssl/ssl_policy.cc
@@ -175,7 +175,7 @@ void SSLPolicy::UpdateEntry(NavigationEntry* entry) {
// possibly have mixed content. See bug http://crbug.com/12423.
if (site_instance &&
backend_->DidMarkHostAsBroken(entry->url().host(),
- site_instance->GetProcess()->pid()))
+ site_instance->GetProcess()->id()))
entry->ssl().set_has_mixed_content();
}
@@ -299,7 +299,8 @@ void SSLPolicy::ShowErrorPage(SSLCertErrorHandler* handler) {
TabContents* tab = handler->GetTabContents();
int cert_id = CertStore::GetSharedInstance()->StoreCert(
- handler->ssl_info().cert, tab->render_view_host()->process()->pid());
+ handler->ssl_info().cert,
+ tab->render_view_host()->process()->id());
std::string security_info =
SSLManager::SerializeSecurityInfo(cert_id,
handler->ssl_info().cert_status,
@@ -350,18 +351,18 @@ void SSLPolicy::UpdateStateForMixedContent(SSLRequestInfo* info) {
if (info->resource_type() != ResourceType::MAIN_FRAME ||
info->resource_type() != ResourceType::SUB_FRAME) {
// The frame's origin now contains mixed content and therefore is broken.
- MarkOriginAsBroken(info->frame_origin(), info->pid());
+ MarkOriginAsBroken(info->frame_origin(), info->child_id());
}
if (info->resource_type() != ResourceType::MAIN_FRAME) {
// The main frame now contains a frame with mixed content. Therefore, we
// mark the main frame's origin as broken too.
- MarkOriginAsBroken(info->main_frame_origin(), info->pid());
+ MarkOriginAsBroken(info->main_frame_origin(), info->child_id());
}
}
void SSLPolicy::UpdateStateForUnsafeContent(SSLRequestInfo* info) {
// This request as a broken cert, which means its host is broken.
- backend_->MarkHostAsBroken(info->url().host(), info->pid());
+ backend_->MarkHostAsBroken(info->url().host(), info->child_id());
UpdateStateForMixedContent(info);
}
diff --git a/chrome/browser/ssl/ssl_policy_backend.cc b/chrome/browser/ssl/ssl_policy_backend.cc
index e249252..592ccc0 100644
--- a/chrome/browser/ssl/ssl_policy_backend.cc
+++ b/chrome/browser/ssl/ssl_policy_backend.cc
@@ -127,8 +127,8 @@ void SSLPolicyBackend::AddMessageToConsole(
string16(), message, level);
}
-void SSLPolicyBackend::MarkHostAsBroken(const std::string& host, int pid) {
- ssl_host_state_->MarkHostAsBroken(host, pid);
+void SSLPolicyBackend::MarkHostAsBroken(const std::string& host, int id) {
+ ssl_host_state_->MarkHostAsBroken(host, id);
DispatchSSLInternalStateChanged();
}
diff --git a/chrome/browser/ssl/ssl_request_info.h b/chrome/browser/ssl/ssl_request_info.h
index fc8e417..3daf91f 100644
--- a/chrome/browser/ssl/ssl_request_info.h
+++ b/chrome/browser/ssl/ssl_request_info.h
@@ -21,7 +21,7 @@ class SSLRequestInfo : public base::RefCounted<SSLRequestInfo> {
const std::string& frame_origin,
const std::string& main_frame_origin,
FilterPolicy::Type filter_policy,
- int pid,
+ int child_id,
int ssl_cert_id,
int ssl_cert_status)
: url_(url),
@@ -29,7 +29,7 @@ class SSLRequestInfo : public base::RefCounted<SSLRequestInfo> {
frame_origin_(frame_origin),
main_frame_origin_(main_frame_origin),
filter_policy_(filter_policy),
- pid_(pid),
+ child_id_(child_id),
ssl_cert_id_(ssl_cert_id),
ssl_cert_status_(ssl_cert_status) {
}
@@ -39,7 +39,7 @@ class SSLRequestInfo : public base::RefCounted<SSLRequestInfo> {
const std::string& frame_origin() const { return frame_origin_; }
const std::string& main_frame_origin() const { return main_frame_origin_; }
FilterPolicy::Type filter_policy() const { return filter_policy_; }
- int pid() const { return pid_; }
+ int child_id() const { return child_id_; }
int ssl_cert_id() const { return ssl_cert_id_; }
int ssl_cert_status() const { return ssl_cert_status_; }
@@ -49,7 +49,7 @@ class SSLRequestInfo : public base::RefCounted<SSLRequestInfo> {
std::string frame_origin_;
std::string main_frame_origin_;
FilterPolicy::Type filter_policy_;
- int pid_;
+ int child_id_;
int ssl_cert_id_;
int ssl_cert_status_;
diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc
index b7e739e..f9d6ded 100644
--- a/chrome/browser/tab_contents/interstitial_page.cc
+++ b/chrome/browser/tab_contents/interstitial_page.cc
@@ -120,7 +120,7 @@ InterstitialPage::InterstitialPage(TabContents* tab,
enabled_(true),
action_taken_(false),
render_view_host_(NULL),
- original_rvh_process_id_(tab->render_view_host()->process()->pid()),
+ original_child_id_(tab->render_view_host()->process()->id()),
original_rvh_id_(tab->render_view_host()->routing_id()),
should_revert_tab_title_(false),
resource_dispatcher_host_notified_(false),
@@ -263,7 +263,7 @@ void InterstitialPage::Observe(NotificationType type,
// The RenderViewHost is being destroyed (as part of the tab being
// closed), make sure we clear the blocked requests.
RenderViewHost* rvh = Source<RenderViewHost>(source).ptr();
- DCHECK(rvh->process()->pid() == original_rvh_process_id_ &&
+ DCHECK(rvh->process()->id() == original_child_id_ &&
rvh->routing_id() == original_rvh_id_);
TakeActionOnResourceDispatcher(CANCEL);
}
@@ -490,11 +490,11 @@ void InterstitialPage::TakeActionOnResourceDispatcher(
// NOTIFY_RENDER_WIDGET_HOST_DESTROYED.
// Also we need to test there is an IO thread, as when unit-tests we don't
// have one.
- RenderViewHost* rvh = RenderViewHost::FromID(original_rvh_process_id_,
+ RenderViewHost* rvh = RenderViewHost::FromID(original_child_id_,
original_rvh_id_);
if (rvh && g_browser_process->io_thread()) {
g_browser_process->io_thread()->message_loop()->PostTask(
- FROM_HERE, new ResourceRequestTask(original_rvh_process_id_,
+ FROM_HERE, new ResourceRequestTask(original_child_id_,
original_rvh_id_,
action));
}
diff --git a/chrome/browser/tab_contents/interstitial_page.h b/chrome/browser/tab_contents/interstitial_page.h
index dce25e4..3d6a6bc 100644
--- a/chrome/browser/tab_contents/interstitial_page.h
+++ b/chrome/browser/tab_contents/interstitial_page.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// 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.
@@ -183,8 +183,8 @@ class InterstitialPage : public NotificationObserver,
// The RenderViewHost displaying the interstitial contents.
RenderViewHost* render_view_host_;
- // The IDs for the RenderViewHost hidden by this interstitial.
- int original_rvh_process_id_;
+ // The IDs for the Render[View|Process]Host hidden by this interstitial.
+ int original_child_id_;
int original_rvh_id_;
// Whether or not we should change the title of the tab when hidden (to revert
@@ -215,4 +215,4 @@ class InterstitialPage : public NotificationObserver,
DISALLOW_COPY_AND_ASSIGN(InterstitialPage);
};
-#endif // #ifndef CHROME_BROWSER_TAB_CONTENTS_INTERSTITIAL_PAGE_H_
+#endif // CHROME_BROWSER_TAB_CONTENTS_INTERSTITIAL_PAGE_H_
diff --git a/chrome/browser/tab_contents/render_view_host_manager.cc b/chrome/browser/tab_contents/render_view_host_manager.cc
index e25f786..101c1f8 100644
--- a/chrome/browser/tab_contents/render_view_host_manager.cc
+++ b/chrome/browser/tab_contents/render_view_host_manager.cc
@@ -146,11 +146,12 @@ bool RenderViewHostManager::ShouldCloseTabOnUnresponsiveRenderer() {
// handler later finishes, this call will be ignored because the state in
// CrossSiteResourceHandler will already be cleaned up.)
ViewMsg_ClosePage_Params params;
- params.closing_process_id = render_view_host_->process()->pid();
+ params.closing_process_id =
+ render_view_host_->process()->id();
params.closing_route_id = render_view_host_->routing_id();
params.for_cross_site_transition = true;
params.new_render_process_host_id =
- pending_render_view_host_->process()->pid();
+ pending_render_view_host_->process()->id();
params.new_request_id = pending_request_id;
current_host()->process()->CrossSiteClosePageACK(params);
}
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 166c59b..cfdde6c 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -607,7 +607,6 @@ void TabContents::NotifyNavigationStateChanged(unsigned changed_flags) {
void TabContents::DidBecomeSelected() {
controller_.SetActive(true);
-
if (render_widget_host_view()) {
render_widget_host_view()->DidBecomeSelected();
#if defined(OS_MACOSX)
@@ -615,10 +614,7 @@ void TabContents::DidBecomeSelected() {
#endif
}
- // If pid() is -1, that means the RenderProcessHost still hasn't been
- // initialized. It'll register with CacheManagerHost when it is.
- if (process()->pid() != -1)
- WebCacheManager::GetInstance()->ObserveActivity(process()->pid());
+ WebCacheManager::GetInstance()->ObserveActivity(process()->id());
}
void TabContents::WasHidden() {
@@ -1713,7 +1709,7 @@ void TabContents::DidLoadResourceFromMemoryCache(
&cert_id, &cert_status,
&security_bits);
LoadFromMemoryCacheDetails details(url, frame_origin, main_frame_origin,
- process()->pid(), cert_id, cert_status);
+ process()->id(), cert_id, cert_status);
NotificationService::current()->Notify(
NotificationType::LOAD_FROM_MEMORY_CACHE,
@@ -1939,8 +1935,8 @@ void TabContents::DidNavigate(RenderViewHost* rvh,
UpdateHistoryForNavigation(GetURL(), details, params);
}
- if (!did_navigate)
- return; // No navigation happened.
+ if (!did_navigate)
+ return; // No navigation happened.
// DO NOT ADD MORE STUFF TO THIS FUNCTION! Your component should either listen
// for the appropriate notification (best) or you can add it to
diff --git a/chrome/browser/task_manager.cc b/chrome/browser/task_manager.cc
index 886220a..88083cc 100644
--- a/chrome/browser/task_manager.cc
+++ b/chrome/browser/task_manager.cc
@@ -13,6 +13,7 @@
#include "base/thread.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/net/url_request_tracking.h"
#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
#include "chrome/browser/task_manager_resource_providers.h"
@@ -611,8 +612,8 @@ void TaskManagerModel::BytesRead(BytesReadParam param) {
TaskManager::Resource* resource = NULL;
for (ResourceProviderList::iterator iter = providers_.begin();
iter != providers_.end(); ++iter) {
- resource = (*iter)->GetResource(param.origin_pid,
- param.render_process_host_id,
+ resource = (*iter)->GetResource(param.origin_child_id,
+ param.render_process_host_child_id,
param.routing_id);
if (resource)
break;
@@ -658,18 +659,20 @@ void TaskManagerModel::OnJobRedirect(URLRequestJob* job,
}
void TaskManagerModel::OnBytesRead(URLRequestJob* job, int byte_count) {
- int render_process_host_id = -1, routing_id = -1;
+ int render_process_host_child_id = -1, routing_id = -1;
ResourceDispatcherHost::RenderViewForRequest(job->request(),
- &render_process_host_id,
+ &render_process_host_child_id,
&routing_id);
// This happens in the IO thread, post it to the UI thread.
+ int origin_child_id =
+ chrome_browser_net::GetOriginProcessUniqueIDForRequest(job->request());
ui_loop_->PostTask(FROM_HERE,
NewRunnableMethod(
- this,
- &TaskManagerModel::BytesRead,
- BytesReadParam(job->request()->origin_pid(),
- render_process_host_id, routing_id,
- byte_count)));
+ this,
+ &TaskManagerModel::BytesRead,
+ BytesReadParam(origin_child_id,
+ render_process_host_child_id,
+ routing_id, byte_count)));
}
bool TaskManagerModel::GetProcessMetricsForRows(
diff --git a/chrome/browser/task_manager.h b/chrome/browser/task_manager.h
index 3ca3774..811cf2f 100644
--- a/chrome/browser/task_manager.h
+++ b/chrome/browser/task_manager.h
@@ -222,15 +222,23 @@ class TaskManagerModel : public URLRequestJobTracker::JobObserver,
// This struct is used to exchange information between the io and ui threads.
struct BytesReadParam {
- BytesReadParam(int origin_pid, int render_process_host_id,
- int routing_id, int byte_count)
- : origin_pid(origin_pid),
- render_process_host_id(render_process_host_id),
+ BytesReadParam(int origin_child_id,
+ int render_process_host_child_id,
+ int routing_id,
+ int byte_count)
+ : origin_child_id(origin_child_id),
+ render_process_host_child_id(render_process_host_child_id),
routing_id(routing_id),
- byte_count(byte_count) { }
+ byte_count(byte_count) {}
+
+ // This is the child ID of the originator of the request. It will often be
+ // the same as the render_process_host_child_id, but will be different when
+ // another sub-process like a plugin is routing requests through a renderer.
+ int origin_child_id;
+
+ // The child ID of the RenderProcessHist this request was routed through.
+ int render_process_host_child_id;
- int origin_pid;
- int render_process_host_id;
int routing_id;
int byte_count;
};
diff --git a/chrome/browser/task_manager_resource_providers.cc b/chrome/browser/task_manager_resource_providers.cc
index 7c51b2e..135da63 100644
--- a/chrome/browser/task_manager_resource_providers.cc
+++ b/chrome/browser/task_manager_resource_providers.cc
@@ -271,7 +271,7 @@ TaskManagerChildProcessResource::TaskManagerChildProcessResource(
network_usage_support_(false) {
// We cache the process id because it's not cheap to calculate, and it won't
// be available when we get the plugin disconnected notification.
- pid_ = child_proc.GetProcessId();
+ pid_ = child_proc.id();
if (!default_icon_) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
default_icon_ = rb.GetBitmapNamed(IDR_PLUGIN);
diff --git a/chrome/browser/utility_process_host_unittest.cc b/chrome/browser/utility_process_host_unittest.cc
index 8703b67..43ac61b 100644
--- a/chrome/browser/utility_process_host_unittest.cc
+++ b/chrome/browser/utility_process_host_unittest.cc
@@ -99,8 +99,8 @@ class ProcessClosedObserver : public NotificationObserver {
NotificationService::AllSources());
}
- void RunUntilClose(int child_pid) {
- child_pid_ = child_pid;
+ void RunUntilClose(int child_id) {
+ child_id_ = child_id;
observed_ = false;
message_loop_->Run();
DCHECK(observed_);
@@ -112,7 +112,7 @@ class ProcessClosedObserver : public NotificationObserver {
const NotificationDetails& details) {
DCHECK(type == NotificationType::CHILD_PROCESS_HOST_DISCONNECTED);
ChildProcessInfo* info = Details<ChildProcessInfo>(details).ptr();
- if (info->GetProcessId() == child_pid_) {
+ if (info->id() == child_id_) {
observed_ = true;
message_loop_->Quit();
}
@@ -120,7 +120,7 @@ class ProcessClosedObserver : public NotificationObserver {
MessageLoop* message_loop_;
NotificationRegistrar registrar_;
- int child_pid_;
+ int child_id_;
bool observed_;
};
@@ -146,7 +146,7 @@ TEST_F(UtilityProcessHostTest, ExtensionUnpacker) {
ProcessClosedObserver observer(&message_loop_);
process_host->StartExtensionUnpacker(
temp_extension_dir.AppendASCII("theme.crx"));
- observer.RunUntilClose(process_host->GetProcessId());
+ observer.RunUntilClose(process_host->id());
EXPECT_TRUE(client->success());
// Clean up the temp dir.
diff --git a/chrome/browser/visitedlink_unittest.cc b/chrome/browser/visitedlink_unittest.cc
index fb4b109..8ce1900 100644
--- a/chrome/browser/visitedlink_unittest.cc
+++ b/chrome/browser/visitedlink_unittest.cc
@@ -507,11 +507,8 @@ class VisitRelayingRenderProcessHost : public BrowserRenderProcessHost {
public:
explicit VisitRelayingRenderProcessHost(Profile* profile)
: BrowserRenderProcessHost(profile) {
- static int prev_id = 0;
- SetProcessID(++prev_id);
}
virtual ~VisitRelayingRenderProcessHost() {
- RemoveFromList();
}
virtual bool Init() { return true; }
diff --git a/chrome/browser/worker_host/worker_process_host.cc b/chrome/browser/worker_host/worker_process_host.cc
index 69d3a96..9570743 100644
--- a/chrome/browser/worker_host/worker_process_host.cc
+++ b/chrome/browser/worker_host/worker_process_host.cc
@@ -40,13 +40,13 @@
// Notifies RenderViewHost that one or more worker objects crashed.
class WorkerCrashTask : public Task {
public:
- WorkerCrashTask(int render_process_id, int render_view_id)
- : render_process_id_(render_process_id),
+ WorkerCrashTask(int render_process_unique_id, int render_view_id)
+ : render_process_unique_id_(render_process_unique_id),
render_view_id_(render_view_id) { }
void Run() {
RenderViewHost* host =
- RenderViewHost::FromID(render_process_id_, render_view_id_);
+ RenderViewHost::FromID(render_process_unique_id_, render_view_id_);
if (host) {
RenderViewHostDelegate::BrowserIntegration* integration_delegate =
host->delegate()->GetBrowserIntegrationDelegate();
@@ -56,7 +56,7 @@ class WorkerCrashTask : public Task {
}
private:
- int render_process_id_;
+ int render_process_unique_id_;
int render_view_id_;
};
@@ -79,10 +79,10 @@ WorkerProcessHost::~WorkerProcessHost() {
MessageLoop* ui_loop = WorkerService::GetInstance()->ui_loop();
for (Instances::iterator i = instances_.begin(); i != instances_.end(); ++i) {
ui_loop->PostTask(FROM_HERE, new WorkerCrashTask(
- i->renderer_process_id, i->render_view_route_id));
+ i->renderer_id, i->render_view_route_id));
}
- ChildProcessSecurityPolicy::GetInstance()->Remove(GetProcessId());
+ ChildProcessSecurityPolicy::GetInstance()->Remove(id());
}
bool WorkerProcessHost::Init() {
@@ -128,14 +128,14 @@ bool WorkerProcessHost::Init() {
return false;
SetHandle(process);
- ChildProcessSecurityPolicy::GetInstance()->Add(GetProcessId());
+ ChildProcessSecurityPolicy::GetInstance()->Add(id());
return true;
}
void WorkerProcessHost::CreateWorker(const WorkerInstance& instance) {
ChildProcessSecurityPolicy::GetInstance()->GrantRequestURL(
- GetProcessId(), instance.url);
+ id(), instance.url);
instances_.push_back(instance);
Send(new WorkerProcessMsg_CreateWorker(
@@ -149,7 +149,7 @@ void WorkerProcessHost::CreateWorker(const WorkerInstance& instance) {
bool WorkerProcessHost::FilterMessage(const IPC::Message& message,
int sender_pid) {
for (Instances::iterator i = instances_.begin(); i != instances_.end(); ++i) {
- if (i->sender_pid == sender_pid &&
+ if (i->sender_id == sender_pid &&
i->sender_route_id == message.routing_id()) {
RelayMessage(
message, this, i->worker_route_id, next_route_id_callback_.get());
@@ -299,15 +299,14 @@ void WorkerProcessHost::OnCreateDedicatedWorker(const GURL& url,
DCHECK(instances_.size() == 1); // Only called when one process per worker.
*route_id = WorkerService::GetInstance()->next_worker_route_id();
WorkerService::GetInstance()->CreateDedicatedWorker(
- url, instances_.front().renderer_process_id,
- instances_.front().render_view_route_id, this, GetProcessId(), *route_id);
+ url, instances_.front().renderer_id,
+ instances_.front().render_view_route_id, this, id(), *route_id);
}
void WorkerProcessHost::OnCancelCreateDedicatedWorker(int route_id) {
- WorkerService::GetInstance()->CancelCreateDedicatedWorker(
- GetProcessId(), route_id);
+ WorkerService::GetInstance()->CancelCreateDedicatedWorker(id(), route_id);
}
void WorkerProcessHost::OnForwardToWorker(const IPC::Message& message) {
- WorkerService::GetInstance()->ForwardMessage(message, GetProcessId());
+ WorkerService::GetInstance()->ForwardMessage(message, id());
}
diff --git a/chrome/browser/worker_host/worker_process_host.h b/chrome/browser/worker_host/worker_process_host.h
index 648d731..65f4999 100644
--- a/chrome/browser/worker_host/worker_process_host.h
+++ b/chrome/browser/worker_host/worker_process_host.h
@@ -19,11 +19,11 @@ class WorkerProcessHost : public ChildProcessHost {
// between the renderer and worker processes.
struct WorkerInstance {
GURL url;
- int renderer_process_id;
+ int renderer_id;
int render_view_route_id;
int worker_route_id;
IPC::Message::Sender* sender;
- int sender_pid;
+ int sender_id;
int sender_route_id;
};
diff --git a/chrome/browser/worker_host/worker_service.cc b/chrome/browser/worker_host/worker_service.cc
index df8ba51..a8ce3f0 100644
--- a/chrome/browser/worker_host/worker_service.cc
+++ b/chrome/browser/worker_host/worker_service.cc
@@ -48,10 +48,10 @@ WorkerService::~WorkerService() {
}
bool WorkerService::CreateDedicatedWorker(const GURL &url,
- int renderer_process_id,
+ int renderer_id,
int render_view_route_id,
IPC::Message::Sender* sender,
- int sender_pid,
+ int sender_id,
int sender_route_id) {
// Generate a unique route id for the browser-worker communication that's
// unique among all worker processes. That way when the worker process sends
@@ -59,11 +59,11 @@ bool WorkerService::CreateDedicatedWorker(const GURL &url,
// it to.
WorkerProcessHost::WorkerInstance instance;
instance.url = url;
- instance.renderer_process_id = renderer_process_id;
+ instance.renderer_id = renderer_id;
instance.render_view_route_id = render_view_route_id;
instance.worker_route_id = next_worker_route_id();
instance.sender = sender;
- instance.sender_pid = sender_pid;
+ instance.sender_id = sender_id;
instance.sender_route_id = sender_route_id;
WorkerProcessHost* worker = NULL;
@@ -92,11 +92,12 @@ bool WorkerService::CreateDedicatedWorker(const GURL &url,
return true;
}
-void WorkerService::CancelCreateDedicatedWorker(int sender_pid,
+void WorkerService::CancelCreateDedicatedWorker(int sender_id,
int sender_route_id) {
for (WorkerProcessHost::Instances::iterator i = queued_workers_.begin();
i != queued_workers_.end(); ++i) {
- if (i->sender_pid == sender_pid && i->sender_route_id == sender_route_id) {
+ if (i->sender_id == sender_id &&
+ i->sender_route_id == sender_route_id) {
queued_workers_.erase(i);
return;
}
@@ -111,12 +112,12 @@ void WorkerService::CancelCreateDedicatedWorker(int sender_pid,
for (WorkerProcessHost::Instances::const_iterator instance =
worker->instances().begin();
instance != worker->instances().end(); ++instance) {
- if (instance->sender_pid == sender_pid &&
+ if (instance->sender_id == sender_id &&
instance->sender_route_id == sender_route_id) {
// Fake a worker destroyed message so that WorkerProcessHost cleans up
// properly.
WorkerHostMsg_WorkerContextDestroyed msg(sender_route_id);
- ForwardMessage(msg, sender_pid);
+ ForwardMessage(msg, sender_id);
return;
}
}
@@ -198,7 +199,7 @@ bool WorkerService::CanCreateWorkerProcess(
total_workers++;
if (total_workers >= kMaxWorkersWhenSeparate)
return false;
- if (cur_instance->renderer_process_id == instance.renderer_process_id &&
+ if (cur_instance->renderer_id == instance.renderer_id &&
cur_instance->render_view_route_id == instance.render_view_route_id) {
workers_per_tab++;
if (workers_per_tab >= kMaxWorkersPerTabWhenSeparate)
diff --git a/chrome/browser/worker_host/worker_service.h b/chrome/browser/worker_host/worker_service.h
index b7cb6e0..0887b32 100644
--- a/chrome/browser/worker_host/worker_service.h
+++ b/chrome/browser/worker_host/worker_service.h
@@ -29,18 +29,18 @@ class WorkerService : public NotificationObserver {
// Creates a dedicated worker. Returns true on success.
bool CreateDedicatedWorker(const GURL &url,
- int renderer_process_id,
+ int renderer_pid,
int render_view_route_id,
IPC::Message::Sender* sender,
- int sender_pid,
+ int sender_id,
int sender_route_id);
// Cancel creation of a dedicated worker that hasn't started yet.
- void CancelCreateDedicatedWorker(int sender_pid, int sender_route_id);
+ void CancelCreateDedicatedWorker(int sender_id, int sender_route_id);
// Called by the worker creator when a message arrives that should be
// forwarded to the worker process.
- void ForwardMessage(const IPC::Message& message, int sender_pid);
+ void ForwardMessage(const IPC::Message& message, int sender_id);
MessageLoop* ui_loop() { return ui_loop_; }
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index d4fc821..b970881 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -1510,6 +1510,8 @@
'browser/net/url_request_slow_download_job.h',
'browser/net/url_request_slow_http_job.cc',
'browser/net/url_request_slow_http_job.h',
+ 'browser/net/url_request_tracking.cc',
+ 'browser/net/url_request_tracking.h',
'browser/omnibox_search_hint.cc',
'browser/omnibox_search_hint.h',
'browser/options_page_base.cc',
diff --git a/chrome/common/child_process_host.cc b/chrome/common/child_process_host.cc
index cf67d15..5ac925a 100644
--- a/chrome/common/child_process_host.cc
+++ b/chrome/common/child_process_host.cc
@@ -65,7 +65,7 @@ class ChildNotificationTask : public Task {
ChildProcessHost::ChildProcessHost(
ProcessType type, ResourceDispatcherHost* resource_dispatcher_host)
- : Receiver(type),
+ : Receiver(type, -1),
ALLOW_THIS_IN_INITIALIZER_LIST(listener_(this)),
resource_dispatcher_host_(resource_dispatcher_host),
opening_channel_(false) {
@@ -76,7 +76,7 @@ ChildProcessHost::ChildProcessHost(
ChildProcessHost::~ChildProcessHost() {
Singleton<ChildProcessList>::get()->remove(this);
- resource_dispatcher_host_->CancelRequestsForProcess(GetProcessId());
+ resource_dispatcher_host_->CancelRequestsForProcess(id());
if (handle())
ProcessWatcher::EnsureProcessTerminated(handle());
diff --git a/chrome/common/child_process_host.h b/chrome/common/child_process_host.h
index cb833dc..778b5a2 100644
--- a/chrome/common/child_process_host.h
+++ b/chrome/common/child_process_host.h
@@ -18,6 +18,9 @@ class NotificationType;
// Plugins/workers and other child processes that live on the IO thread should
// derive from this class.
+//
+// [Browser]RenderProcessHost is the main exception that doesn't derive from
+// this class. That project lives on the UI thread.
class ChildProcessHost : public ResourceDispatcherHost::Receiver,
public IPC::Channel::Listener {
public:
diff --git a/chrome/common/child_process_info.cc b/chrome/common/child_process_info.cc
index 819b7fc..770c9866 100644
--- a/chrome/common/child_process_info.cc
+++ b/chrome/common/child_process_info.cc
@@ -7,12 +7,34 @@
#include <limits>
#include "app/l10n_util.h"
+#include "base/atomicops.h"
#include "base/logging.h"
#include "base/process_util.h"
#include "base/rand_util.h"
#include "base/string_util.h"
#include "grit/generated_resources.h"
+ChildProcessInfo::ChildProcessInfo(const ChildProcessInfo& original)
+ : type_(original.type_),
+ name_(original.name_),
+ id_(original.id_),
+ process_(original.process_) {
+}
+
+ChildProcessInfo::~ChildProcessInfo() {
+}
+
+ChildProcessInfo& ChildProcessInfo::operator=(
+ const ChildProcessInfo& original) {
+ if (&original != this) {
+ type_ = original.type_;
+ name_ = original.name_;
+ id_ = original.id_;
+ process_ = original.process_;
+ }
+ return *this;
+}
+
std::wstring ChildProcessInfo::GetTypeNameInEnglish(
ChildProcessInfo::ProcessType type) {
switch (type) {
@@ -56,17 +78,11 @@ std::wstring ChildProcessInfo::GetLocalizedTitle() const {
return l10n_util::GetStringF(message_id, title);
}
-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() {
+ChildProcessInfo::ChildProcessInfo(ProcessType type, int id) : type_(type) {
+ if (id == -1)
+ id_ = GenerateChildProcessUniqueId();
+ else
+ id_ = id;
}
std::string ChildProcessInfo::GenerateRandomChannelID(void* instance) {
@@ -80,3 +96,10 @@ std::string ChildProcessInfo::GenerateRandomChannelID(void* instance) {
base::GetCurrentProcId(), instance,
base::RandInt(0, std::numeric_limits<int>::max()));
}
+
+// static
+int ChildProcessInfo::GenerateChildProcessUniqueId() {
+ // This function must be threadsafe.
+ static base::subtle::Atomic32 last_unique_child_id = 0;
+ return base::subtle::NoBarrier_AtomicIncrement(&last_unique_child_id, 1);
+}
diff --git a/chrome/common/child_process_info.h b/chrome/common/child_process_info.h
index d79435f..3d80a1d 100644
--- a/chrome/common/child_process_info.h
+++ b/chrome/common/child_process_info.h
@@ -21,6 +21,11 @@ class ChildProcessInfo {
UNKNOWN_PROCESS,
};
+ ChildProcessInfo(const ChildProcessInfo& original);
+ virtual ~ChildProcessInfo();
+
+ ChildProcessInfo& operator=(const ChildProcessInfo& original);
+
// Returns the type of the process.
ProcessType type() const { return type_; }
@@ -31,13 +36,11 @@ class ChildProcessInfo {
// Getter to the process handle.
base::ProcessHandle handle() const { return process_.handle(); }
- virtual int GetProcessId() const {
- if (pid_ != -1)
- return pid_;
+ // The unique identifier for this child process. This identifier is NOT a
+ // process ID, and will be unique for all types of child process for
+ // one run of the browser.
+ int id() const { return id_; }
- pid_ = process_.pid();
- return pid_;
- }
void SetProcessBackgrounded() const { process_.SetProcessBackgrounded(true); }
void ReduceWorkingSet() const { process_.ReduceWorkingSet(); }
@@ -49,25 +52,6 @@ class ChildProcessInfo {
// 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 {
@@ -84,21 +68,30 @@ class ChildProcessInfo {
// The "instance" pointer value is baked into the channel id.
static std::string GenerateRandomChannelID(void* instance);
+ // Returns a unique ID to identify a child process. On construction, this
+ // function will be used to generate the id_, but it is also used to generate
+ // IDs for the RenderProcessHost, which doesn't inherit from us, and whose IDs
+ // must be unique for all child processes.
+ //
+ // This function is threadsafe since RenderProcessHost is on the UI thread,
+ // but normally this will be used on the IO thread.
+ static int GenerateChildProcessUniqueId();
+
protected:
+ // Derived objects need to use this constructor so we know what type we are.
+ // If the caller has already generated a unique ID for this child process,
+ // it should pass it as the second argument. Otherwise, -1 should be passed
+ // and a unique ID will be automatically generated.
+ ChildProcessInfo(ProcessType type, int id);
+
void set_type(ProcessType type) { type_ = type; }
void set_name(const std::wstring& name) { name_ = name; }
- void set_handle(base::ProcessHandle handle) {
- process_.set_handle(handle);
- pid_ = -1;
- }
-
- // Derived objects need to use this constructor so we know what type we are.
- ChildProcessInfo(ProcessType type);
+ void set_handle(base::ProcessHandle handle) { process_.set_handle(handle); }
private:
ProcessType type_;
std::wstring name_;
- mutable int pid_; // Cache of the process id.
+ int id_;
// The handle to the process.
mutable base::Process process_;
diff --git a/chrome/common/plugin_messages_internal.h b/chrome/common/plugin_messages_internal.h
index 3bc169b..7b7ce74 100644
--- a/chrome/common/plugin_messages_internal.h
+++ b/chrome/common/plugin_messages_internal.h
@@ -17,12 +17,13 @@
// These are messages sent from the browser to the plugin process.
IPC_BEGIN_MESSAGES(PluginProcess)
// Tells the plugin process to create a new channel for communication with a
- // renderer. The channel name is returned in a
- // PluginProcessHostMsg_ChannelCreated message. The renderer's process_id is
- // passed so that the plugin process reuses an existing channel to that
- // process if it exists.
+ // given renderer. The channel name is returned in a
+ // PluginProcessHostMsg_ChannelCreated message. The renderer ID is passed so
+ // that the plugin process reuses an existing channel to that process if it
+ // exists. This ID is a unique opaque identifier generated by the browser
+ // process.
IPC_MESSAGE_CONTROL2(PluginProcessMsg_CreateChannel,
- int /* process_id */,
+ int /* renderer_id */,
bool /* off_the_record */)
// Allows a chrome plugin loaded in the browser process to send arbitrary
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index 2eb355d..b1b21ec 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -315,8 +315,10 @@ struct ViewHostMsg_Resource_Request {
// URLRequest load flags (0 by default).
int load_flags;
- // Process ID of process that originated this request.
- int origin_pid;
+ // Unique ID of process that originated this request. For normal renderer
+ // requests, this will be the ID of the renderer. For plugin requests routed
+ // through the renderer, this will be the plugin's ID.
+ int origin_child_id;
// What this resource load is for (main frame, sub-frame, sub-resource,
// object).
@@ -1277,7 +1279,7 @@ struct ParamTraits<ViewHostMsg_Resource_Request> {
WriteParam(m, p.main_frame_origin);
WriteParam(m, p.headers);
WriteParam(m, p.load_flags);
- WriteParam(m, p.origin_pid);
+ WriteParam(m, p.origin_child_id);
WriteParam(m, p.resource_type);
WriteParam(m, p.request_context);
WriteParam(m, p.appcache_host_id);
@@ -1293,7 +1295,7 @@ struct ParamTraits<ViewHostMsg_Resource_Request> {
ReadParam(m, iter, &r->main_frame_origin) &&
ReadParam(m, iter, &r->headers) &&
ReadParam(m, iter, &r->load_flags) &&
- ReadParam(m, iter, &r->origin_pid) &&
+ ReadParam(m, iter, &r->origin_child_id) &&
ReadParam(m, iter, &r->resource_type) &&
ReadParam(m, iter, &r->request_context) &&
ReadParam(m, iter, &r->appcache_host_id) &&
@@ -1313,7 +1315,7 @@ struct ParamTraits<ViewHostMsg_Resource_Request> {
l->append(L", ");
LogParam(p.load_flags, l);
l->append(L", ");
- LogParam(p.origin_pid, l);
+ LogParam(p.origin_child_id, l);
l->append(L", ");
LogParam(p.resource_type, l);
l->append(L", ");
diff --git a/chrome/common/resource_dispatcher.cc b/chrome/common/resource_dispatcher.cc
index e075fc3..47efd6b 100644
--- a/chrome/common/resource_dispatcher.cc
+++ b/chrome/common/resource_dispatcher.cc
@@ -106,7 +106,7 @@ IPCResourceLoaderBridge::IPCResourceLoaderBridge(
const std::string& main_frame_origin,
const std::string& headers,
int load_flags,
- int origin_pid,
+ int origin_child_id,
ResourceType::Type resource_type,
uint32 request_context,
int appcache_host_id,
@@ -124,7 +124,7 @@ IPCResourceLoaderBridge::IPCResourceLoaderBridge(
request_.main_frame_origin = main_frame_origin;
request_.headers = headers;
request_.load_flags = load_flags;
- request_.origin_pid = origin_pid;
+ request_.origin_child_id = origin_child_id;
request_.resource_type = resource_type;
request_.request_context = request_context;
request_.appcache_host_id = appcache_host_id;
diff --git a/chrome/plugin/plugin_channel.cc b/chrome/plugin/plugin_channel.cc
index 04d9afc..c813e4c 100644
--- a/chrome/plugin/plugin_channel.cc
+++ b/chrome/plugin/plugin_channel.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// 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.
@@ -27,11 +27,11 @@ class PluginReleaseTask : public Task {
// How long we wait before releasing the plugin process.
static const int kPluginReleaseTimeMS = 10000;
-PluginChannel* PluginChannel::GetPluginChannel(
- int process_id, MessageLoop* ipc_message_loop) {
- // map renderer's process id to a (single) channel to that process
+PluginChannel* PluginChannel::GetPluginChannel(int renderer_id,
+ MessageLoop* ipc_message_loop) {
+ // Map renderer ID to a (single) channel to that process.
std::string channel_name = StringPrintf(
- "%d.r%d", base::GetCurrentProcId(), process_id);
+ "%d.r%d", base::GetCurrentProcId(), renderer_id);
return static_cast<PluginChannel*>(PluginChannelBase::GetChannel(
channel_name,
diff --git a/chrome/plugin/plugin_channel.h b/chrome/plugin/plugin_channel.h
index 02b619e..58e711f 100644
--- a/chrome/plugin/plugin_channel.h
+++ b/chrome/plugin/plugin_channel.h
@@ -15,10 +15,13 @@
// process. On the renderer side there's a corresponding PluginChannelHost.
class PluginChannel : public PluginChannelBase {
public:
- // Get a new PluginChannel object for the current process.
+ // Get a new PluginChannel object for the current process to talk to the
+ // given rendeer process. The renderer ID is an opaque unique ID generated by
+ // the browser.
+ //
// POSIX only: If |channel_fd| > 0, use that file descriptor for the
// channel socket.
- static PluginChannel* GetPluginChannel(int process_id,
+ static PluginChannel* GetPluginChannel(int renderer_id,
MessageLoop* ipc_message_loop);
~PluginChannel();
diff --git a/chrome/plugin/plugin_thread.cc b/chrome/plugin/plugin_thread.cc
index 307cbaa..c2a21bd 100644
--- a/chrome/plugin/plugin_thread.cc
+++ b/chrome/plugin/plugin_thread.cc
@@ -98,11 +98,10 @@ void PluginThread::OnControlMessageReceived(const IPC::Message& msg) {
IPC_END_MESSAGE_MAP()
}
-void PluginThread::OnCreateChannel(
- int process_id,
- bool off_the_record) {
+void PluginThread::OnCreateChannel(int renderer_id,
+ bool off_the_record) {
scoped_refptr<PluginChannel> channel = PluginChannel::GetPluginChannel(
- process_id, ChildProcess::current()->io_message_loop());
+ renderer_id, ChildProcess::current()->io_message_loop());
IPC::ChannelHandle channel_handle;
if (channel.get()) {
channel_handle.name = channel->channel_name();
diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc
index c72c654..2068a50 100644
--- a/chrome/renderer/webplugin_delegate_proxy.cc
+++ b/chrome/renderer/webplugin_delegate_proxy.cc
@@ -403,9 +403,8 @@ void WebPluginDelegateProxy::OnChannelError() {
render_view_->PluginCrashed(GetProcessId(), plugin_path_);
}
-void WebPluginDelegateProxy::UpdateGeometry(
- const gfx::Rect& window_rect,
- const gfx::Rect& clip_rect) {
+void WebPluginDelegateProxy::UpdateGeometry(const gfx::Rect& window_rect,
+ const gfx::Rect& clip_rect) {
plugin_rect_ = window_rect;
bool bitmaps_changed = false;
diff --git a/net/url_request/url_request.cc b/net/url_request/url_request.cc
index d94c8dc..bf8fd5a 100644
--- a/net/url_request/url_request.cc
+++ b/net/url_request/url_request.cc
@@ -5,7 +5,6 @@
#include "net/url_request/url_request.h"
#include "base/message_loop.h"
-#include "base/process_util.h"
#include "base/singleton.h"
#include "base/stats_counters.h"
#include "base/string_util.h"
@@ -53,7 +52,6 @@ URLRequest::URLRequest(const GURL& url, Delegate* delegate)
priority_(0) {
URLREQUEST_COUNT_CTOR();
SIMPLE_STATS_COUNTER("URLRequestCount");
- origin_pid_ = base::GetCurrentProcId();
// Sanity check out environment.
DCHECK(MessageLoop::current()) <<
diff --git a/net/url_request/url_request.h b/net/url_request/url_request.h
index c395125..14c6287 100644
--- a/net/url_request/url_request.h
+++ b/net/url_request/url_request.h
@@ -389,12 +389,6 @@ class URLRequest {
int load_flags() const { return load_flags_; }
void set_load_flags(int flags) { load_flags_ = flags; }
- // Accessors to the pid of the process this request originated from.
- int origin_pid() const { return origin_pid_; }
- void set_origin_pid(int proc_id) {
- origin_pid_ = proc_id;
- }
-
// Returns true if the request is "pending" (i.e., if Start() has been called,
// and the response has not yet been called).
bool is_pending() const { return is_pending_; }
@@ -569,10 +563,6 @@ class URLRequest {
int load_flags_; // Flags indicating the request type for the load;
// expected values are LOAD_* enums above.
- // The pid of the process that initiated this request. Initialized to the id
- // of the current process.
- int origin_pid_;
-
Delegate* delegate_;
// Current error status of the job. When no error has been encountered, this