diff options
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, 59 insertions, 60 deletions
diff --git a/chrome/browser/autocomplete/builtin_provider.cc b/chrome/browser/autocomplete/builtin_provider.cc index 54a1b60..fd0c677 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; - static const string16 kAbout = ASCIIToUTF16(chrome::kAboutScheme) + + const string16 kAbout = ASCIIToUTF16(chrome::kAboutScheme) + ASCIIToUTF16(chrome::kStandardSchemeSeparator); - static const string16 kChrome = ASCIIToUTF16(chrome::kChromeUIScheme) + + const string16 kChrome = ASCIIToUTF16(chrome::kChromeUIScheme) + ASCIIToUTF16(chrome::kStandardSchemeSeparator); - static const int kUrl = ACMatchClassification::URL; - static const int kMatch = kUrl | ACMatchClassification::MATCH; + const int kUrl = ACMatchClassification::URL; + 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://". - static const size_t kAboutSchemeLength = strlen(chrome::kAboutScheme); + 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 9453e19..62d5b92 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. - static const int kQueryDelayMs = 200; + 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. - static const std::string kGoogleSuggestType("google:suggesttype"); + 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 5c5edd7..8e0435f 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. - static DictionaryValue root; + CR_DEFINE_STATIC_LOCAL(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 ec433af..460da9e 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 toppest position, after then put user -// recently selected encodings, then put local dependent encoding items. -// At last, we put all rest encoding items. +// 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. 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); - static std::string cached_user_selected_encodings; + CR_DEFINE_STATIC_LOCAL(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 09735ce..f1905b6 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 { - static std::set<std::string> empty_set; + CR_DEFINE_STATIC_LOCAL(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 242407c..c47e0c7 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) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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,9 +10,14 @@ #include "chrome/common/chrome_paths.h" namespace google_update { -std::string posix_guid; + +static std::string& posix_guid() { + CR_DEFINE_STATIC_LOCAL(std::string, guid, ()); + return guid; } +} // namespace google_update + // File name used in the user data dir to indicate consent. static const char kConsentToSendStats[] = "Consent To Send Stats"; @@ -24,7 +29,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; } @@ -39,13 +44,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; @@ -60,7 +65,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 a971743..01f5e0d 100644 --- a/chrome/browser/metrics/thread_watcher.cc +++ b/chrome/browser/metrics/thread_watcher.cc @@ -9,6 +9,7 @@ #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" @@ -702,11 +703,15 @@ void ThreadWatcherObserver::Observe( } // WatchDogThread methods and members. -// -// static -base::Lock WatchDogThread::lock_; -// static -WatchDogThread* WatchDogThread::watchdog_thread_ = NULL; + +// 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; + // The WatchDogThread object must outlive any tasks posted to the IO thread // before the Quit task. @@ -721,9 +726,9 @@ WatchDogThread::~WatchDogThread() { // static bool WatchDogThread::CurrentlyOnWatchDogThread() { - base::AutoLock lock(lock_); - return watchdog_thread_ && - watchdog_thread_->message_loop() == MessageLoop::current(); + base::AutoLock lock(g_watchdog_lock.Get()); + return g_watchdog_thread && + g_watchdog_thread->message_loop() == MessageLoop::current(); } // static @@ -745,10 +750,10 @@ bool WatchDogThread::PostTaskHelper( const base::Closure& task, int64 delay_ms) { { - base::AutoLock lock(lock_); + base::AutoLock lock(g_watchdog_lock.Get()); - MessageLoop* message_loop = watchdog_thread_ ? - watchdog_thread_->message_loop() : NULL; + MessageLoop* message_loop = g_watchdog_thread ? + g_watchdog_thread->message_loop() : NULL; if (message_loop) { message_loop->PostDelayedTask(from_here, task, delay_ms); return true; @@ -762,14 +767,14 @@ void WatchDogThread::Init() { // This thread shouldn't be allowed to perform any blocking disk I/O. base::ThreadRestrictions::SetIOAllowed(false); - base::AutoLock lock(lock_); - CHECK(!watchdog_thread_); - watchdog_thread_ = this; + base::AutoLock lock(g_watchdog_lock.Get()); + CHECK(!g_watchdog_thread); + g_watchdog_thread = this; } void WatchDogThread::CleanUp() { - base::AutoLock lock(lock_); - watchdog_thread_ = NULL; + base::AutoLock lock(g_watchdog_lock.Get()); + g_watchdog_thread = NULL; } namespace { diff --git a/chrome/browser/metrics/thread_watcher.h b/chrome/browser/metrics/thread_watcher.h index a36cbac..64d9058 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 - // watchdog_thread_. + // WatchDogThread. static bool CurrentlyOnWatchDogThread(); // These are the same methods in message_loop.h, but are guaranteed to either @@ -486,11 +486,6 @@ 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 a71f6ed..5143b21 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() { - static std::string agent; + CR_DEFINE_STATIC_LOCAL(std::string, agent, ()); if (!agent.empty()) return agent; @@ -486,7 +486,7 @@ std::string DeviceManagementBackendImpl::GetAgentString() { } std::string DeviceManagementBackendImpl::GetPlatformString() { - static std::string platform; + CR_DEFINE_STATIC_LOCAL(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 6e332f4..1a90739 100644 --- a/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc +++ b/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc @@ -37,16 +37,12 @@ namespace { -string16& SetupIframeXPath() { - static string16 kSetupIframeXPath = - ASCIIToUTF16("//iframe[@id='cloudprintsetup']"); - return kSetupIframeXPath; +string16 SetupIframeXPath() { + return ASCIIToUTF16("//iframe[@id='cloudprintsetup']"); } -string16& DoneIframeXPath() { - static string16 kDoneIframeXPath = - ASCIIToUTF16("//iframe[@id='setupdone']"); - return kDoneIframeXPath; +string16 DoneIframeXPath() { + return ASCIIToUTF16("//iframe[@id='setupdone']"); } } // end namespace diff --git a/chrome/browser/search_engines/search_terms_data.cc b/chrome/browser/search_engines/search_terms_data.cc index c7aa887..95cc1a6 100644 --- a/chrome/browser/search_engines/search_terms_data.cc +++ b/chrome/browser/search_engines/search_terms_data.cc @@ -33,8 +33,7 @@ std::string SearchTermsData::GoogleBaseSuggestURLValue() const { GURL::Replacements repl; // Replace any existing path with "/complete/". - static const std::string suggest_path("/complete/"); - repl.SetPathStr(suggest_path); + repl.SetPathStr("/complete/"); // 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 fa01090..e5c7adc 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() { - static GURL url = google_util::AppendGoogleLocaleParam( + 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 35b3ac0..f1fe047 100644 --- a/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc +++ b/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc @@ -59,12 +59,11 @@ 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*>(drag_target_string.c_str()); + drag_target.target = const_cast<char*>(kDragTarget); 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 4e67cb9..89f22a9 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() { - static std::string cr_version; + CR_DEFINE_STATIC_LOCAL(std::string, cr_version, ()); if (!cr_version.empty()) return cr_version; chrome::VersionInfo version_info; |