Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(320)

Unified Diff: net/tools/fetch/fetch_client.cc

Issue 5682008: Make members of Singleton<T> private and only visible to the singleton type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/tools/fetch/fetch_client.cc
diff --git a/net/tools/fetch/fetch_client.cc b/net/tools/fetch/fetch_client.cc
index 138bed3b2ea9f4721cd8012a042088ae4f7417c2..800f3070d8b1e0c8fbe61fcc365e783acbcd7f9e 100644
--- a/net/tools/fetch/fetch_client.cc
+++ b/net/tools/fetch/fetch_client.cc
@@ -6,9 +6,9 @@
#include "base/at_exit.h"
#include "base/command_line.h"
+#include "base/lazy_instance.h"
#include "base/message_loop.h"
#include "base/metrics/stats_counters.h"
-#include "base/singleton.h"
#include "base/string_number_conversions.h"
#include "base/string_util.h"
#include "net/base/completion_callback.h"
@@ -47,6 +47,8 @@ class Driver {
int clients_;
};
+static base::LazyInstance<Driver> g_driver(base::LINKER_INITIALIZED);
+
// A network client
class Client {
public:
@@ -60,7 +62,7 @@ class Client {
int rv = factory->CreateTransaction(&transaction_);
DCHECK_EQ(net::OK, rv);
buffer_->AddRef();
- driver_->ClientStarted();
+ g_driver.Get().ClientStarted();
request_info_.url = url_;
request_info_.method = "GET";
int state = transaction_->Start(
@@ -101,7 +103,7 @@ class Client {
void OnRequestComplete(int result) {
static base::StatsCounter requests("FetchClient.requests");
requests.Increment();
- driver_->ClientStopped();
+ g_driver.Get().ClientStopped();
printf(".");
}
@@ -112,7 +114,6 @@ class Client {
scoped_refptr<net::IOBuffer> buffer_;
net::CompletionCallbackImpl<Client> connect_callback_;
net::CompletionCallbackImpl<Client> read_callback_;
- Singleton<Driver> driver_;
};
int main(int argc, char**argv) {

Powered by Google App Engine
This is Rietveld 408576698