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

Unified Diff: chrome/browser/icon_loader.h

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 | « no previous file | chrome/browser/icon_loader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/icon_loader.h
diff --git a/chrome/browser/icon_loader.h b/chrome/browser/icon_loader.h
index b2db32545cc1721a00cafc7d9c4e35cf62092785..4276d75987744ea9b1902fcdc303f976eac2410c 100644
--- a/chrome/browser/icon_loader.h
+++ b/chrome/browser/icon_loader.h
@@ -8,9 +8,9 @@
#include <memory>
#include <string>
+#include "base/callback.h"
#include "base/files/file_path.h"
#include "base/macros.h"
-#include "base/memory/ref_counted.h"
#include "base/single_thread_task_runner.h"
#include "build/build_config.h"
#include "content/public/browser/browser_thread.h"
@@ -22,7 +22,7 @@
// thread. Returns the icon in the form of an ImageSkia.
//
////////////////////////////////////////////////////////////////////////////////
-class IconLoader : public base::RefCountedThreadSafe<IconLoader> {
+class IconLoader {
public:
// An IconGroup is a class of files that all share the same icon. For all
// platforms but Windows, and for most files on Windows, it is the file type
@@ -39,31 +39,22 @@ class IconLoader : public base::RefCountedThreadSafe<IconLoader> {
ALL, // All sizes available
};
- class Delegate {
- public:
- // Invoked when an icon has been read. |source| is the IconLoader. If the
- // icon has been successfully loaded, |result| is non-null. |group| is the
- // determined group from the original requested path.
- virtual void OnImageLoaded(IconLoader* source,
- std::unique_ptr<gfx::Image> result,
- const IconGroup& group) = 0;
-
- protected:
- virtual ~Delegate() {}
- };
+ // The callback invoked when an icon has been read. The parameters are:
+ // - The IconLoader.
+ // - The icon that was loaded, or null if there was a failure to load it.
+ // - The determined group from the original requested path.
+ using IconLoadedCallback = base::OnceCallback<
+ void(IconLoader*, std::unique_ptr<gfx::Image>, const IconGroup&)>;
IconLoader(const base::FilePath& file_path,
IconSize size,
- Delegate* delegate);
+ IconLoadedCallback callback);
+ ~IconLoader();
// Start reading the icon on the file thread.
void Start();
private:
- friend class base::RefCountedThreadSafe<IconLoader>;
-
- virtual ~IconLoader();
-
// Given a file path, get the group for the given file.
static IconGroup GroupForFilepath(const base::FilePath& file_path);
@@ -74,8 +65,6 @@ class IconLoader : public base::RefCountedThreadSafe<IconLoader> {
void OnReadGroup();
void ReadIcon();
- void NotifyDelegate();
-
// The task runner object of the thread in which we notify the delegate.
scoped_refptr<base::SingleThreadTaskRunner> target_task_runner_;
@@ -87,7 +76,7 @@ class IconLoader : public base::RefCountedThreadSafe<IconLoader> {
std::unique_ptr<gfx::Image> image_;
- Delegate* delegate_;
+ IconLoadedCallback callback_;
DISALLOW_COPY_AND_ASSIGN(IconLoader);
};
« no previous file with comments | « no previous file | chrome/browser/icon_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698