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

Unified Diff: chrome/browser/image_decoder.cc

Issue 2667993003: Don't use LazyInstance in chrome/browser/image_decoder.* (Closed)
Patch Set: auto* Created 3 years, 10 months 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
« no previous file with comments | « chrome/browser/image_decoder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/image_decoder.cc
diff --git a/chrome/browser/image_decoder.cc b/chrome/browser/image_decoder.cc
index 12306d8392893fee0bb4b68d2e09de2ea2094e51..94b9c0d6b16bf73d69c057bb57418c6553cc7b34 100644
--- a/chrome/browser/image_decoder.cc
+++ b/chrome/browser/image_decoder.cc
@@ -8,7 +8,6 @@
#include "base/bind.h"
#include "base/callback.h"
-#include "base/lazy_instance.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "content/public/browser/browser_thread.h"
@@ -20,9 +19,6 @@
namespace {
-// static, Leaky to allow access from any thread.
-base::LazyInstance<ImageDecoder>::Leaky g_decoder = LAZY_INSTANCE_INITIALIZER;
-
const int64_t kMaxImageSizeInBytes =
static_cast<int64_t>(IPC::Channel::kMaximumMessageSize);
@@ -95,9 +91,11 @@ ImageDecoder::ImageRequest::~ImageRequest() {
ImageDecoder::Cancel(this);
}
-ImageDecoder::ImageDecoder() : image_request_id_counter_(0) {}
-
-ImageDecoder::~ImageDecoder() {}
+// static
+ImageDecoder* ImageDecoder::GetInstance() {
+ static auto* image_decoder = new ImageDecoder();
+ return image_decoder;
+}
// static
void ImageDecoder::Start(ImageRequest* image_request,
@@ -117,8 +115,8 @@ void ImageDecoder::StartWithOptions(ImageRequest* image_request,
std::vector<uint8_t> image_data,
ImageCodec image_codec,
bool shrink_to_fit) {
- g_decoder.Get().StartWithOptionsImpl(image_request, std::move(image_data),
- image_codec, shrink_to_fit);
+ ImageDecoder::GetInstance()->StartWithOptionsImpl(
+ image_request, std::move(image_data), image_codec, shrink_to_fit);
}
// static
@@ -131,6 +129,8 @@ void ImageDecoder::StartWithOptions(ImageRequest* image_request,
image_codec, shrink_to_fit);
}
+ImageDecoder::ImageDecoder() : image_request_id_counter_(0) {}
+
void ImageDecoder::StartWithOptionsImpl(ImageRequest* image_request,
std::vector<uint8_t> image_data,
ImageCodec image_codec,
@@ -173,7 +173,7 @@ void ImageDecoder::StartWithOptionsImpl(ImageRequest* image_request,
// static
void ImageDecoder::Cancel(ImageRequest* image_request) {
DCHECK(image_request);
- g_decoder.Get().CancelImpl(image_request);
+ ImageDecoder::GetInstance()->CancelImpl(image_request);
}
void ImageDecoder::CancelImpl(ImageRequest* image_request) {
« no previous file with comments | « chrome/browser/image_decoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698