diff options
author | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-16 01:56:35 +0000 |
---|---|---|
committer | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-16 01:56:35 +0000 |
commit | 9f66d3066829486700ed7ac72328defcd2196ff3 (patch) | |
tree | eb836489bb6e29d77fdffc258b1a8039e257868f /chrome/browser | |
parent | 6f7e5bc02b5edc14761ad17fd5abd4e97e9d1553 (diff) | |
download | chromium_src-9f66d3066829486700ed7ac72328defcd2196ff3.zip chromium_src-9f66d3066829486700ed7ac72328defcd2196ff3.tar.gz chromium_src-9f66d3066829486700ed7ac72328defcd2196ff3.tar.bz2 |
Revert 110235 - chrome: Remove 14 exit time destructors and 2 static initializers.
BUG=101600, 94925
TEST=none
TBR=mnissler
Review URL: http://codereview.chromium.org/8573021
TBR=thakis@chromium.org
Review URL: http://codereview.chromium.org/8568039
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110238 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/autocomplete/builtin_provider.cc | 10 | ||||
-rw-r--r-- | chrome/browser/autocomplete/search_provider.cc | 4 | ||||
-rw-r--r-- | chrome/browser/browser_about_handler.cc | 2 | ||||
-rw-r--r-- | chrome/browser/character_encoding.cc | 8 | ||||
-rw-r--r-- | chrome/browser/content_settings/tab_specific_content_settings.cc | 2 | ||||
-rw-r--r-- | chrome/browser/google/google_update_settings_posix.cc | 21 | ||||
-rw-r--r-- | chrome/browser/metrics/thread_watcher.cc | 37 | ||||
-rw-r--r-- | chrome/browser/metrics/thread_watcher.h | 7 | ||||
-rw-r--r-- | chrome/browser/policy/device_management_backend_impl.cc | 4 | ||||
-rw-r--r-- | chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc | 12 | ||||
-rw-r--r-- | chrome/browser/search_engines/search_terms_data.cc | 3 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/about_chrome_dialog.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc | 5 | ||||
-rw-r--r-- | chrome/browser/web_resource/gpu_blacklist_updater.cc | 2 |
14 files changed, 60 insertions, 59 deletions
diff --git a/chrome/browser/autocomplete/builtin_provider.cc b/chrome/browser/autocomplete/builtin_provider.cc index fd0c677..54a1b60 100644 --- a/chrome/browser/autocomplete/builtin_provider.cc +++ b/chrome/browser/autocomplete/builtin_provider.cc @@ -63,13 +63,13 @@ void BuiltinProvider::Start(const AutocompleteInput& input, (input.matches_requested() == AutocompleteInput::BEST_MATCH)) return; - const string16 kAbout = ASCIIToUTF16(chrome::kAboutScheme) + + static const string16 kAbout = ASCIIToUTF16(chrome::kAboutScheme) + ASCIIToUTF16(chrome::kStandardSchemeSeparator); - const string16 kChrome = ASCIIToUTF16(chrome::kChromeUIScheme) + + static const string16 kChrome = ASCIIToUTF16(chrome::kChromeUIScheme) + ASCIIToUTF16(chrome::kStandardSchemeSeparator); - const int kUrl = ACMatchClassification::URL; - const int kMatch = kUrl | ACMatchClassification::MATCH; + static const int kUrl = ACMatchClassification::URL; + static const int kMatch = kUrl | ACMatchClassification::MATCH; string16 text = input.text(); bool starting_chrome = StartsWith(kChrome, text, false); @@ -77,7 +77,7 @@ void BuiltinProvider::Start(const AutocompleteInput& input, ACMatchClassifications styles; // Highlight the input portion matching "chrome://"; or if the user has // input "about:" (with optional slashes), highlight the whole "chrome://". - const size_t kAboutSchemeLength = strlen(chrome::kAboutScheme); + static const size_t kAboutSchemeLength = strlen(chrome::kAboutScheme); bool highlight = starting_chrome || text.length() > kAboutSchemeLength; styles.push_back(ACMatchClassification(0, highlight ? kMatch : kUrl)); size_t offset = starting_chrome ? text.length() : kChrome.length(); diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc index 62d5b92..9453e19 100644 --- a/chrome/browser/autocomplete/search_provider.cc +++ b/chrome/browser/autocomplete/search_provider.cc @@ -330,7 +330,7 @@ void SearchProvider::StartOrStopSuggestQuery(bool minimal_changes) { // Don't send any queries to the server until some time has elapsed after // the last keypress, to avoid flooding the server with requests we are // likely to end up throwing away anyway. - const int kQueryDelayMs = 200; + static const int kQueryDelayMs = 200; if (!IsQuerySuitableForSuggest()) { StopSuggest(); @@ -491,7 +491,7 @@ bool SearchProvider::ParseSuggestResults(Value* root_val, DictionaryValue* dict_val = static_cast<DictionaryValue*>(optional_val); // Parse Google Suggest specific type extension. - const std::string kGoogleSuggestType("google:suggesttype"); + static const std::string kGoogleSuggestType("google:suggesttype"); if (dict_val->HasKey(kGoogleSuggestType)) dict_val->GetList(kGoogleSuggestType, &type_list); } diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc index 8e0435f..5c5edd7 100644 --- a/chrome/browser/browser_about_handler.cc +++ b/chrome/browser/browser_about_handler.cc @@ -913,7 +913,7 @@ static std::string AboutTracking(const std::string& query) { std::string AboutStats(const std::string& query) { // We keep the DictionaryValue tree live so that we can do delta // stats computations across runs. - CR_DEFINE_STATIC_LOCAL(DictionaryValue, root, ()); + static DictionaryValue root; static base::TimeTicks last_sample_time = base::TimeTicks::Now(); base::TimeTicks now = base::TimeTicks::Now(); diff --git a/chrome/browser/character_encoding.cc b/chrome/browser/character_encoding.cc index 460da9e..ec433af 100644 --- a/chrome/browser/character_encoding.cc +++ b/chrome/browser/character_encoding.cc @@ -410,9 +410,9 @@ std::string CharacterEncoding::GetCanonicalEncodingNameByAliasName( // Static // According to the behavior of user recently selected encoding short list in -// Firefox, we always put UTF-8 as top position, after then put user -// recent selected encodings, then put local dependent encoding items. -// At last, we put all remaining encoding items. +// FireFox, we always put UTF-8 as toppest position, after then put user +// recently selected encodings, then put local dependent encoding items. +// At last, we put all rest encoding items. const std::vector<CharacterEncoding::EncodingInfo>* CharacterEncoding::GetCurrentDisplayEncodings( const std::string& locale, @@ -429,7 +429,7 @@ const std::vector<CharacterEncoding::EncodingInfo>* locale_dependent_encoding_list, kUserSelectedEncodingsMaxLength); - CR_DEFINE_STATIC_LOCAL(std::string, cached_user_selected_encodings, ()); + static std::string cached_user_selected_encodings; // Build current display encoding list. if (encoding_list->empty() || cached_user_selected_encodings != recently_select_encodings) { diff --git a/chrome/browser/content_settings/tab_specific_content_settings.cc b/chrome/browser/content_settings/tab_specific_content_settings.cc index f1905b6..09735ce 100644 --- a/chrome/browser/content_settings/tab_specific_content_settings.cc +++ b/chrome/browser/content_settings/tab_specific_content_settings.cc @@ -199,7 +199,7 @@ const std::set<std::string>& if (blocked_resources_[content_type].get()) { return *blocked_resources_[content_type]; } else { - CR_DEFINE_STATIC_LOCAL(std::set<std::string>, empty_set, ()); + static std::set<std::string> empty_set; return empty_set; } } diff --git a/chrome/browser/google/google_update_settings_posix.cc b/chrome/browser/google/google_update_settings_posix.cc index c47e0c7..242407c 100644 --- a/chrome/browser/google/google_update_settings_posix.cc +++ b/chrome/browser/google/google_update_settings_posix.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 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. @@ -10,14 +10,9 @@ #include "chrome/common/chrome_paths.h" namespace google_update { - -static std::string& posix_guid() { - CR_DEFINE_STATIC_LOCAL(std::string, guid, ()); - return guid; +std::string posix_guid; } -} // namespace google_update - // File name used in the user data dir to indicate consent. static const char kConsentToSendStats[] = "Consent To Send Stats"; @@ -29,7 +24,7 @@ bool GoogleUpdateSettings::GetCollectStatsConsent() { std::string tmp_guid; bool consented = file_util::ReadFileToString(consent_file, &tmp_guid); if (consented) - google_update::posix_guid().assign(tmp_guid); + google_update::posix_guid.assign(tmp_guid); return consented; } @@ -44,13 +39,13 @@ bool GoogleUpdateSettings::SetCollectStatsConsent(bool consented) { if (consented) { if ((!file_util::PathExists(consent_file)) || (file_util::PathExists(consent_file) && - !google_update::posix_guid().empty())) { - const char* c_str = google_update::posix_guid().c_str(); - int size = google_update::posix_guid().size(); + !google_update::posix_guid.empty())) { + const char* c_str = google_update::posix_guid.c_str(); + int size = google_update::posix_guid.size(); return file_util::WriteFile(consent_file, c_str, size) == size; } } else { - google_update::posix_guid().clear(); + google_update::posix_guid.clear(); return file_util::Delete(consent_file, false); } return true; @@ -65,7 +60,7 @@ bool GoogleUpdateSettings::SetMetricsId(const std::wstring& client_id) { return false; // Since user has consented, write the metrics id to the file. - google_update::posix_guid() = WideToASCII(client_id); + google_update::posix_guid = WideToASCII(client_id); return GoogleUpdateSettings::SetCollectStatsConsent(true); } diff --git a/chrome/browser/metrics/thread_watcher.cc b/chrome/browser/metrics/thread_watcher.cc index 01f5e0d..a971743 100644 --- a/chrome/browser/metrics/thread_watcher.cc +++ b/chrome/browser/metrics/thread_watcher.cc @@ -9,7 +9,6 @@ #include "base/bind.h" #include "base/compiler_specific.h" #include "base/debug/alias.h" -#include "base/lazy_instance.h" #include "base/string_tokenizer.h" #include "base/threading/thread_restrictions.h" #include "build/build_config.h" @@ -703,15 +702,11 @@ void ThreadWatcherObserver::Observe( } // WatchDogThread methods and members. - -// This lock protects g_watchdog_thread. -static base::LazyInstance<base::Lock, - base::LeakyLazyInstanceTraits<base::Lock> > - g_watchdog_lock = LAZY_INSTANCE_INITIALIZER; - -// The singleton of this class. -static WatchDogThread* g_watchdog_thread = NULL; - +// +// static +base::Lock WatchDogThread::lock_; +// static +WatchDogThread* WatchDogThread::watchdog_thread_ = NULL; // The WatchDogThread object must outlive any tasks posted to the IO thread // before the Quit task. @@ -726,9 +721,9 @@ WatchDogThread::~WatchDogThread() { // static bool WatchDogThread::CurrentlyOnWatchDogThread() { - base::AutoLock lock(g_watchdog_lock.Get()); - return g_watchdog_thread && - g_watchdog_thread->message_loop() == MessageLoop::current(); + base::AutoLock lock(lock_); + return watchdog_thread_ && + watchdog_thread_->message_loop() == MessageLoop::current(); } // static @@ -750,10 +745,10 @@ bool WatchDogThread::PostTaskHelper( const base::Closure& task, int64 delay_ms) { { - base::AutoLock lock(g_watchdog_lock.Get()); + base::AutoLock lock(lock_); - MessageLoop* message_loop = g_watchdog_thread ? - g_watchdog_thread->message_loop() : NULL; + MessageLoop* message_loop = watchdog_thread_ ? + watchdog_thread_->message_loop() : NULL; if (message_loop) { message_loop->PostDelayedTask(from_here, task, delay_ms); return true; @@ -767,14 +762,14 @@ void WatchDogThread::Init() { // This thread shouldn't be allowed to perform any blocking disk I/O. base::ThreadRestrictions::SetIOAllowed(false); - base::AutoLock lock(g_watchdog_lock.Get()); - CHECK(!g_watchdog_thread); - g_watchdog_thread = this; + base::AutoLock lock(lock_); + CHECK(!watchdog_thread_); + watchdog_thread_ = this; } void WatchDogThread::CleanUp() { - base::AutoLock lock(g_watchdog_lock.Get()); - g_watchdog_thread = NULL; + base::AutoLock lock(lock_); + watchdog_thread_ = NULL; } namespace { diff --git a/chrome/browser/metrics/thread_watcher.h b/chrome/browser/metrics/thread_watcher.h index 64d9058..a36cbac 100644 --- a/chrome/browser/metrics/thread_watcher.h +++ b/chrome/browser/metrics/thread_watcher.h @@ -462,7 +462,7 @@ class WatchDogThread : public base::Thread { virtual ~WatchDogThread(); // Callable on any thread. Returns whether you're currently on a - // WatchDogThread. + // watchdog_thread_. static bool CurrentlyOnWatchDogThread(); // These are the same methods in message_loop.h, but are guaranteed to either @@ -486,6 +486,11 @@ class WatchDogThread : public base::Thread { const base::Closure& task, int64 delay_ms); + // This lock protects watchdog_thread_. + static base::Lock lock_; + + static WatchDogThread* watchdog_thread_; // The singleton of this class. + DISALLOW_COPY_AND_ASSIGN(WatchDogThread); }; diff --git a/chrome/browser/policy/device_management_backend_impl.cc b/chrome/browser/policy/device_management_backend_impl.cc index 5143b21..a71f6ed 100644 --- a/chrome/browser/policy/device_management_backend_impl.cc +++ b/chrome/browser/policy/device_management_backend_impl.cc @@ -473,7 +473,7 @@ DeviceManagementBackendImpl::~DeviceManagementBackendImpl() { } std::string DeviceManagementBackendImpl::GetAgentString() { - CR_DEFINE_STATIC_LOCAL(std::string, agent, ()); + static std::string agent; if (!agent.empty()) return agent; @@ -486,7 +486,7 @@ std::string DeviceManagementBackendImpl::GetAgentString() { } std::string DeviceManagementBackendImpl::GetPlatformString() { - CR_DEFINE_STATIC_LOCAL(std::string, platform, ()); + static std::string platform; if (!platform.empty()) return platform; diff --git a/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc b/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc index 1a90739..6e332f4 100644 --- a/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc +++ b/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc @@ -37,12 +37,16 @@ namespace { -string16 SetupIframeXPath() { - return ASCIIToUTF16("//iframe[@id='cloudprintsetup']"); +string16& SetupIframeXPath() { + static string16 kSetupIframeXPath = + ASCIIToUTF16("//iframe[@id='cloudprintsetup']"); + return kSetupIframeXPath; } -string16 DoneIframeXPath() { - return ASCIIToUTF16("//iframe[@id='setupdone']"); +string16& DoneIframeXPath() { + static string16 kDoneIframeXPath = + ASCIIToUTF16("//iframe[@id='setupdone']"); + return kDoneIframeXPath; } } // end namespace diff --git a/chrome/browser/search_engines/search_terms_data.cc b/chrome/browser/search_engines/search_terms_data.cc index 95cc1a6..c7aa887 100644 --- a/chrome/browser/search_engines/search_terms_data.cc +++ b/chrome/browser/search_engines/search_terms_data.cc @@ -33,7 +33,8 @@ std::string SearchTermsData::GoogleBaseSuggestURLValue() const { GURL::Replacements repl; // Replace any existing path with "/complete/". - repl.SetPathStr("/complete/"); + static const std::string suggest_path("/complete/"); + repl.SetPathStr(suggest_path); // Clear the query and ref. repl.ClearQuery(); diff --git a/chrome/browser/ui/gtk/about_chrome_dialog.cc b/chrome/browser/ui/gtk/about_chrome_dialog.cc index e5c7adc..fa01090 100644 --- a/chrome/browser/ui/gtk/about_chrome_dialog.cc +++ b/chrome/browser/ui/gtk/about_chrome_dialog.cc @@ -73,7 +73,7 @@ void OnLinkButtonClick(GtkWidget* button, const char* url) { } const char* GetChromiumUrl() { - GURL url = google_util::AppendGoogleLocaleParam( + static GURL url = google_util::AppendGoogleLocaleParam( GURL(chrome::kChromiumProjectURL)); return url.spec().c_str(); } diff --git a/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc b/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc index f1fe047..35b3ac0 100644 --- a/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc +++ b/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc @@ -59,11 +59,12 @@ const int kSeparatorPadding = 2; // Width of the invisible gripper for resizing the toolbar. const int kResizeGripperWidth = 4; -const char kDragTarget[] = "application/x-chrome-browseraction"; +const char* kDragTarget = "application/x-chrome-browseraction"; GtkTargetEntry GetDragTargetEntry() { + static std::string drag_target_string(kDragTarget); GtkTargetEntry drag_target; - drag_target.target = const_cast<char*>(kDragTarget); + drag_target.target = const_cast<char*>(drag_target_string.c_str()); drag_target.flags = GTK_TARGET_SAME_APP; drag_target.info = 0; return drag_target; diff --git a/chrome/browser/web_resource/gpu_blacklist_updater.cc b/chrome/browser/web_resource/gpu_blacklist_updater.cc index 89f22a9..4e67cb9 100644 --- a/chrome/browser/web_resource/gpu_blacklist_updater.cc +++ b/chrome/browser/web_resource/gpu_blacklist_updater.cc @@ -36,7 +36,7 @@ static const int kStartGpuBlacklistFetchDelay = 6000; static const int kCacheUpdateDelay = 48 * 60 * 60 * 1000; std::string GetChromeVersionString() { - CR_DEFINE_STATIC_LOCAL(std::string, cr_version, ()); + static std::string cr_version; if (!cr_version.empty()) return cr_version; chrome::VersionInfo version_info; |