diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-31 17:27:45 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-31 17:27:45 +0000 |
commit | 76543b9c43515c8c68413b25d682b7c15a151905 (patch) | |
tree | 3fa26b07a2de8102561d5ded5828797fa9a375ab /chrome/browser/tab_contents | |
parent | f341f8f58ceeae4efe38daf3c26ad4581f98fd2d (diff) | |
download | chromium_src-76543b9c43515c8c68413b25d682b7c15a151905.zip chromium_src-76543b9c43515c8c68413b25d682b7c15a151905.tar.gz chromium_src-76543b9c43515c8c68413b25d682b7c15a151905.tar.bz2 |
Replace the RenderProcessHost.PID function that returns the OS-generated
process ID with an internally-generated id() function. This allows us the
guarantee that the IDs are unique over the entire run of the application.
This also cleans up some code associated with managing the PID.
The main potentially interesting change is now the PID is set uniquely for
every creation of RenderProcessHost. It used to be set cleared if the process
went away, and re-set if the process was re-created. The ID generation is in
ChildProcesInfo so it is also unique between workers and plugins. I had to
change some significant things in resource_dispatcher_host_unittest to take
into account this new generation of IDs.
BUG=17828
TEST=none
Review URL: http://codereview.chromium.org/160203
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24899 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
4 files changed, 15 insertions, 18 deletions
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 |