diff options
Diffstat (limited to 'chrome')
| -rw-r--r-- | chrome/browser/prerender/prerender_browsertest.cc | 53 | ||||
| -rw-r--r-- | chrome/browser/prerender/prerender_contents.cc | 23 | ||||
| -rw-r--r-- | chrome/browser/prerender/prerender_manager.cc | 28 | ||||
| -rw-r--r-- | chrome/browser/prerender/prerender_manager.h | 4 | ||||
| -rw-r--r-- | chrome/browser/task_manager/task_manager.cc | 1 | ||||
| -rw-r--r-- | chrome/browser/task_manager/task_manager_resource_providers.cc | 255 | ||||
| -rw-r--r-- | chrome/browser/task_manager/task_manager_resource_providers.h | 57 |
7 files changed, 95 insertions, 326 deletions
diff --git a/chrome/browser/prerender/prerender_browsertest.cc b/chrome/browser/prerender/prerender_browsertest.cc index e89febca..bbea33c 100644 --- a/chrome/browser/prerender/prerender_browsertest.cc +++ b/chrome/browser/prerender/prerender_browsertest.cc @@ -415,10 +415,9 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderHttpAuthentication) { // than the final destination page. IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderClientRedirectNavigateToFirst) { - PrerenderTestURL( - CreateClientRedirect("files/prerender/prerender_page.html"), - FINAL_STATUS_USED, - 2); + PrerenderTestURL(CreateClientRedirect("files/prerender/prerender_page.html"), + FINAL_STATUS_USED, + 2); NavigateToDestURL(); } @@ -427,10 +426,9 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, // page which does the redirection. IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderClientRedirectNavigateToSecond) { - PrerenderTestURL( - CreateClientRedirect("files/prerender/prerender_page.html"), - FINAL_STATUS_USED, - 2); + PrerenderTestURL(CreateClientRedirect("files/prerender/prerender_page.html"), + FINAL_STATUS_USED, + 2); NavigateToURL("files/prerender/prerender_page.html"); } @@ -503,10 +501,9 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, // than the final destination page. IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderServerRedirectNavigateToFirst) { - PrerenderTestURL( - CreateServerRedirect("files/prerender/prerender_page.html"), - FINAL_STATUS_USED, - 1); + PrerenderTestURL(CreateServerRedirect("files/prerender/prerender_page.html"), + FINAL_STATUS_USED, + 1); NavigateToDestURL(); } @@ -515,11 +512,9 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, // page which does the redirection. IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderServerRedirectNavigateToSecond) { - std::string redirect_path; - PrerenderTestURL( - CreateServerRedirect("files/prerender/prerender_page.html"), - FINAL_STATUS_USED, - 1); + PrerenderTestURL(CreateServerRedirect("files/prerender/prerender_page.html"), + FINAL_STATUS_USED, + 1); NavigateToURL("files/prerender/prerender_page.html"); } @@ -705,6 +700,12 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, } IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, TaskManager) { + // Early out if we're not using TabContents for Prerendering. + if (!prerender::PrerenderContents::UseTabContents()) { + SUCCEED(); + return; + } + // Show the task manager. This populates the model. browser()->window()->ShowTaskManager(); @@ -715,19 +716,27 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, TaskManager) { // The prerender makes three. EXPECT_EQ(3, model()->ResourceCount()); - // It shouldn't have a TabContents associated with it. - ASSERT_TRUE(model()->GetResourceTabContents(1) == NULL); + // It should have a TabContents associated with it. + ASSERT_TRUE(model()->GetResourceTabContents(1) != NULL); // The prefix should be "Prerender:" string16 prefix = l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_PRERENDER_PREFIX, string16()); - ASSERT_TRUE(StartsWith(model()->GetResourceTitle(1), prefix, true)); + ASSERT_TRUE(StartsWith(model()->GetResourceTitle(2), prefix, true)); NavigateToDestURL(); - // Prerender task should be killed and removed from the Task Manager. - EXPECT_EQ(2, model()->ResourceCount()); + // Prerender task should become a normal tab. + EXPECT_EQ(3, model()->ResourceCount()); + + // It should have a TabContents associated with it. + ASSERT_TRUE(model()->GetResourceTabContents(2) != NULL); + + // The prefix should now be "Tab:" + prefix = l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_TAB_PREFIX, + string16()); + ASSERT_TRUE(StartsWith(model()->GetResourceTitle(2), prefix, true)); } // Checks that prerenderers will terminate when an audio tag is encountered. diff --git a/chrome/browser/prerender/prerender_contents.cc b/chrome/browser/prerender/prerender_contents.cc index d68294e..724f824 100644 --- a/chrome/browser/prerender/prerender_contents.cc +++ b/chrome/browser/prerender/prerender_contents.cc @@ -126,14 +126,6 @@ void PrerenderContents::StartPrerenderingOld( render_view_host_observer_.reset( new PrerenderRenderViewHostObserver(this, render_view_host_mutable())); - int process_id = render_view_host_->process()->id(); - int view_id = render_view_host_->routing_id(); - std::pair<int, int> process_view_pair = std::make_pair(process_id, view_id); - NotificationService::current()->Notify( - NotificationType::PRERENDER_CONTENTS_STARTED, - Source<std::pair<int, int> >(&process_view_pair), - NotificationService::NoDetails()); - // Create the RenderView, so it can receive messages. render_view_host_->CreateRenderView(string16()); @@ -147,6 +139,9 @@ void PrerenderContents::StartPrerenderingOld( // RenderViewHost. This must be done before the Navigate message to catch all // resource requests, but as it is on the same thread as the Navigate message // (IO) there is no race condition. + int process_id = render_view_host_->process()->id(); + int view_id = render_view_host_->routing_id(); + BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, NewRunnableFunction(&AddChildRoutePair, @@ -247,12 +242,6 @@ void PrerenderContents::StartPrerendering( CHECK(GetChildId(&process_id)); CHECK(GetRouteId(&view_id)); - std::pair<int, int> process_view_pair = std::make_pair(process_id, view_id); - NotificationService::current()->Notify( - NotificationType::PRERENDER_CONTENTS_STARTED, - Source<std::pair<int, int> >(&process_view_pair), - NotificationService::NoDetails()); - // Register this with the ResourceDispatcherHost as a prerender // RenderViewHost. This must be done before the Navigate message to catch all // resource requests, but as it is on the same thread as the Navigate message @@ -352,11 +341,6 @@ PrerenderContents::~PrerenderContents() { int process_id = prerender_render_view_host->process()->id(); int view_id = prerender_render_view_host->routing_id(); - std::pair<int, int> process_view_pair = std::make_pair(process_id, view_id); - NotificationService::current()->Notify( - NotificationType::PRERENDER_CONTENTS_DESTROYED, - Source<std::pair<int, int> >(&process_view_pair), - NotificationService::NoDetails()); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, @@ -555,6 +539,7 @@ WebPreferences PrerenderContents::GetWebkitPrefs() { void PrerenderContents::CreateNewWindow( int route_id, const ViewHostMsg_CreateWindow_Params& params) { + // TODO(dominich): Remove when we switch to TabContents. // Since we don't want to permit child windows that would have a // window.opener property, terminate prerendering. Destroy(FINAL_STATUS_CREATE_NEW_WINDOW); diff --git a/chrome/browser/prerender/prerender_manager.cc b/chrome/browser/prerender/prerender_manager.cc index 9b294e7..e3ace0d 100644 --- a/chrome/browser/prerender/prerender_manager.cc +++ b/chrome/browser/prerender/prerender_manager.cc @@ -468,11 +468,6 @@ bool PrerenderManager::MaybeUsePreloadedPageOld(TabContents* tab_contents, pending_prerender_list_.erase(pending_it); } - NotificationService::current()->Notify( - NotificationType::PRERENDER_CONTENTS_USED, - Source<std::pair<int, int> >(&child_route_pair), - NotificationService::NoDetails()); - RenderViewHostDelegate* render_view_host_delegate = static_cast<RenderViewHostDelegate*>(tab_contents); ViewHostMsg_FrameNavigate_Params* params = @@ -576,13 +571,6 @@ bool PrerenderManager::MaybeUsePreloadedPage(TabContents* tab_contents, pending_prerender_list_.erase(pending_it); } - NotificationService::current()->Notify( - NotificationType::PRERENDER_CONTENTS_USED, - Source<std::pair<int, int> >(&child_route_pair), - NotificationService::NoDetails()); - - old_tab_contents_list_.push_back(old_tab_contents); - StartSchedulingPeriodicCleanups(); return true; } @@ -861,6 +849,22 @@ void PrerenderManager::PeriodicCleanup() { } } +bool PrerenderManager::IsTabContentsPrerendering( + TabContents* tab_contents) const { + DCHECK(CalledOnValidThread()); + for (std::list<PrerenderContentsData>::const_iterator it = + prerender_list_.begin(); + it != prerender_list_.end(); + ++it) { + TabContentsWrapper* prerender_tab_contents_wrapper = + it->contents_->prerender_contents(); + if (prerender_tab_contents_wrapper && + prerender_tab_contents_wrapper->tab_contents() == tab_contents) + return true; + } + return false; +} + void PrerenderManager::MarkTabContentsAsPrerendered(TabContents* tab_contents) { DCHECK(CalledOnValidThread()); prerendered_tab_contents_set_.insert(tab_contents); diff --git a/chrome/browser/prerender/prerender_manager.h b/chrome/browser/prerender/prerender_manager.h index 8db8676..7b4f40e 100644 --- a/chrome/browser/prerender/prerender_manager.h +++ b/chrome/browser/prerender/prerender_manager.h @@ -160,6 +160,10 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>, // Records that a prefetch tag has been observed. void RecordPrefetchTagObserved(); + // Query the list of current prerender pages to see if the given tab contents + // is prerendering a page. + bool IsTabContentsPrerendering(TabContents* tab_contents) const; + // Maintaining and querying the set of TabContents belonging to this // PrerenderManager that are currently showing prerendered pages. void MarkTabContentsAsPrerendered(TabContents* tab_contents); diff --git a/chrome/browser/task_manager/task_manager.cc b/chrome/browser/task_manager/task_manager.cc index b288f11..aa0a04f 100644 --- a/chrome/browser/task_manager/task_manager.cc +++ b/chrome/browser/task_manager/task_manager.cc @@ -84,7 +84,6 @@ TaskManagerModel::TaskManagerModel(TaskManager* task_manager) AddResourceProvider( new TaskManagerBackgroundContentsResourceProvider(task_manager)); AddResourceProvider(new TaskManagerTabContentsResourceProvider(task_manager)); - AddResourceProvider(new TaskManagerPrerenderResourceProvider(task_manager)); AddResourceProvider( new TaskManagerChildProcessResourceProvider(task_manager)); AddResourceProvider( diff --git a/chrome/browser/task_manager/task_manager_resource_providers.cc b/chrome/browser/task_manager/task_manager_resource_providers.cc index 9e7daf3..99cb938 100644 --- a/chrome/browser/task_manager/task_manager_resource_providers.cc +++ b/chrome/browser/task_manager/task_manager_resource_providers.cc @@ -24,7 +24,6 @@ #include "chrome/browser/notifications/balloon_collection.h" #include "chrome/browser/notifications/balloon_host.h" #include "chrome/browser/notifications/notification_ui_manager.h" -#include "chrome/browser/prerender/prerender_contents.h" #include "chrome/browser/prerender/prerender_manager.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/tab_contents/background_contents.h" @@ -61,16 +60,22 @@ namespace { // Returns the appropriate message prefix ID for tabs and extensions, // reflecting whether they are apps or in incognito mode. int GetMessagePrefixID(bool is_app, bool is_extension, - bool is_incognito) { - return is_app ? - (is_incognito ? - IDS_TASK_MANAGER_APP_INCOGNITO_PREFIX : - IDS_TASK_MANAGER_APP_PREFIX) : - (is_extension ? - (is_incognito ? - IDS_TASK_MANAGER_EXTENSION_INCOGNITO_PREFIX : - IDS_TASK_MANAGER_EXTENSION_PREFIX) : - IDS_TASK_MANAGER_TAB_PREFIX); + bool is_incognito, bool is_prerender) { + if (is_app) { + if (is_incognito) + return IDS_TASK_MANAGER_APP_INCOGNITO_PREFIX; + else + return IDS_TASK_MANAGER_APP_PREFIX; + } else if (is_extension) { + if (is_incognito) + return IDS_TASK_MANAGER_EXTENSION_INCOGNITO_PREFIX; + else + return IDS_TASK_MANAGER_EXTENSION_PREFIX; + } else if (is_prerender) { + return IDS_TASK_MANAGER_PRERENDER_PREFIX; + } else { + return IDS_TASK_MANAGER_TAB_PREFIX; + } } } // namespace @@ -160,17 +165,32 @@ bool TaskManagerRendererResource::SupportNetworkUsage() const { // TaskManagerTabContentsResource class //////////////////////////////////////////////////////////////////////////////// +// static +SkBitmap* TaskManagerTabContentsResource::prerender_icon_ = NULL; + TaskManagerTabContentsResource::TaskManagerTabContentsResource( TabContentsWrapper* tab_contents) : TaskManagerRendererResource( tab_contents->tab_contents()->GetRenderProcessHost()->GetHandle(), tab_contents->render_view_host()), tab_contents_(tab_contents) { + if (!prerender_icon_) { + ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + prerender_icon_ = rb.GetBitmapNamed(IDR_PRERENDER); + } } TaskManagerTabContentsResource::~TaskManagerTabContentsResource() { } +bool TaskManagerTabContentsResource::IsPrerendering() const { + prerender::PrerenderManager* prerender_manager = + tab_contents_->profile()->GetPrerenderManager(); + return prerender_manager && + prerender_manager->IsTabContentsPrerendering( + tab_contents_->tab_contents()); +} + TaskManager::Resource::Type TaskManagerTabContentsResource::GetType() const { return tab_contents_->tab_contents()->HostsExtension() ? EXTENSION : RENDERER; } @@ -197,15 +217,19 @@ string16 TaskManagerTabContentsResource::GetTitle() const { ExtensionService* extensions_service = tab_contents_->profile()->GetExtensionService(); + int message_id = GetMessagePrefixID( extensions_service->IsInstalledApp( tab_contents_->tab_contents()->GetURL()), tab_contents_->tab_contents()->HostsExtension(), - tab_contents_->profile()->IsOffTheRecord()); + tab_contents_->profile()->IsOffTheRecord(), + IsPrerendering()); return l10n_util::GetStringFUTF16(message_id, tab_title); } SkBitmap TaskManagerTabContentsResource::GetIcon() const { + if (IsPrerendering()) + return *prerender_icon_; return tab_contents_->favicon_tab_helper()->GetFavicon(); } @@ -394,211 +418,6 @@ void TaskManagerTabContentsResourceProvider::Observe(NotificationType type, } //////////////////////////////////////////////////////////////////////////////// -// TaskManagerPrerenderResource class -//////////////////////////////////////////////////////////////////////////////// -// static -SkBitmap* TaskManagerPrerenderResource::default_icon_ = NULL; - -TaskManagerPrerenderResource::TaskManagerPrerenderResource( - RenderViewHost* render_view_host) - : TaskManagerRendererResource( - render_view_host->process()->GetHandle(), - render_view_host), - process_route_id_pair_(std::make_pair(render_view_host->process()->id(), - render_view_host->routing_id())) { - if (!default_icon_) { - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - default_icon_ = rb.GetBitmapNamed(IDR_PRERENDER); - } -} - -TaskManagerPrerenderResource::~TaskManagerPrerenderResource() { -} - -TaskManager::Resource::Type TaskManagerPrerenderResource::GetType() const { - return RENDERER; -} - -string16 TaskManagerPrerenderResource::GetTitle() const { - // The URL is used as the title. - // TODO(dominich): Expose document title through RenderHostDelegate. - // http://crbug.com/77776 - RenderViewHost* render_view_host = - RenderViewHost::FromID(process_route_id_pair_.first, - process_route_id_pair_.second); - - // In some instances, for instance when the RenderProcessHost has been - // destroyed, we try to get the title for a RenderViewHost that has - // been removed. Return an empty string in this case. - if (!render_view_host) - return EmptyString16(); - - RenderViewHostDelegate* delegate = render_view_host->delegate(); - - string16 title = UTF8ToUTF16(delegate->GetURL().spec()); - // Force URL to be LTR. - title = base::i18n::GetDisplayStringInLTRDirectionality(title); - - int message_id = IDS_TASK_MANAGER_PRERENDER_PREFIX; - return l10n_util::GetStringFUTF16(message_id, title); -} - -SkBitmap TaskManagerPrerenderResource::GetIcon() const { - // TODO(dominich): use the favicon if available. - // http://crbug.com/77782 - return *default_icon_; -} - -//////////////////////////////////////////////////////////////////////////////// -// TaskManagerPrerenderResourceProvider class -//////////////////////////////////////////////////////////////////////////////// - -TaskManagerPrerenderResourceProvider::TaskManagerPrerenderResourceProvider( - TaskManager* task_manager) - : updating_(false), - task_manager_(task_manager) { -} - -TaskManagerPrerenderResourceProvider::~TaskManagerPrerenderResourceProvider() { - STLDeleteContainerPairSecondPointers(resources_.begin(), resources_.end()); -} - -TaskManager::Resource* TaskManagerPrerenderResourceProvider::GetResource( - int origin_pid, - int render_process_host_id, - int routing_id) { - // If an origin PID was specified then the request originated in a plugin so - // ignore it. - if (origin_pid) - return NULL; - - ResourceMap::iterator res_iter = resources_.find( - std::make_pair(render_process_host_id, routing_id)); - if (res_iter == resources_.end()) - return NULL; - - return res_iter->second; -} - -void TaskManagerPrerenderResourceProvider::StartUpdating() { - DCHECK(!updating_); - updating_ = true; - - // Add all the existing PrerenderContents. - const ResourceDispatcherHost* resource_dispatcher_host = - g_browser_process->resource_dispatcher_host(); - const ResourceDispatcherHost::PrerenderChildRouteIdPairs& - prerender_child_route_id_pairs = - resource_dispatcher_host->prerender_child_route_id_pairs(); - for (ResourceDispatcherHost::PrerenderChildRouteIdPairs::const_iterator it = - prerender_child_route_id_pairs.begin(); - it != prerender_child_route_id_pairs.end(); - ++it) { - Add(*it); - } - - // Then we register for notifications to get new prerender items. - registrar_.Add(this, NotificationType::PRERENDER_CONTENTS_STARTED, - NotificationService::AllSources()); - registrar_.Add(this, NotificationType::PRERENDER_CONTENTS_USED, - NotificationService::AllSources()); - registrar_.Add(this, NotificationType::PRERENDER_CONTENTS_DESTROYED, - NotificationService::AllSources()); -} - -void TaskManagerPrerenderResourceProvider::StopUpdating() { - DCHECK(updating_); - updating_ = false; - - // Then we unregister for notifications to get new prerender items. - registrar_.Remove(this, NotificationType::PRERENDER_CONTENTS_STARTED, - NotificationService::AllSources()); - registrar_.Remove(this, NotificationType::PRERENDER_CONTENTS_USED, - NotificationService::AllSources()); - registrar_.Remove(this, NotificationType::PRERENDER_CONTENTS_DESTROYED, - NotificationService::AllSources()); - - // Delete all the resources. - STLDeleteContainerPairSecondPointers(resources_.begin(), resources_.end()); - - resources_.clear(); -} - -void TaskManagerPrerenderResourceProvider::AddToTaskManager( - const std::pair<int, int>& process_route_id_pair) { - RenderViewHost* render_view_host = - RenderViewHost::FromID(process_route_id_pair.first, - process_route_id_pair.second); - CHECK(render_view_host); - TaskManagerPrerenderResource* resource = - new TaskManagerPrerenderResource(render_view_host); - resources_[process_route_id_pair] = resource; - task_manager_->AddResource(resource); -} - -void TaskManagerPrerenderResourceProvider::Add( - const std::pair<int, int>& process_route_id_pair) { - if (!updating_) - return; - - // Don't add dead prerender contents or prerender contents that haven't yet - // started. - RenderViewHost* render_view_host = - RenderViewHost::FromID(process_route_id_pair.first, - process_route_id_pair.second); - if (!render_view_host) - return; - - AddToTaskManager(process_route_id_pair); -} - -void TaskManagerPrerenderResourceProvider::Remove( - const std::pair<int, int>& process_route_id_pair) { - if (!updating_) - return; - - RenderViewHost* render_view_host = - RenderViewHost::FromID(process_route_id_pair.first, - process_route_id_pair.second); - - if (!render_view_host) { - // This will happen if the PrerenderContents was used. We should have had a - // PRERENDER_CONTENTS_USED message about it and already removed it, but - // either way we can't remove a NULL resource. - return; - } - - ResourceMap::iterator iter = resources_.find(process_route_id_pair); - DCHECK(iter != resources_.end()); - - // Remove the resource from the Task Manager. - TaskManagerPrerenderResource* resource = iter->second; - task_manager_->RemoveResource(resource); - // And from the provider. - resources_.erase(iter); - // Finally, delete the resource. - delete resource; -} - -void TaskManagerPrerenderResourceProvider::Observe( - NotificationType type, - const NotificationSource& source, - const NotificationDetails& details) { - DCHECK(NotificationService::NoDetails() == details); - switch (type.value) { - case NotificationType::PRERENDER_CONTENTS_STARTED: - Add(*Source<std::pair<int, int> >(source).ptr()); - break; - case NotificationType::PRERENDER_CONTENTS_USED: - case NotificationType::PRERENDER_CONTENTS_DESTROYED: - Remove(*Source<std::pair<int, int> >(source).ptr()); - break; - default: - NOTREACHED() << "Unexpected notification."; - return; - } -} -//////////////////////////////////////////////////////////////////////////////// // TaskManagerBackgroundContentsResource class //////////////////////////////////////////////////////////////////////////////// @@ -1148,7 +967,7 @@ TaskManagerExtensionProcessResource::TaskManagerExtensionProcessResource( DCHECK(!extension_name.empty()); int message_id = GetMessagePrefixID(GetExtension()->is_app(), true, - extension_host_->profile()->IsOffTheRecord()); + extension_host_->profile()->IsOffTheRecord(), false); title_ = l10n_util::GetStringFUTF16(message_id, extension_name); } diff --git a/chrome/browser/task_manager/task_manager_resource_providers.h b/chrome/browser/task_manager/task_manager_resource_providers.h index 3c5c68b..3f5fc9c 100644 --- a/chrome/browser/task_manager/task_manager_resource_providers.h +++ b/chrome/browser/task_manager/task_manager_resource_providers.h @@ -25,10 +25,6 @@ class ExtensionHost; class RenderViewHost; class TabContentsWrapper; -namespace prerender { -class PrerenderContents; -} - // These file contains the resource providers used in the task manager. // Base class for various types of render process resources that provides common @@ -94,6 +90,9 @@ class TaskManagerTabContentsResource : public TaskManagerRendererResource { virtual const Extension* GetExtension() const OVERRIDE; private: + bool IsPrerendering() const; + + static SkBitmap* prerender_icon_; TabContentsWrapper* tab_contents_; DISALLOW_COPY_AND_ASSIGN(TaskManagerTabContentsResource); @@ -140,56 +139,6 @@ class TaskManagerTabContentsResourceProvider DISALLOW_COPY_AND_ASSIGN(TaskManagerTabContentsResourceProvider); }; -class TaskManagerPrerenderResource : public TaskManagerRendererResource { - public: - explicit TaskManagerPrerenderResource(RenderViewHost* render_view_host); - virtual ~TaskManagerPrerenderResource(); - - // TaskManager::Resource methods: - virtual Type GetType() const OVERRIDE; - virtual string16 GetTitle() const OVERRIDE; - virtual SkBitmap GetIcon() const OVERRIDE; - - private: - static SkBitmap* default_icon_; - std::pair<int, int> process_route_id_pair_; - - DISALLOW_COPY_AND_ASSIGN(TaskManagerPrerenderResource); -}; - -class TaskManagerPrerenderResourceProvider - : public TaskManager::ResourceProvider, - public NotificationObserver { - public: - explicit TaskManagerPrerenderResourceProvider(TaskManager* task_manager); - - virtual TaskManager::Resource* GetResource(int origin_pid, - int render_process_host_id, - int routing_id); - virtual void StartUpdating(); - virtual void StopUpdating(); - - virtual void Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details); - private: - virtual ~TaskManagerPrerenderResourceProvider(); - - void Add(const std::pair<int, int>& process_route_id_pair); - void Remove(const std::pair<int, int>& process_route_id_pair); - - void AddToTaskManager(const std::pair<int, int>& process_route_id_pair); - - bool updating_; - TaskManager* task_manager_; - typedef std::map<std::pair<int, int>, TaskManagerPrerenderResource*> - ResourceMap; - ResourceMap resources_; - NotificationRegistrar registrar_; - - DISALLOW_COPY_AND_ASSIGN(TaskManagerPrerenderResourceProvider); -}; - class TaskManagerBackgroundContentsResource : public TaskManagerRendererResource { public: |
