Skip to content

Commit

Permalink
Remove 13 exit time constructors and 3 static initializers
Browse files Browse the repository at this point in the history
BUG=101600,94925
TEST=none
TBR=vandebo,viettrungluu

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108838 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
thakis@chromium.org committed Nov 7, 2011
1 parent 5a4c3f5 commit 2643002
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 30 deletions.
5 changes: 2 additions & 3 deletions content/browser/tab_contents/web_drag_source_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,8 @@ - (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal {
- (void)lazyWriteToPasteboard:(NSPasteboard*)pboard forType:(NSString*)type {
// NSHTMLPboardType requires the character set to be declared. Otherwise, it
// assumes US-ASCII. Awesome.
static const string16 kHtmlHeader =
ASCIIToUTF16("<meta http-equiv=\"Content-Type\" "
"content=\"text/html;charset=UTF-8\">");
const string16 kHtmlHeader = ASCIIToUTF16(
"<meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\">");

// Be extra paranoid; avoid crashing.
if (!dropData_.get()) {
Expand Down
4 changes: 2 additions & 2 deletions jingle/notifier/listener/push_notifications_subscribe_task.cc
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -80,7 +80,7 @@ buzz::XmlElement* PushNotificationsSubscribeTask::MakeSubscriptionMessage(
const SubscriptionList& subscriptions,
const buzz::Jid& jid, const std::string& task_id) {
DCHECK(jid.IsFull());
static const buzz::QName kQnSubscribe(
const buzz::QName kQnSubscribe(
kPushNotificationsNamespace, "subscribe");

// Create the subscription stanza using the notifications protocol.
Expand Down
3 changes: 2 additions & 1 deletion net/base/net_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,8 @@ static base::Lock lang_set_lock;
// the language |lang|.
bool IsComponentCoveredByLang(const icu::UnicodeSet& component_characters,
const std::string& lang) {
static const icu::UnicodeSet kASCIILetters(0x61, 0x7a); // [a-z]
CR_DEFINE_STATIC_LOCAL(
const icu::UnicodeSet, kASCIILetters, ('a', 'z'));
icu::UnicodeSet* lang_set;
// We're called from both the UI thread and the history thread.
{
Expand Down
2 changes: 1 addition & 1 deletion net/http/http_mac_signature.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ bool HttpMacSignature::GenerateHeaderString(const std::string& age,
std::string HttpMacSignature::GenerateNormalizedRequest(
const std::string& age,
const std::string& nonce) {
static const std::string kNewLine = "\n";
const std::string kNewLine = "\n";

std::string normalized_request = age + ":" + nonce + kNewLine;
normalized_request += method_ + kNewLine;
Expand Down
2 changes: 1 addition & 1 deletion net/spdy/spdy_settings_storage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const spdy::SpdySettings& SpdySettingsStorage::Get(
const HostPortPair& host_port_pair) const {
SettingsMap::const_iterator it = settings_map_.find(host_port_pair);
if (it == settings_map_.end()) {
static const spdy::SpdySettings kEmpty;
CR_DEFINE_STATIC_LOCAL(spdy::SpdySettings, kEmpty, ());
return kEmpty;
}
return it->second;
Expand Down
7 changes: 5 additions & 2 deletions net/url_request/url_request.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/lazy_instance.h"
#include "base/memory/singleton.h"
#include "base/message_loop.h"
#include "base/metrics/stats_counters.h"
Expand Down Expand Up @@ -55,11 +56,13 @@ void StripPostSpecificHeaders(HttpRequestHeaders* headers) {
uint64 g_next_url_request_identifier = 1;

// This lock protects g_next_url_request_identifier.
base::Lock g_next_url_request_identifier_lock;
base::LazyInstance<base::Lock,
base::LeakyLazyInstanceTraits<base::Lock> >
g_next_url_request_identifier_lock(base::LINKER_INITIALIZED);

// Returns an prior unused identifier for URL requests.
uint64 GenerateURLRequestIdentifier() {
base::AutoLock lock(g_next_url_request_identifier_lock);
base::AutoLock lock(g_next_url_request_identifier_lock.Get());
return g_next_url_request_identifier++;
}

Expand Down
6 changes: 3 additions & 3 deletions net/url_request/url_request_http_job.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ void URLRequestHttpJob::NotifyHeadersComplete() {

if (SdchManager::Global() &&
SdchManager::Global()->IsInSupportedDomain(request_->url())) {
static const std::string name = "Get-Dictionary";
const std::string name = "Get-Dictionary";
std::string url_text;
void* iter = NULL;
// TODO(jar): We need to not fetch dictionaries the first time they are
Expand Down Expand Up @@ -592,7 +592,7 @@ void URLRequestHttpJob::CookieHandled() {

void URLRequestHttpJob::FetchResponseCookies(
std::vector<std::string>* cookies) {
std::string name = "Set-Cookie";
const std::string name = "Set-Cookie";
std::string value;

void* iter = NULL;
Expand All @@ -614,7 +614,7 @@ void URLRequestHttpJob::ProcessStrictTransportSecurityHeader() {
const bool valid_https =
https && !IsCertStatusError(response_info_->ssl_info.cert_status);

std::string name = "Strict-Transport-Security";
const std::string name = "Strict-Transport-Security";
std::string value;

int max_age;
Expand Down
9 changes: 5 additions & 4 deletions ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,9 @@ void PnaclCoordinator::RunTranslate(int32_t pp_error,
namespace {

// Fake filename for the object file generated by llvm.
const nacl::string kGeneratedObjectFileName =
nacl::string("___PNACL_GENERATED");
nacl::string GeneratedObjectFileName() {
return nacl::string("___PNACL_GENERATED");
}

string_vector LinkResources(const nacl::string& sandbox_isa,
bool withGenerated) {
Expand All @@ -419,7 +420,7 @@ string_vector LinkResources(const nacl::string& sandbox_isa,

// NOTE: order of items == link order.
if (withGenerated) {
results.push_back(kGeneratedObjectFileName);
results.push_back(GeneratedObjectFileName());
}
results.push_back(base_dir + "/libcrt_platform.a");
results.push_back(base_dir + "/libgcc.a");
Expand Down Expand Up @@ -512,7 +513,7 @@ void WINAPI DoLinkThread(void* arg) {
link_file + ") failed.");
}
// Also map the file name to descriptor.
if (i->compare(kGeneratedObjectFileName) == 0) {
if (i->compare(GeneratedObjectFileName()) == 0) {
SrpcParams dummy_params2;
if (!PnaclSrpcLib::InvokeSrpcMethod(browser_interface,
ld_subprocess,
Expand Down
4 changes: 2 additions & 2 deletions ppapi/proxy/ppb_core_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ namespace proxy {
namespace {

base::MessageLoopProxy* GetMainThreadMessageLoop() {
static scoped_refptr<base::MessageLoopProxy> proxy(
base::MessageLoopProxy::current());
CR_DEFINE_STATIC_LOCAL(scoped_refptr<base::MessageLoopProxy>, proxy,
(base::MessageLoopProxy::current()));
return proxy.get();
}

Expand Down
2 changes: 1 addition & 1 deletion ppapi/proxy/ppb_font_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ PP_Var PPB_Font_Proxy::GetFontFamilies(PP_Instance instance) {
return PP_MakeUndefined();

// Assume the font families don't change, so we can cache the result globally.
static std::string families;
CR_DEFINE_STATIC_LOCAL(std::string, families, ());
if (families.empty()) {
dispatcher->SendToBrowser(
new PpapiHostMsg_PPBFont_GetFontFamilies(&families));
Expand Down
2 changes: 1 addition & 1 deletion printing/backend/print_backend_cups.cc
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ int PrintBackendCUPS::GetDests(cups_dest_t** dests) {
FilePath PrintBackendCUPS::GetPPD(const char* name) {
// cupsGetPPD returns a filename stored in a static buffer in CUPS.
// Protect this code with lock.
static base::Lock ppd_lock;
CR_DEFINE_STATIC_LOCAL(base::Lock, ppd_lock, ());
base::AutoLock ppd_autolock(ppd_lock);
FilePath ppd_path;
const char* ppd_file_path = NULL;
Expand Down
22 changes: 13 additions & 9 deletions printing/pdf_metafile_cg_mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "printing/pdf_metafile_cg_mac.h"

#include "base/file_path.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/mac/mac_util.h"
#include "base/mac/scoped_cftyperef.h"
Expand Down Expand Up @@ -34,7 +35,10 @@ namespace {
// single-process mode. TODO(avi): This Apple bug appears fixed in 10.7; when
// 10.7 is the minimum required version for Chromium, remove this hack.

base::ThreadLocalPointer<struct __CFSet> thread_pdf_docs;
base::LazyInstance<
base::ThreadLocalPointer<struct __CFSet>,
base::LeakyLazyInstanceTraits<base::ThreadLocalPointer<struct __CFSet> > >
thread_pdf_docs(base::LINKER_INITIALIZED);

} // namespace

Expand All @@ -43,24 +47,24 @@ namespace printing {
PdfMetafileCg::PdfMetafileCg()
: page_is_open_(false),
thread_pdf_docs_owned_(false) {
if (!thread_pdf_docs.Get() && base::mac::IsOSSnowLeopardOrEarlier()) {
if (!thread_pdf_docs.Pointer()->Get() &&
base::mac::IsOSSnowLeopardOrEarlier()) {
thread_pdf_docs_owned_ = true;
thread_pdf_docs.Set(CFSetCreateMutable(kCFAllocatorDefault,
0,
&kCFTypeSetCallBacks));
thread_pdf_docs.Pointer()->Set(
CFSetCreateMutable(kCFAllocatorDefault, 0, &kCFTypeSetCallBacks));
}
}

PdfMetafileCg::~PdfMetafileCg() {
DCHECK(thread_checker_.CalledOnValidThread());
if (pdf_doc_ && thread_pdf_docs.Get()) {
if (pdf_doc_ && thread_pdf_docs.Pointer()->Get()) {
// Transfer ownership to the pool.
CFSetAddValue(thread_pdf_docs.Get(), pdf_doc_);
CFSetAddValue(thread_pdf_docs.Pointer()->Get(), pdf_doc_);
}

if (thread_pdf_docs_owned_) {
CFRelease(thread_pdf_docs.Get());
thread_pdf_docs.Set(NULL);
CFRelease(thread_pdf_docs.Pointer()->Get());
thread_pdf_docs.Pointer()->Set(NULL);
}
}

Expand Down

0 comments on commit 2643002

Please sign in to comment.