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) { |