summaryrefslogtreecommitdiffstats
path: root/chrome/browser/renderer_host
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/renderer_host')
-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
16 files changed, 406 insertions, 401 deletions
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")));