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

Unified Diff: chrome/browser/icon_loader_auralinux.cc

Issue 2586003002: patch from issue 2577273002 at patchset 20001 (http://crrev.com/2577273002#ps20001)
Patch Set: Convert to OnceCallback, and make it compile at least on Linux. Created 4 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
« no previous file with comments | « chrome/browser/icon_loader.cc ('k') | chrome/browser/icon_loader_chromeos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/icon_loader_auralinux.cc
diff --git a/chrome/browser/icon_loader_auralinux.cc b/chrome/browser/icon_loader_auralinux.cc
index c3b57ed8cfd9c37973be1a3cb5652144e442caf3..461d5d7e9f9e0ec7d72ee4efd6e522e691fd93b3 100644
--- a/chrome/browser/icon_loader_auralinux.cc
+++ b/chrome/browser/icon_loader_auralinux.cc
@@ -45,6 +45,25 @@ void IconLoader::ReadIcon() {
image_.reset(new gfx::Image(image));
}
+ // TODO(jbroman): This should get better once PostTask can take a
+ // OnceCallback, which seems the "right" thing to do.
+ //
+ // The root of the error in doing this the obvious way is that the functor
+ // (first) argument to Bind isn't moved (rather a const& is used, because
+ // running a repeating callback doesn't move from it). We could probably make
+ // it work (by adjusting Invoker<...>::Run to move under some circumstances,
+ // but it'd be a hack.
+ //
+ // This is a hack that does essentially that: it moves the functor like the
+ // arguments are moved, even though that's not really safe if the callback is
+ // invoked more than once.
target_task_runner_->PostTask(
- FROM_HERE, base::Bind(&IconLoader::NotifyDelegate, this));
+ FROM_HERE,
+ base::Bind(
+ [](IconLoadedCallback callback, IconLoader* loader,
+ std::unique_ptr<gfx::Image> image, const IconGroup& group) {
+ std::move(callback).Run(loader, std::move(image), group);
+ },
+ base::Passed(&callback_), base::Unretained(this),
+ base::Passed(&image_), group_));
}
« no previous file with comments | « chrome/browser/icon_loader.cc ('k') | chrome/browser/icon_loader_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698