summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-22 23:07:19 +0000
committerrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-22 23:07:19 +0000
commit2862086530e94dab7ab55e842601661aabd8a408 (patch)
tree31fc3c9027af9d89c1fdfd671cfe1ea1968e0c8c
parent81cbbeba77b50e09cf52c7da09ed5ff88056cd28 (diff)
downloadchromium_src-2862086530e94dab7ab55e842601661aabd8a408.zip
chromium_src-2862086530e94dab7ab55e842601661aabd8a408.tar.gz
chromium_src-2862086530e94dab7ab55e842601661aabd8a408.tar.bz2
Removed the static on all stats macros and changed the static declaration
of StatsCounter, StatsCounterTimer and StatsRate variables to auto. This change would fix possibel race condition during static's initialization in multi-threaded environments. BUG=76980 TEST=unit tests in net, browser and plugins R=jar@chromium.org Review URL: http://codereview.chromium.org/6719011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79065 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/metrics/stats_counters.h4
-rw-r--r--content/browser/tab_contents/tab_contents.cc2
-rw-r--r--net/socket/tcp_client_socket_libevent.cc10
-rw-r--r--net/socket/tcp_client_socket_win.cc12
-rw-r--r--net/spdy/spdy_framer.cc12
-rw-r--r--net/spdy/spdy_session.cc12
-rw-r--r--net/tools/fetch/fetch_client.cc4
-rw-r--r--net/udp/udp_socket_libevent.cc6
-rw-r--r--net/udp/udp_socket_win.cc4
-rw-r--r--webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc4
-rw-r--r--webkit/plugins/npapi/webplugin_delegate_impl_win.cc2
11 files changed, 36 insertions, 36 deletions
diff --git a/base/metrics/stats_counters.h b/base/metrics/stats_counters.h
index 2de2b73..4a93a41 100644
--- a/base/metrics/stats_counters.h
+++ b/base/metrics/stats_counters.h
@@ -46,14 +46,14 @@ namespace base {
//------------------------------------------------------------------------------
// First provide generic macros, which exist in production as well as debug.
#define STATS_COUNTER(name, delta) do { \
- static base::StatsCounter counter(name); \
+ base::StatsCounter counter(name); \
counter.Add(delta); \
} while (0)
#define SIMPLE_STATS_COUNTER(name) STATS_COUNTER(name, 1)
#define RATE_COUNTER(name, duration) do { \
- static base::StatsRate hit_count(name); \
+ base::StatsRate hit_count(name); \
hit_count.AddTime(duration); \
} while (0)
diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc
index 328a051..04034c4 100644
--- a/content/browser/tab_contents/tab_contents.cc
+++ b/content/browser/tab_contents/tab_contents.cc
@@ -1459,7 +1459,7 @@ void TabContents::OnDidFailProvisionalLoadWithError(
void TabContents::OnDidLoadResourceFromMemoryCache(
const GURL& url,
const std::string& security_info) {
- static base::StatsCounter cache("WebKit.CacheHit");
+ base::StatsCounter cache("WebKit.CacheHit");
cache.Increment();
// Send out a notification that we loaded a resource from our memory cache.
diff --git a/net/socket/tcp_client_socket_libevent.cc b/net/socket/tcp_client_socket_libevent.cc
index c94276b..1c7cdc0 100644
--- a/net/socket/tcp_client_socket_libevent.cc
+++ b/net/socket/tcp_client_socket_libevent.cc
@@ -144,7 +144,7 @@ int TCPClientSocketLibevent::Connect(CompletionCallback* callback) {
if (socket_ != kInvalidSocket)
return OK;
- static base::StatsCounter connects("tcp.connect");
+ base::StatsCounter connects("tcp.connect");
connects.Increment();
DCHECK(!waiting_connect());
@@ -346,7 +346,7 @@ int TCPClientSocketLibevent::Read(IOBuffer* buf,
int nread = HANDLE_EINTR(read(socket_, buf->data(), buf_len));
if (nread >= 0) {
- static base::StatsCounter read_bytes("tcp.read_bytes");
+ base::StatsCounter read_bytes("tcp.read_bytes");
read_bytes.Add(nread);
if (nread > 0)
use_history_.set_was_used_to_convey_data();
@@ -385,7 +385,7 @@ int TCPClientSocketLibevent::Write(IOBuffer* buf,
int nwrite = InternalWrite(buf, buf_len);
if (nwrite >= 0) {
- static base::StatsCounter write_bytes("tcp.write_bytes");
+ base::StatsCounter write_bytes("tcp.write_bytes");
write_bytes.Add(nwrite);
if (nwrite > 0)
use_history_.set_was_used_to_convey_data();
@@ -564,7 +564,7 @@ void TCPClientSocketLibevent::DidCompleteRead() {
int result;
if (bytes_transferred >= 0) {
result = bytes_transferred;
- static base::StatsCounter read_bytes("tcp.read_bytes");
+ base::StatsCounter read_bytes("tcp.read_bytes");
read_bytes.Add(bytes_transferred);
if (bytes_transferred > 0)
use_history_.set_was_used_to_convey_data();
@@ -591,7 +591,7 @@ void TCPClientSocketLibevent::DidCompleteWrite() {
int result;
if (bytes_transferred >= 0) {
result = bytes_transferred;
- static base::StatsCounter write_bytes("tcp.write_bytes");
+ base::StatsCounter write_bytes("tcp.write_bytes");
write_bytes.Add(bytes_transferred);
if (bytes_transferred > 0)
use_history_.set_was_used_to_convey_data();
diff --git a/net/socket/tcp_client_socket_win.cc b/net/socket/tcp_client_socket_win.cc
index d33bd40..5315f45 100644
--- a/net/socket/tcp_client_socket_win.cc
+++ b/net/socket/tcp_client_socket_win.cc
@@ -250,7 +250,7 @@ int TCPClientSocketWin::Connect(CompletionCallback* callback) {
if (socket_ != INVALID_SOCKET)
return OK;
- static base::StatsCounter connects("tcp.connect");
+ base::StatsCounter connects("tcp.connect");
connects.Increment();
net_log_.BeginEvent(NetLog::TYPE_TCP_CONNECT,
@@ -515,7 +515,7 @@ int TCPClientSocketWin::Read(IOBuffer* buf,
// false error reports.
// See bug 5297.
base::MemoryDebug::MarkAsInitialized(core_->read_buffer_.buf, num);
- static base::StatsCounter read_bytes("tcp.read_bytes");
+ base::StatsCounter read_bytes("tcp.read_bytes");
read_bytes.Add(num);
if (num > 0)
use_history_.set_was_used_to_convey_data();
@@ -545,7 +545,7 @@ int TCPClientSocketWin::Write(IOBuffer* buf,
DCHECK_GT(buf_len, 0);
DCHECK(!core_->write_iobuffer_);
- static base::StatsCounter writes("tcp.writes");
+ base::StatsCounter writes("tcp.writes");
writes.Increment();
core_->write_buffer_.len = buf_len;
@@ -567,7 +567,7 @@ int TCPClientSocketWin::Write(IOBuffer* buf,
<< " bytes, but " << rv << " bytes reported.";
return ERR_WINSOCK_UNEXPECTED_WRITTEN_BYTES;
}
- static base::StatsCounter write_bytes("tcp.write_bytes");
+ base::StatsCounter write_bytes("tcp.write_bytes");
write_bytes.Add(rv);
if (rv > 0)
use_history_.set_was_used_to_convey_data();
@@ -769,7 +769,7 @@ void TCPClientSocketWin::DidCompleteRead() {
waiting_read_ = false;
core_->read_iobuffer_ = NULL;
if (ok) {
- static base::StatsCounter read_bytes("tcp.read_bytes");
+ base::StatsCounter read_bytes("tcp.read_bytes");
read_bytes.Add(num_bytes);
if (num_bytes > 0)
use_history_.set_was_used_to_convey_data();
@@ -800,7 +800,7 @@ void TCPClientSocketWin::DidCompleteWrite() {
<< " bytes reported.";
rv = ERR_WINSOCK_UNEXPECTED_WRITTEN_BYTES;
} else {
- static base::StatsCounter write_bytes("tcp.write_bytes");
+ base::StatsCounter write_bytes("tcp.write_bytes");
write_bytes.Add(num_bytes);
if (num_bytes > 0)
use_history_.set_was_used_to_convey_data();
diff --git a/net/spdy/spdy_framer.cc b/net/spdy/spdy_framer.cc
index 1bca57d..9958c4c 100644
--- a/net/spdy/spdy_framer.cc
+++ b/net/spdy/spdy_framer.cc
@@ -927,9 +927,9 @@ SpdyFrame* SpdyFramer::CompressFrameWithZStream(const SpdyFrame& frame,
int header_length;
const char* payload;
- static base::StatsCounter compressed_frames("spdy.CompressedFrames");
- static base::StatsCounter pre_compress_bytes("spdy.PreCompressSize");
- static base::StatsCounter post_compress_bytes("spdy.PostCompressSize");
+ base::StatsCounter compressed_frames("spdy.CompressedFrames");
+ base::StatsCounter pre_compress_bytes("spdy.PreCompressSize");
+ base::StatsCounter post_compress_bytes("spdy.PostCompressSize");
if (!enable_compression_)
return DuplicateFrame(frame);
@@ -991,9 +991,9 @@ SpdyFrame* SpdyFramer::DecompressFrameWithZStream(const SpdyFrame& frame,
int header_length;
const char* payload;
- static base::StatsCounter decompressed_frames("spdy.DecompressedFrames");
- static base::StatsCounter pre_decompress_bytes("spdy.PreDeCompressSize");
- static base::StatsCounter post_decompress_bytes("spdy.PostDeCompressSize");
+ base::StatsCounter decompressed_frames("spdy.DecompressedFrames");
+ base::StatsCounter pre_decompress_bytes("spdy.PreDeCompressSize");
+ base::StatsCounter post_decompress_bytes("spdy.PostDeCompressSize");
if (!enable_compression_)
return DuplicateFrame(frame);
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc
index 9776aff..9ab0155 100644
--- a/net/spdy/spdy_session.cc
+++ b/net/spdy/spdy_session.cc
@@ -286,7 +286,7 @@ net::Error SpdySession::InitializeWithSocket(
ClientSocketHandle* connection,
bool is_secure,
int certificate_error_code) {
- static base::StatsCounter spdy_sessions("spdy.sessions");
+ base::StatsCounter spdy_sessions("spdy.sessions");
spdy_sessions.Increment();
state_ = CONNECTED;
@@ -461,7 +461,7 @@ int SpdySession::WriteSynStream(
flags, false, headers.get()));
QueueFrame(syn_frame.get(), priority, stream);
- static base::StatsCounter spdy_requests("spdy.requests");
+ base::StatsCounter spdy_requests("spdy.requests");
spdy_requests.Increment();
streams_initiated_count_++;
@@ -782,8 +782,8 @@ void SpdySession::WriteSocket() {
}
void SpdySession::CloseAllStreams(net::Error status) {
- static base::StatsCounter abandoned_streams("spdy.abandoned_streams");
- static base::StatsCounter abandoned_push_streams(
+ base::StatsCounter abandoned_streams("spdy.abandoned_streams");
+ base::StatsCounter abandoned_push_streams(
"spdy.abandoned_push_streams");
if (!active_streams_.empty())
@@ -932,7 +932,7 @@ void SpdySession::RemoveFromPool() {
scoped_refptr<SpdyStream> SpdySession::GetActivePushStream(
const std::string& path) {
- static base::StatsCounter used_push_streams("spdy.claimed_push_streams");
+ base::StatsCounter used_push_streams("spdy.claimed_push_streams");
PushedStreamMap::iterator it = unclaimed_pushed_streams_.find(path);
if (it != unclaimed_pushed_streams_.end()) {
@@ -1096,7 +1096,7 @@ void SpdySession::OnSyn(const spdy::SpdySynStreamControlFrame& frame,
if (!Respond(*headers, stream))
return;
- static base::StatsCounter push_requests("spdy.pushed_streams");
+ base::StatsCounter push_requests("spdy.pushed_streams");
push_requests.Increment();
}
diff --git a/net/tools/fetch/fetch_client.cc b/net/tools/fetch/fetch_client.cc
index 31e4001..e206e49 100644
--- a/net/tools/fetch/fetch_client.cc
+++ b/net/tools/fetch/fetch_client.cc
@@ -89,7 +89,7 @@ class Client {
}
// Deal with received data here.
- static base::StatsCounter bytes_read("FetchClient.bytes_read");
+ base::StatsCounter bytes_read("FetchClient.bytes_read");
bytes_read.Add(result);
// Issue a read for more data.
@@ -102,7 +102,7 @@ class Client {
}
void OnRequestComplete(int result) {
- static base::StatsCounter requests("FetchClient.requests");
+ base::StatsCounter requests("FetchClient.requests");
requests.Increment();
g_driver.Get().ClientStopped();
printf(".");
diff --git a/net/udp/udp_socket_libevent.cc b/net/udp/udp_socket_libevent.cc
index 6604e7d..85b87c3 100644
--- a/net/udp/udp_socket_libevent.cc
+++ b/net/udp/udp_socket_libevent.cc
@@ -182,7 +182,7 @@ int UDPSocketLibevent::SendToOrWrite(IOBuffer* buf,
int nwrite = InternalSendTo(buf, buf_len, address);
if (nwrite >= 0) {
- static base::StatsCounter write_bytes("udp.write_bytes");
+ base::StatsCounter write_bytes("udp.write_bytes");
write_bytes.Add(nwrite);
return nwrite;
}
@@ -296,7 +296,7 @@ void UDPSocketLibevent::DidCompleteWrite() {
int result = InternalSendTo(write_buf_, write_buf_len_,
send_to_address_.get());
if (result >= 0) {
- static base::StatsCounter write_bytes("udp.write_bytes");
+ base::StatsCounter write_bytes("udp.write_bytes");
write_bytes.Add(result);
} else {
result = MapSystemError(errno);
@@ -330,7 +330,7 @@ int UDPSocketLibevent::InternalRecvFrom(IOBuffer* buf, int buf_len,
int result;
if (bytes_transferred >= 0) {
result = bytes_transferred;
- static base::StatsCounter read_bytes("udp.read_bytes");
+ base::StatsCounter read_bytes("udp.read_bytes");
read_bytes.Add(bytes_transferred);
if (address) {
if (!address->FromSockAddr(addr, addr_len))
diff --git a/net/udp/udp_socket_win.cc b/net/udp/udp_socket_win.cc
index 328f379..2e2271e 100644
--- a/net/udp/udp_socket_win.cc
+++ b/net/udp/udp_socket_win.cc
@@ -263,7 +263,7 @@ void UDPSocketWin::DidCompleteRead() {
}
bool UDPSocketWin::ProcessSuccessfulRead(int num_bytes, IPEndPoint* address) {
- static base::StatsCounter read_bytes("udp.read_bytes");
+ base::StatsCounter read_bytes("udp.read_bytes");
read_bytes.Add(num_bytes);
// Convert address.
@@ -290,7 +290,7 @@ void UDPSocketWin::DidCompleteWrite() {
}
void UDPSocketWin::ProcessSuccessfulWrite(int num_bytes) {
- static base::StatsCounter write_bytes("udp.write_bytes");
+ base::StatsCounter write_bytes("udp.write_bytes");
write_bytes.Add(num_bytes);
}
diff --git a/webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc b/webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc
index 726abc0..9a0fb6b 100644
--- a/webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc
+++ b/webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc
@@ -446,7 +446,7 @@ void WebPluginDelegateImpl::WindowlessPaint(cairo_t* context,
}
// Tell the plugin to paint into the pixmap.
- static base::StatsRate plugin_paint("Plugin.Paint");
+ base::StatsRate plugin_paint("Plugin.Paint");
base::StatsScope<base::StatsRate> scope(plugin_paint);
NPError err = instance()->NPP_HandleEvent(&np_event);
DCHECK_EQ(err, NPERR_NO_ERROR);
@@ -477,7 +477,7 @@ void WebPluginDelegateImpl::WindowlessPaint(cairo_t* context,
event.drawable = GDK_PIXMAP_XID(pixmap_);
// Tell the plugin to paint into the pixmap.
- static base::StatsRate plugin_paint("Plugin.Paint");
+ base::StatsRate plugin_paint("Plugin.Paint");
base::StatsScope<base::StatsRate> scope(plugin_paint);
NPError err = instance()->NPP_HandleEvent(&np_event);
DCHECK_EQ(err, NPERR_NO_ERROR);
diff --git a/webkit/plugins/npapi/webplugin_delegate_impl_win.cc b/webkit/plugins/npapi/webplugin_delegate_impl_win.cc
index 5bfc994..764d6d7 100644
--- a/webkit/plugins/npapi/webplugin_delegate_impl_win.cc
+++ b/webkit/plugins/npapi/webplugin_delegate_impl_win.cc
@@ -1040,7 +1040,7 @@ void WebPluginDelegateImpl::WindowlessPaint(HDC hdc,
// NOTE: NPAPI is not 64bit safe. It puts pointers into 32bit values.
paint_event.wParam = PtrToUlong(hdc);
paint_event.lParam = PtrToUlong(&damage_rect_win);
- static base::StatsRate plugin_paint("Plugin.Paint");
+ base::StatsRate plugin_paint("Plugin.Paint");
base::StatsScope<base::StatsRate> scope(plugin_paint);
instance()->NPP_HandleEvent(&paint_event);
window_.window = old_dc;