blob: a02c6bae8b081ac8bf0d351b77a481a556dcfa67 [file] [log] [blame]
[email protected]46728b1f2009-05-07 20:42:241// Copyright (c) 2009 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
[email protected]7ced67af2009-04-14 23:25:165#ifndef CHROME_BROWSER_ICON_LOADER_H_
6#define CHROME_BROWSER_ICON_LOADER_H_
initial.commit09911bf2008-07-26 23:55:297
initial.commit09911bf2008-07-26 23:55:298#include <string>
initial.commit09911bf2008-07-26 23:55:299
[email protected]56d01f62009-03-12 22:41:5410#include "base/basictypes.h"
[email protected]7ced67af2009-04-14 23:25:1611#include "base/file_path.h"
[email protected]46728b1f2009-05-07 20:42:2412#include "base/ref_counted.h"
initial.commit09911bf2008-07-26 23:55:2913
14class SkBitmap;
15
16////////////////////////////////////////////////////////////////////////////////
17//
18// A facility to read a file containing an icon asynchronously in the IO
[email protected]46728b1f2009-05-07 20:42:2419// thread. Returns the icon in the form of an SkBitmap.
initial.commit09911bf2008-07-26 23:55:2920//
21////////////////////////////////////////////////////////////////////////////////
[email protected]46728b1f2009-05-07 20:42:2422class IconLoader : public base::RefCountedThreadSafe<IconLoader> {
initial.commit09911bf2008-07-26 23:55:2923 public:
initial.commit09911bf2008-07-26 23:55:2924 enum IconSize {
25 SMALL = 0, // 16x16
26 NORMAL, // 32x32
27 LARGE
28 };
29
30 class Delegate {
31 public:
32 // Invoked when an icon has been read. |source| is the IconLoader. If the
33 // icon has been successfully loaded, result is non-null. This method must
34 // return true if it is taking ownership of the returned bitmap.
[email protected]46728b1f2009-05-07 20:42:2435 virtual bool OnBitmapLoaded(IconLoader* source, SkBitmap* result) = 0;
initial.commit09911bf2008-07-26 23:55:2936 };
37
[email protected]46728b1f2009-05-07 20:42:2438 IconLoader() { }
initial.commit09911bf2008-07-26 23:55:2939
[email protected]46728b1f2009-05-07 20:42:2440 virtual ~IconLoader() { }
initial.commit09911bf2008-07-26 23:55:2941
[email protected]46728b1f2009-05-07 20:42:2442 // Start reading the icon on the file thread.
43 virtual void Start() = 0;
initial.commit09911bf2008-07-26 23:55:2944
[email protected]46728b1f2009-05-07 20:42:2445 // Factory method for returning a platform specific IconLoad.
46 static IconLoader* Create(const FilePath& path, IconSize size,
47 Delegate* delegate);
initial.commit09911bf2008-07-26 23:55:2948
49 private:
[email protected]7ced67af2009-04-14 23:25:1650 DISALLOW_COPY_AND_ASSIGN(IconLoader);
initial.commit09911bf2008-07-26 23:55:2951};
52
[email protected]7ced67af2009-04-14 23:25:1653#endif // CHROME_BROWSER_ICON_LOADER_H_