Make gfx::Image instance a local variable.

This follows https://codereview.chromium.org/2709683002
This commit is contained in:
Yury Solovyov 2018-01-08 12:47:25 +03:00
parent c1d68974ab
commit b3743058c0
4 changed files with 18 additions and 12 deletions

View file

@ -5,6 +5,7 @@
#include "chrome/browser/icon_loader.h"
#include "base/bind.h"
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/nix/mime_util_xdg.h"
#include "ui/views/linux_ui/linux_ui.h"
@ -38,14 +39,17 @@ void IconLoader::ReadIcon() {
NOTREACHED();
}
std::unique_ptr<gfx::Image> image;
views::LinuxUI* ui = views::LinuxUI::instance();
if (ui) {
gfx::Image image = ui->GetIconForContentType(group_, size_pixels);
if (!image.IsEmpty())
image_.reset(new gfx::Image(image));
image = base::MakeUnique<gfx::Image>(
ui->GetIconForContentType(group_, size_pixels));
if (image->IsEmpty())
image = nullptr;
}
target_task_runner_->PostTask(
FROM_HERE, base::Bind(callback_, base::Passed(&image_), group_));
FROM_HERE, base::Bind(callback_, base::Passed(&image), group_));
delete this;
}