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

Unified Diff: net/disk_cache/file_win.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/disk_cache/file_win.cc
diff --git a/net/disk_cache/file_win.cc b/net/disk_cache/file_win.cc
index 5b01224002a474a3414d34029346fe6f4ca7e781..737b8e833207b5c9841efb09d0a9100fa8b209c8 100644
--- a/net/disk_cache/file_win.cc
+++ b/net/disk_cache/file_win.cc
@@ -5,8 +5,8 @@
#include "net/disk_cache/file.h"
#include "base/file_path.h"
+#include "base/lazy_instance.h"
#include "base/message_loop.h"
-#include "base/singleton.h"
#include "net/disk_cache/disk_cache.h"
namespace {
@@ -33,6 +33,9 @@ class CompletionHandler : public MessageLoopForIO::IOHandler {
DWORD actual_bytes, DWORD error);
};
+static base::LazyInstance<CompletionHandler> g_completion_handler(
+ base::LINKER_INITIALIZED);
+
void CompletionHandler::OnIOCompleted(MessageLoopForIO::IOContext* context,
DWORD actual_bytes, DWORD error) {
MyOverlapped* data = reinterpret_cast<MyOverlapped*>(context);
@@ -52,7 +55,7 @@ void CompletionHandler::OnIOCompleted(MessageLoopForIO::IOContext* context,
MyOverlapped::MyOverlapped(disk_cache::File* file, size_t offset,
disk_cache::FileIOCallback* callback) {
memset(this, 0, sizeof(*this));
- context_.handler = Singleton<CompletionHandler>::get();
+ context_.handler = g_completion_handler.Pointer();
context_.overlapped.Offset = static_cast<DWORD>(offset);
file_ = file;
callback_ = callback;
@@ -81,7 +84,7 @@ bool File::Init(const FilePath& name) {
return false;
MessageLoopForIO::current()->RegisterIOHandler(
- platform_file_, Singleton<CompletionHandler>::get());
+ platform_file_, g_completion_handler.Pointer());
init_ = true;
sync_platform_file_ = CreateFile(name.value().c_str(), access, sharing, NULL,
@@ -255,7 +258,7 @@ void File::WaitForPendingIO(int* num_pending_io) {
while (*num_pending_io) {
// Asynchronous IO operations may be in flight and the completion may end
// up calling us back so let's wait for them.
- MessageLoopForIO::IOHandler* handler = Singleton<CompletionHandler>::get();
+ MessageLoopForIO::IOHandler* handler = g_completion_handler.Pointer();
MessageLoopForIO::current()->WaitForIOCompletion(100, handler);
}
}

Powered by Google App Engine
This is Rietveld 408576698