Commit 4c2f5633 authored by thakis@chromium.org's avatar thakis@chromium.org

CrOs: Remove 16 exit time destructors and 11 static initializers.

BUG=101600,94925
TEST=none
TBR=stevenjb

Review URL: http://codereview.chromium.org/8609002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110868 0039d316-1c4b-4281-b951-d872f2087c98
parent 1ce8b39d
...@@ -57,7 +57,7 @@ void StartUpdateCallback(void* user_data, ...@@ -57,7 +57,7 @@ void StartUpdateCallback(void* user_data,
// static // static
UpdateScreen::InstanceSet& UpdateScreen::GetInstanceSet() { UpdateScreen::InstanceSet& UpdateScreen::GetInstanceSet() {
static std::set<UpdateScreen*> instance_set; CR_DEFINE_STATIC_LOCAL(std::set<UpdateScreen*>, instance_set, ());
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); // not threadsafe. DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); // not threadsafe.
return instance_set; return instance_set;
} }
......
...@@ -699,7 +699,7 @@ const SkBitmap NetworkMenuIcon::GenerateBitmapFromComponents( ...@@ -699,7 +699,7 @@ const SkBitmap NetworkMenuIcon::GenerateBitmapFromComponents(
// We blend connecting icons with a black image to generate a faded icon. // We blend connecting icons with a black image to generate a faded icon.
const SkBitmap NetworkMenuIcon::GenerateConnectingBitmap( const SkBitmap NetworkMenuIcon::GenerateConnectingBitmap(
const SkBitmap& source) { const SkBitmap& source) {
static SkBitmap empty_badge; CR_DEFINE_STATIC_LOCAL(SkBitmap, empty_badge, ());
if (empty_badge.empty()) { if (empty_badge.empty()) {
empty_badge.setConfig(SkBitmap::kARGB_8888_Config, empty_badge.setConfig(SkBitmap::kARGB_8888_Config,
source.width(), source.height(), 0); source.width(), source.height(), 0);
......
...@@ -61,10 +61,10 @@ const char kVolumeDevicePathNotFound[] = "Device path not found"; ...@@ -61,10 +61,10 @@ const char kVolumeDevicePathNotFound[] = "Device path not found";
#ifdef OS_CHROMEOS #ifdef OS_CHROMEOS
// Volume type strings. // Volume type strings.
const std::string kVolumeTypeFlash = "flash"; const char kVolumeTypeFlash[] = "flash";
const std::string kVolumeTypeOptical = "optical"; const char kVolumeTypeOptical[] = "optical";
const std::string kVolumeTypeHardDrive = "hdd"; const char kVolumeTypeHardDrive[] = "hdd";
const std::string kVolumeTypeUnknown = "undefined"; const char kVolumeTypeUnknown[] = "undefined";
#endif #endif
// Internal task ids. // Internal task ids.
...@@ -1491,7 +1491,7 @@ bool GetVolumeMetadataFunction::RunImpl() { ...@@ -1491,7 +1491,7 @@ bool GetVolumeMetadataFunction::RunImpl() {
} }
#ifdef OS_CHROMEOS #ifdef OS_CHROMEOS
const std::string& GetVolumeMetadataFunction::DeviceTypeToString( std::string GetVolumeMetadataFunction::DeviceTypeToString(
chromeos::DeviceType type) { chromeos::DeviceType type) {
switch (type) { switch (type) {
case chromeos::FLASH: case chromeos::FLASH:
......
...@@ -339,7 +339,7 @@ class GetVolumeMetadataFunction ...@@ -339,7 +339,7 @@ class GetVolumeMetadataFunction
private: private:
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
const std::string& DeviceTypeToString(chromeos::DeviceType type); std::string DeviceTypeToString(chromeos::DeviceType type);
#endif #endif
DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getVolumeMetadata"); DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getVolumeMetadata");
......
...@@ -57,12 +57,24 @@ static const int kErrorLabelVerticalSpacing = 15; // Pixels. ...@@ -57,12 +57,24 @@ static const int kErrorLabelVerticalSpacing = 15; // Pixels.
namespace { namespace {
// These are used as placeholder text around the links in the text in the about // These are used as placeholder text around the links in the text in the about
// dialog. // dialog.
const string16 kBeginLink(ASCIIToUTF16("BEGIN_LINK")); string16 kBeginLink() {
const string16 kEndLink(ASCIIToUTF16("END_LINK")); return ASCIIToUTF16("BEGIN_LINK");
const string16 kBeginLinkChr(ASCIIToUTF16("BEGIN_LINK_CHR")); }
const string16 kBeginLinkOss(ASCIIToUTF16("BEGIN_LINK_OSS")); string16 kEndLink() {
const string16 kEndLinkChr(ASCIIToUTF16("END_LINK_CHR")); return ASCIIToUTF16("END_LINK");
const string16 kEndLinkOss(ASCIIToUTF16("END_LINK_OSS")); }
string16 kBeginLinkChr() {
return ASCIIToUTF16("BEGIN_LINK_CHR");
}
string16 kBeginLinkOss() {
return ASCIIToUTF16("BEGIN_LINK_OSS");
}
string16 kEndLinkChr() {
return ASCIIToUTF16("END_LINK_CHR");
}
string16 kEndLinkOss() {
return ASCIIToUTF16("END_LINK_OSS");
}
// Returns a substring from |text| between start and end. // Returns a substring from |text| between start and end.
string16 StringSubRange(const string16& text, size_t start, size_t end) { string16 StringSubRange(const string16& text, size_t start, size_t end) {
...@@ -196,33 +208,33 @@ void AboutChromeView::Init() { ...@@ -196,33 +208,33 @@ void AboutChromeView::Init() {
string16 text = l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_LICENSE); string16 text = l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_LICENSE);
chromium_url_appears_first_ = chromium_url_appears_first_ =
text.find(kBeginLinkChr) < text.find(kBeginLinkOss); text.find(kBeginLinkChr()) < text.find(kBeginLinkOss());
size_t link1 = text.find(kBeginLink); size_t link1 = text.find(kBeginLink());
DCHECK(link1 != string16::npos); DCHECK(link1 != string16::npos);
size_t link1_end = text.find(kEndLink, link1); size_t link1_end = text.find(kEndLink(), link1);
DCHECK(link1_end != string16::npos); DCHECK(link1_end != string16::npos);
size_t link2 = text.find(kBeginLink, link1_end); size_t link2 = text.find(kBeginLink(), link1_end);
DCHECK(link2 != string16::npos); DCHECK(link2 != string16::npos);
size_t link2_end = text.find(kEndLink, link2); size_t link2_end = text.find(kEndLink(), link2);
DCHECK(link1_end != string16::npos); DCHECK(link1_end != string16::npos);
main_label_chunk1_ = text.substr(0, link1); main_label_chunk1_ = text.substr(0, link1);
main_label_chunk2_ = StringSubRange(text, link1_end + kEndLinkOss.size(), main_label_chunk2_ = StringSubRange(text, link1_end + kEndLinkOss().size(),
link2); link2);
main_label_chunk3_ = text.substr(link2_end + kEndLinkOss.size()); main_label_chunk3_ = text.substr(link2_end + kEndLinkOss().size());
// The Chromium link within the main text of the dialog. // The Chromium link within the main text of the dialog.
chromium_url_ = new views::Link( chromium_url_ = new views::Link(
StringSubRange(text, text.find(kBeginLinkChr) + kBeginLinkChr.size(), StringSubRange(text, text.find(kBeginLinkChr()) + kBeginLinkChr().size(),
text.find(kEndLinkChr))); text.find(kEndLinkChr())));
AddChildView(chromium_url_); AddChildView(chromium_url_);
chromium_url_->set_listener(this); chromium_url_->set_listener(this);
// The Open Source link within the main text of the dialog. // The Open Source link within the main text of the dialog.
open_source_url_ = new views::Link( open_source_url_ = new views::Link(
StringSubRange(text, text.find(kBeginLinkOss) + kBeginLinkOss.size(), StringSubRange(text, text.find(kBeginLinkOss()) + kBeginLinkOss().size(),
text.find(kEndLinkOss))); text.find(kEndLinkOss())));
AddChildView(open_source_url_); AddChildView(open_source_url_);
open_source_url_->set_listener(this); open_source_url_->set_listener(this);
......
...@@ -109,8 +109,8 @@ void AppInfoView::Init(const string16& title_text, ...@@ -109,8 +109,8 @@ void AppInfoView::Init(const string16& title_text,
void AppInfoView::PrepareDescriptionLabel(const string16& description) { void AppInfoView::PrepareDescriptionLabel(const string16& description) {
DCHECK(!description.empty()); DCHECK(!description.empty());
static const size_t kMaxLength = 200; const size_t kMaxLength = 200;
static const string16 kEllipsis(ASCIIToUTF16(" ... ")); const string16 kEllipsis(ASCIIToUTF16(" ... "));
string16 text = description; string16 text = description;
if (text.length() > kMaxLength) { if (text.length() > kMaxLength) {
......
...@@ -473,7 +473,7 @@ gfx::Size ToolbarView::GetPreferredSize() { ...@@ -473,7 +473,7 @@ gfx::Size ToolbarView::GetPreferredSize() {
browser_actions_->GetPreferredSize().width() + browser_actions_->GetPreferredSize().width() +
app_menu_->GetPreferredSize().width() + kEdgeSpacing; app_menu_->GetPreferredSize().width() + kEdgeSpacing;
static SkBitmap normal_background; CR_DEFINE_STATIC_LOCAL(SkBitmap, normal_background, ());
if (normal_background.isNull()) { if (normal_background.isNull()) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance(); ResourceBundle& rb = ResourceBundle::GetSharedInstance();
normal_background = *rb.GetBitmapNamed(IDR_CONTENT_TOP_CENTER); normal_background = *rb.GetBitmapNamed(IDR_CONTENT_TOP_CENTER);
......
...@@ -142,8 +142,8 @@ void ChangePictureOptionsHandler::HandleChooseFile(const ListValue* args) { ...@@ -142,8 +142,8 @@ void ChangePictureOptionsHandler::HandleChooseFile(const ListValue* args) {
} }
// Static so we initialize it only once. // Static so we initialize it only once.
static SelectFileDialog::FileTypeInfo file_type_info = CR_DEFINE_STATIC_LOCAL(SelectFileDialog::FileTypeInfo, file_type_info,
GetUserImageFileTypeInfo(); (GetUserImageFileTypeInfo()));
select_file_dialog_->SelectFile( select_file_dialog_->SelectFile(
SelectFileDialog::SELECT_OPEN_FILE, SelectFileDialog::SELECT_OPEN_FILE,
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <string> #include <string>
#include "base/i18n/rtl.h" #include "base/i18n/rtl.h"
#include "base/lazy_instance.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/string_util.h" #include "base/string_util.h"
...@@ -120,7 +121,9 @@ static const char* kTimeZones[] = { ...@@ -120,7 +121,9 @@ static const char* kTimeZones[] = {
"Pacific/Tongatapu", "Pacific/Tongatapu",
}; };
static base::Lock timezone_bundle_lock; static base::LazyInstance<base::Lock,
base::LeakyLazyInstanceTraits<base::Lock> >
g_timezone_bundle_lock = LAZY_INSTANCE_INITIALIZER;
struct UResClose { struct UResClose {
inline void operator() (UResourceBundle* b) const { inline void operator() (UResourceBundle* b) const {
...@@ -138,7 +141,7 @@ string16 GetExemplarCity(const icu::TimeZone& zone) { ...@@ -138,7 +141,7 @@ string16 GetExemplarCity(const icu::TimeZone& zone) {
UErrorCode status = U_ZERO_ERROR; UErrorCode status = U_ZERO_ERROR;
{ {
base::AutoLock lock(timezone_bundle_lock); base::AutoLock lock(g_timezone_bundle_lock.Get());
if (zone_bundle == NULL) if (zone_bundle == NULL)
zone_bundle = ures_open(zone_bundle_name, uloc_getDefault(), &status); zone_bundle = ures_open(zone_bundle_name, uloc_getDefault(), &status);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment