diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-10 05:23:33 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-10 05:23:33 +0000 |
commit | 9c85204b1fd755b70de7974e24b7cf4e4b5ffefa (patch) | |
tree | 47ba98558e3ffc2b571ad56923b2e4f7c878a395 /chrome | |
parent | 05d3fc7b93bc8498aac8fb798b4adebad257633d (diff) | |
download | chromium_src-9c85204b1fd755b70de7974e24b7cf4e4b5ffefa.zip chromium_src-9c85204b1fd755b70de7974e24b7cf4e4b5ffefa.tar.gz chromium_src-9c85204b1fd755b70de7974e24b7cf4e4b5ffefa.tar.bz2 |
Revert 55449 - Fix some problems with TaskManagerBrowserTest.PopulateWebCacheFields:
- wait for an actual update to occur; otherwise we're not testing the real thing
- change DCHECKs to EXPECT_EQs; that's what we should use in tests
This change should also fix the crashiness of this test.
TEST=browser_tests
BUG=42301
Review URL: http://codereview.chromium.org/2856091
TBR=phajdan.jr@chromium.org,glen@chromium.org
Review URL: http://codereview.chromium.org/3118003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55530 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/task_manager.cc | 15 | ||||
-rw-r--r-- | chrome/browser/task_manager.h | 2 | ||||
-rw-r--r-- | chrome/browser/task_manager_browsertest.cc | 19 | ||||
-rw-r--r-- | chrome/browser/task_manager_resource_providers.cc | 8 | ||||
-rw-r--r-- | chrome/browser/task_manager_resource_providers.h | 8 | ||||
-rw-r--r-- | chrome/common/notification_type.h | 6 |
6 files changed, 18 insertions, 40 deletions
diff --git a/chrome/browser/task_manager.cc b/chrome/browser/task_manager.cc index 79d2e9d..8677620 100644 --- a/chrome/browser/task_manager.cc +++ b/chrome/browser/task_manager.cc @@ -24,7 +24,6 @@ #include "chrome/browser/renderer_host/resource_dispatcher_host.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/task_manager_resource_providers.h" -#include "chrome/common/notification_service.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" #include "grit/app_resources.h" @@ -180,7 +179,7 @@ std::wstring TaskManagerModel::GetResourceGoatsTeleported(int index) const { std::wstring TaskManagerModel::GetResourceWebCoreImageCacheSize( int index) const { DCHECK(index < ResourceCount()); - if (!resources_[index]->HasCacheStats()) + if (!resources_[index]->ReportsCacheStats()) return l10n_util::GetString(IDS_TASK_MANAGER_NA_CELL_TEXT); const WebKit::WebCache::ResourceTypeStats stats( resources_[index]->GetWebCoreCacheStats()); @@ -190,7 +189,7 @@ std::wstring TaskManagerModel::GetResourceWebCoreImageCacheSize( std::wstring TaskManagerModel::GetResourceWebCoreScriptsCacheSize( int index) const { DCHECK(index < ResourceCount()); - if (!resources_[index]->HasCacheStats()) + if (!resources_[index]->ReportsCacheStats()) return l10n_util::GetString(IDS_TASK_MANAGER_NA_CELL_TEXT); const WebKit::WebCache::ResourceTypeStats stats( resources_[index]->GetWebCoreCacheStats()); @@ -200,7 +199,7 @@ std::wstring TaskManagerModel::GetResourceWebCoreScriptsCacheSize( std::wstring TaskManagerModel::GetResourceWebCoreCSSCacheSize( int index) const { DCHECK(index < ResourceCount()); - if (!resources_[index]->HasCacheStats()) + if (!resources_[index]->ReportsCacheStats()) return l10n_util::GetString(IDS_TASK_MANAGER_NA_CELL_TEXT); const WebKit::WebCache::ResourceTypeStats stats( resources_[index]->GetWebCoreCacheStats()); @@ -339,9 +338,9 @@ int TaskManagerModel::CompareValues(int row1, int row2, int col_id) const { case IDS_TASK_MANAGER_WEBCORE_CSS_CACHE_COLUMN: { WebKit::WebCache::ResourceTypeStats stats1 = { { 0 } }; WebKit::WebCache::ResourceTypeStats stats2 = { { 0 } }; - if (resources_[row1]->HasCacheStats()) + if (resources_[row1]->ReportsCacheStats()) stats1 = resources_[row1]->GetWebCoreCacheStats(); - if (resources_[row2]->HasCacheStats()) + if (resources_[row2]->ReportsCacheStats()) stats2 = resources_[row2]->GetWebCoreCacheStats(); if (IDS_TASK_MANAGER_WEBCORE_IMAGE_CACHE_COLUMN == col_id) return ValueCompare<size_t>(stats1.images.size, stats2.images.size); @@ -688,10 +687,6 @@ void TaskManagerModel::NotifyResourceTypeStats( (*it)->NotifyResourceTypeStats(stats); } } - NotificationService::current()->Notify( - NotificationType::TASK_MANAGER_RESOURCE_TYPE_STATS_UPDATED, - Source<TaskManagerModel>(this), - NotificationService::NoDetails()); } void TaskManagerModel::NotifyV8HeapStats(base::ProcessId renderer_id, diff --git a/chrome/browser/task_manager.h b/chrome/browser/task_manager.h index d078cb4..4a92582 100644 --- a/chrome/browser/task_manager.h +++ b/chrome/browser/task_manager.h @@ -45,7 +45,7 @@ class TaskManager { virtual SkBitmap GetIcon() const = 0; virtual base::ProcessHandle GetProcess() const = 0; - virtual bool HasCacheStats() const { return false; } + virtual bool ReportsCacheStats() const { return false; } virtual WebKit::WebCache::ResourceTypeStats GetWebCoreCacheStats() const { return WebKit::WebCache::ResourceTypeStats(); } diff --git a/chrome/browser/task_manager_browsertest.cc b/chrome/browser/task_manager_browsertest.cc index 1712468..8751db0 100644 --- a/chrome/browser/task_manager_browsertest.cc +++ b/chrome/browser/task_manager_browsertest.cc @@ -13,7 +13,6 @@ #include "chrome/browser/tab_contents/infobar_delegate.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/extensions/extension.h" -#include "chrome/common/notification_type.h" #include "chrome/common/page_transition_types.h" #include "chrome/test/in_process_browser_test.h" #include "chrome/test/ui_test_utils.h" @@ -236,7 +235,9 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, DISABLED_ReloadExtension) { WaitForResourceChange(3); } -IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, PopulateWebCacheFields) { +// Crashy, http://crbug.com/42301. +IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, + DISABLED_PopulateWebCacheFields) { EXPECT_EQ(0, model()->ResourceCount()); // Show the task manager. This populates the model, and helps with debugging @@ -253,19 +254,11 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, PopulateWebCacheFields) { TabStripModel::ADD_SELECTED, NULL, std::string()); WaitForResourceChange(3); - // Make sure that we have received updated stats from the renderer. An update - // could be pending before we added the new tab, so wait for two updates. - // This way at least one of them must have occurred after adding the tab. - ui_test_utils::WaitForNotification( - NotificationType::TASK_MANAGER_RESOURCE_TYPE_STATS_UPDATED); - ui_test_utils::WaitForNotification( - NotificationType::TASK_MANAGER_RESOURCE_TYPE_STATS_UPDATED); - // Check that we get some value for the cache columns. - EXPECT_NE(model()->GetResourceWebCoreImageCacheSize(2), + DCHECK_NE(model()->GetResourceWebCoreImageCacheSize(2), l10n_util::GetString(IDS_TASK_MANAGER_NA_CELL_TEXT)); - EXPECT_NE(model()->GetResourceWebCoreScriptsCacheSize(2), + DCHECK_NE(model()->GetResourceWebCoreScriptsCacheSize(2), l10n_util::GetString(IDS_TASK_MANAGER_NA_CELL_TEXT)); - EXPECT_NE(model()->GetResourceWebCoreCSSCacheSize(2), + DCHECK_NE(model()->GetResourceWebCoreCSSCacheSize(2), l10n_util::GetString(IDS_TASK_MANAGER_NA_CELL_TEXT)); } diff --git a/chrome/browser/task_manager_resource_providers.cc b/chrome/browser/task_manager_resource_providers.cc index 65b107a..d3fa808 100644 --- a/chrome/browser/task_manager_resource_providers.cc +++ b/chrome/browser/task_manager_resource_providers.cc @@ -54,7 +54,6 @@ TaskManagerTabContentsResource::TaskManagerTabContentsResource( TabContents* tab_contents) : tab_contents_(tab_contents), pending_stats_update_(false), - had_stats_update_(false), v8_memory_allocated_(0), v8_memory_used_(0), pending_v8_memory_allocated_update_(false) { @@ -62,7 +61,11 @@ TaskManagerTabContentsResource::TaskManagerTabContentsResource( // becomes NULL and the TaskManager still needs it. process_ = tab_contents_->GetRenderProcessHost()->GetHandle(); pid_ = base::GetProcId(process_); - memset(&stats_, 0, sizeof(stats_)); + stats_.images.size = 0; + stats_.cssStyleSheets.size = 0; + stats_.scripts.size = 0; + stats_.xslStyleSheets.size = 0; + stats_.fonts.size = 0; } TaskManagerTabContentsResource::~TaskManagerTabContentsResource() { @@ -119,7 +122,6 @@ void TaskManagerTabContentsResource::NotifyResourceTypeStats( const WebKit::WebCache::ResourceTypeStats& stats) { stats_ = stats; pending_stats_update_ = false; - had_stats_update_ = true; } void TaskManagerTabContentsResource::NotifyV8HeapStats( diff --git a/chrome/browser/task_manager_resource_providers.h b/chrome/browser/task_manager_resource_providers.h index 2029a54..b96083c 100644 --- a/chrome/browser/task_manager_resource_providers.h +++ b/chrome/browser/task_manager_resource_providers.h @@ -35,7 +35,7 @@ class TaskManagerTabContentsResource : public TaskManager::Resource { base::ProcessHandle GetProcess() const; TabContents* GetTabContents() const; - virtual bool HasCacheStats() const { return had_stats_update_; } + virtual bool ReportsCacheStats() const { return true; } virtual WebKit::WebCache::ResourceTypeStats GetWebCoreCacheStats() const; virtual bool ReportsV8MemoryStats() const { return true; } @@ -58,18 +58,12 @@ class TaskManagerTabContentsResource : public TaskManager::Resource { TabContents* tab_contents_; base::ProcessHandle process_; int pid_; - // The stats_ field holds information about resource usage in the renderer // process and so it is updated asynchronously by the Refresh() call. WebKit::WebCache::ResourceTypeStats stats_; - // This flag is true if we are waiting for the renderer to report its stats. bool pending_stats_update_; - // This flag is true after we received at least one stats report - // from the renderer. - bool had_stats_update_; - // We do a similar dance to gather the V8 memory usage in a process. size_t v8_memory_allocated_; size_t v8_memory_used_; diff --git a/chrome/common/notification_type.h b/chrome/common/notification_type.h index 87d1550..a30fb27 100644 --- a/chrome/common/notification_type.h +++ b/chrome/common/notification_type.h @@ -1051,12 +1051,6 @@ class NotificationType { // TokenRequestFailedDetails object. TOKEN_REQUEST_FAILED, - // Task Manager ------------------------------------------------------------ - - // Sent after the Task Manager has received updated ResourceTypeStats - // from a renderer. Source is a TaskManagerModel. - TASK_MANAGER_RESOURCE_TYPE_STATS_UPDATED, - // Misc -------------------------------------------------------------------- #if defined(OS_CHROMEOS) |