diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-02 20:37:27 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-02 20:37:27 +0000 |
commit | 019191a62f17852c6e8a5085bbd62e804d559718 (patch) | |
tree | 3867502e4a71d6589c5183ea0e6f85a481ee869d /chrome | |
parent | 2d8d923da42df61e9d65942945456d4b9304ef8e (diff) | |
download | chromium_src-019191a62f17852c6e8a5085bbd62e804d559718.zip chromium_src-019191a62f17852c6e8a5085bbd62e804d559718.tar.gz chromium_src-019191a62f17852c6e8a5085bbd62e804d559718.tar.bz2 |
Convert users of RenderProcessHost iterator to all use same style. The key motivator for this is that at least one old place actually did the wrong thing in its loop and failed to call functions on anything but the first host. This also makes many places slightly shorter.
Remove an unneeded #include in web_cache_manager.h by converting it to a forward declaration.
Update copyrights on touched files.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/242104
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27890 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/browser_browsertest.cc | 9 | ||||
-rw-r--r-- | chrome/browser/browser_list.cc | 8 | ||||
-rw-r--r-- | chrome/browser/browser_list.h | 4 | ||||
-rw-r--r-- | chrome/browser/browser_process_impl.cc | 11 | ||||
-rw-r--r-- | chrome/browser/browser_shutdown.cc | 10 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_dom_ui.cc | 2 | ||||
-rw-r--r-- | chrome/browser/memory_details.cc | 6 | ||||
-rw-r--r-- | chrome/browser/metrics/metrics_service.cc | 10 | ||||
-rw-r--r-- | chrome/browser/renderer_host/web_cache_manager.cc | 3 | ||||
-rw-r--r-- | chrome/browser/renderer_host/web_cache_manager.h | 5 | ||||
-rw-r--r-- | chrome/browser/task_manager_resource_providers.cc | 4 |
11 files changed, 32 insertions, 40 deletions
diff --git a/chrome/browser/browser_browsertest.cc b/chrome/browser/browser_browsertest.cc index d19fd66..30e621b 100644 --- a/chrome/browser/browser_browsertest.cc +++ b/chrome/browser/browser_browsertest.cc @@ -43,12 +43,9 @@ std::wstring WindowCaptionFromPageTitle(std::wstring page_title) { // Returns the number of active RenderProcessHosts. int CountRenderProcessHosts() { int result = 0; - RenderProcessHost::iterator renderer_iter( - RenderProcessHost::AllHostsIterator()); - while (!renderer_iter.IsAtEnd()) { - result++; - renderer_iter.Advance(); - } + for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); + !i.IsAtEnd(); i.Advance()) + ++result; return result; } diff --git a/chrome/browser/browser_list.cc b/chrome/browser/browser_list.cc index 6a1f2c2..24b796c 100644 --- a/chrome/browser/browser_list.cc +++ b/chrome/browser/browser_list.cc @@ -48,11 +48,9 @@ class BrowserActivityObserver : public NotificationObserver { // Counts the number of active RenderProcessHosts and logs them. void LogRenderProcessHostCount() const { int hosts_count = 0; - RenderProcessHost::iterator iter(RenderProcessHost::AllHostsIterator()); - while (!iter.IsAtEnd()) { - hosts_count++; - iter.Advance(); - } + for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); + !i.IsAtEnd(); i.Advance()) + ++hosts_count; UMA_HISTOGRAM_CUSTOM_COUNTS("MPArch.RPHCountPerLoad", hosts_count, 1, 50, 50); } diff --git a/chrome/browser/browser_list.h b/chrome/browser/browser_list.h index fda1aa4..de07b9a 100644 --- a/chrome/browser/browser_list.h +++ b/chrome/browser/browser_list.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. @@ -139,7 +139,7 @@ class TabContents; // browser windows or tabs while iterating may cause incorrect behavior. // // Example: -// for (TabContentsIterator iterator; !iterator.done(); iterator++) { +// for (TabContentsIterator iterator; !iterator.done(); ++iterator) { // TabContents* cur = *iterator; // -or- // iterator->operationOnTabContents(); diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc index f381b65..750dc2c 100644 --- a/chrome/browser/browser_process_impl.cc +++ b/chrome/browser/browser_process_impl.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. @@ -465,12 +465,9 @@ void BrowserProcessImpl::SetIPCLoggingEnabled(bool enable) { // Finally, tell the renderers which don't derive from ChildProcess. // Messages to the renderers must be done on the UI (main) thread. - RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); - for (RenderProcessHost* host = i.GetCurrentValue(); - !i.IsAtEnd(); - i.Advance()) { - host->Send(new ViewMsg_SetIPCLoggingEnabled(enable)); - } + for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); + !i.IsAtEnd(); i.Advance()) + i.GetCurrentValue()->Send(new ViewMsg_SetIPCLoggingEnabled(enable)); } // Helper for SetIPCLoggingEnabled. diff --git a/chrome/browser/browser_shutdown.cc b/chrome/browser/browser_shutdown.cc index 22f4507..d3530bb 100644 --- a/chrome/browser/browser_shutdown.cc +++ b/chrome/browser/browser_shutdown.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. @@ -72,10 +72,10 @@ void OnShutdownStarting(ShutdownType type) { // shutdown path for the ones that didn't exit here. shutdown_num_processes_ = 0; shutdown_num_processes_slow_ = 0; - RenderProcessHost::iterator hosts(RenderProcessHost::AllHostsIterator()); - while (!hosts.IsAtEnd()) { - shutdown_num_processes_++; - if (!hosts.GetCurrentValue()->FastShutdownIfPossible()) { + for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); + !i.IsAtEnd(); i.Advance()) { + ++shutdown_num_processes_; + if (!i.GetCurrentValue()->FastShutdownIfPossible()) { shutdown_num_processes_slow_++; } diff --git a/chrome/browser/extensions/extension_dom_ui.cc b/chrome/browser/extensions/extension_dom_ui.cc index c3741c7..a718f5c 100644 --- a/chrome/browser/extensions/extension_dom_ui.cc +++ b/chrome/browser/extensions/extension_dom_ui.cc @@ -189,7 +189,7 @@ void ExtensionDOMUI::UnregisterAndReplaceOverride(const std::string& page, if (index == 0) { // This is the active override, so we need to find all existing // tabs for this override and get them to reload the original URL. - for (TabContentsIterator iterator; !iterator.done(); iterator++) { + for (TabContentsIterator iterator; !iterator.done(); ++iterator) { TabContents* tab = *iterator; if (tab->profile() != profile) continue; diff --git a/chrome/browser/memory_details.cc b/chrome/browser/memory_details.cc index 219333f..72d47fd 100644 --- a/chrome/browser/memory_details.cc +++ b/chrome/browser/memory_details.cc @@ -87,12 +87,12 @@ void MemoryDetails::CollectChildInfoOnUIThread() { // check if it's a diagnostics-related process. We skip all diagnostics // pages (e.g. "about:xxx" URLs). Iterate the RenderProcessHosts to find // the tab contents. - RenderProcessHost::iterator renderer_iter( - RenderProcessHost::AllHostsIterator()); ProcessMemoryInformation& process = chrome_browser->processes[index]; - for (; !renderer_iter.IsAtEnd(); renderer_iter.Advance()) { + for (RenderProcessHost::iterator renderer_iter( + RenderProcessHost::AllHostsIterator()); !renderer_iter.IsAtEnd(); + renderer_iter.Advance()) { DCHECK(renderer_iter.GetCurrentValue()); if (process.pid != renderer_iter.GetCurrentValue()->process().pid()) continue; diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc index f3630f5..7f654f4 100644 --- a/chrome/browser/metrics/metrics_service.cc +++ b/chrome/browser/metrics/metrics_service.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 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. @@ -957,11 +957,9 @@ void MetricsService::LogTransmissionTimerDone() { details->StartFetch(); // Collect WebCore cache information to put into a histogram. - RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator()); - while (!it.IsAtEnd()) { - it.GetCurrentValue()->Send(new ViewMsg_GetCacheResourceStats()); - it.Advance(); - } + for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); + !i.IsAtEnd(); i.Advance()) + i.GetCurrentValue()->Send(new ViewMsg_GetCacheResourceStats()); } void MetricsService::OnMemoryDetailCollectionDone() { diff --git a/chrome/browser/renderer_host/web_cache_manager.cc b/chrome/browser/renderer_host/web_cache_manager.cc index 3135ae4..f5684ae 100644 --- a/chrome/browser/renderer_host/web_cache_manager.cc +++ b/chrome/browser/renderer_host/web_cache_manager.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,6 +7,7 @@ #include <algorithm> #include "base/compiler_specific.h" +#include "base/singleton.h" #include "base/sys_info.h" #include "base/time.h" #include "chrome/browser/browser_process.h" diff --git a/chrome/browser/renderer_host/web_cache_manager.h b/chrome/browser/renderer_host/web_cache_manager.h index 333aeb2..82af433 100644 --- a/chrome/browser/renderer_host/web_cache_manager.h +++ b/chrome/browser/renderer_host/web_cache_manager.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. @@ -14,12 +14,13 @@ #include "base/basictypes.h" #include "base/shared_memory.h" -#include "base/singleton.h" #include "base/task.h" #include "base/time.h" #include "testing/gtest/include/gtest/gtest_prod.h" #include "webkit/api/public/WebCache.h" +template<typename Type> +struct DefaultSingletonTraits; class PrefService; class WebCacheManager { diff --git a/chrome/browser/task_manager_resource_providers.cc b/chrome/browser/task_manager_resource_providers.cc index 20ef4d1a..09c03e9 100644 --- a/chrome/browser/task_manager_resource_providers.cc +++ b/chrome/browser/task_manager_resource_providers.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. @@ -162,7 +162,7 @@ void TaskManagerTabContentsResourceProvider::StartUpdating() { updating_ = true; // Add all the existing TabContents. - for (TabContentsIterator iterator; !iterator.done(); iterator++) + for (TabContentsIterator iterator; !iterator.done(); ++iterator) Add(*iterator); // Then we register for notifications to get new tabs. |