summaryrefslogtreecommitdiffstats
path: root/chrome/browser/icon_loader.h
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-07 20:42:24 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-07 20:42:24 +0000
commit46728b1ff43220f8515deba08a60e079d193bf4c (patch)
tree0e1d2ccc770c132576c16acb245a0c5c277e835c /chrome/browser/icon_loader.h
parent6b16d779369be1df91ab891e15f9a7e5fe7bce30 (diff)
downloadchromium_src-46728b1ff43220f8515deba08a60e079d193bf4c.zip
chromium_src-46728b1ff43220f8515deba08a60e079d193bf4c.tar.gz
chromium_src-46728b1ff43220f8515deba08a60e079d193bf4c.tar.bz2
Windows icon loader refactor in preparation for port.
Review URL: http://codereview.chromium.org/115056 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15577 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/icon_loader.h')
-rw-r--r--chrome/browser/icon_loader.h72
1 files changed, 12 insertions, 60 deletions
diff --git a/chrome/browser/icon_loader.h b/chrome/browser/icon_loader.h
index ff1c5a4..a02c6ba 100644
--- a/chrome/browser/icon_loader.h
+++ b/chrome/browser/icon_loader.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,25 +9,17 @@
#include "base/basictypes.h"
#include "base/file_path.h"
-
-namespace {
-class IconLoaderProcessor;
-}
+#include "base/ref_counted.h"
class SkBitmap;
////////////////////////////////////////////////////////////////////////////////
//
// A facility to read a file containing an icon asynchronously in the IO
-// thread. Clients has the option to get the icon in the form of two HICON
-// handles (one for a small icon size and one for a large icon) or in the form
-// of an SkBitmap.
-//
-// This class currently only supports reading .ico files. Please extend as
-// needed.
+// thread. Returns the icon in the form of an SkBitmap.
//
////////////////////////////////////////////////////////////////////////////////
-class IconLoader {
+class IconLoader : public base::RefCountedThreadSafe<IconLoader> {
public:
enum IconSize {
SMALL = 0, // 16x16
@@ -40,61 +32,21 @@ class IconLoader {
// Invoked when an icon has been read. |source| is the IconLoader. If the
// icon has been successfully loaded, result is non-null. This method must
// return true if it is taking ownership of the returned bitmap.
- virtual bool OnSkBitmapLoaded(IconLoader* source, SkBitmap* result) = 0;
+ virtual bool OnBitmapLoaded(IconLoader* source, SkBitmap* result) = 0;
};
- // Create a new IconLoader that loads the icon from the data at contained in
- // the file at |path|.
- static IconLoader* CreateIconLoaderForFile(const FilePath& path,
- Delegate* delegate);
-
- // Create a new IconLoader that loads the icon in the resource of the file
- // at |path|. This is used with .exe/.dll files.
- // Note that this generates a SkBitmap (and consequently OnSkBitmapLoaded is
- // invoked on the delegate once the load has completed).
- static IconLoader* CreateIconLoaderForFileResource(const FilePath& path,
- IconSize size,
- Delegate* delegate);
+ IconLoader() { }
- ~IconLoader();
+ virtual ~IconLoader() { }
- // Start the read operation
- void Start();
+ // Start reading the icon on the file thread.
+ virtual void Start() = 0;
- // Cancel the read operation. The delegate will no longer be contacted. Call
- // this method if you need to delete the delegate.
- void Cancel();
+ // Factory method for returning a platform specific IconLoad.
+ static IconLoader* Create(const FilePath& path, IconSize size,
+ Delegate* delegate);
private:
- friend class IconLoaderProcessor;
-
- // Use the factory methods CreateIconLoader* instead of using this constructor
- IconLoader(const FilePath& path,
- bool from_resource,
- IconSize size,
- Delegate* delegate);
-
- // Invoked by the processor when the file has been read and an SkBitmap
- // object was requested.
- bool OnLoadComplete(SkBitmap* result);
-
- // The path.
- FilePath path_;
-
- // The delegate.
- Delegate* delegate_;
-
- // Whether we are loading the icon from the resource in the file (if false,
- // the icon is simply loaded from the file content).
- bool loading_from_resource_;
-
- // The size of the icon that should be loaded from the file resource.
- // Not used if loading_from_resource_ is false.
- IconSize icon_size_;
-
- // The underlying object performing the read.
- IconLoaderProcessor* processor_;
-
DISALLOW_COPY_AND_ASSIGN(IconLoader);
};