| Index: chrome/browser/themes/browser_theme_pack.h
|
| diff --git a/chrome/browser/themes/browser_theme_pack.h b/chrome/browser/themes/browser_theme_pack.h
|
| index cc975cc1ce193ac82335a12617ad942aebb6f1dd..d527e97342d83390848ffa9430e6763c5736596c 100644
|
| --- a/chrome/browser/themes/browser_theme_pack.h
|
| +++ b/chrome/browser/themes/browser_theme_pack.h
|
| @@ -53,11 +53,11 @@ class DataPack;
|
| // will trip our IO on the UI thread detector.
|
| class BrowserThemePack : public CustomThemeSupplier {
|
| public:
|
| - // Builds the theme pack from all data from |extension|. This is often done
|
| - // on a separate thread as it takes so long. This can fail and return NULL in
|
| - // the case where the theme has invalid data.
|
| - static scoped_refptr<BrowserThemePack> BuildFromExtension(
|
| - const extensions::Extension* extension);
|
| + // Builds the theme from |extension| into |pack|. This may be done on a
|
| + // separate thread as it takes so long. This can fail in the case where the
|
| + // theme has invalid data, in which case |pack->is_valid()| will be false.
|
| + static void BuildFromExtension(const extensions::Extension* extension,
|
| + scoped_refptr<BrowserThemePack> pack);
|
|
|
| // Builds the theme pack from a previously performed WriteToDisk(). This
|
| // operation should be relatively fast, as it should be an mmap() and some
|
| @@ -69,6 +69,11 @@ class BrowserThemePack : public CustomThemeSupplier {
|
| // in the data pack.
|
| static bool IsPersistentImageID(int id);
|
|
|
| + // Default. Everything is empty.
|
| + BrowserThemePack();
|
| +
|
| + bool is_valid() const { return is_valid_; }
|
| +
|
| // Builds a data pack on disk at |path| for future quick loading by
|
| // BuildFromDataPack(). Often (but not always) called from the file thread;
|
| // implementation should be threadsafe because neither thread will write to
|
| @@ -103,9 +108,6 @@ class BrowserThemePack : public CustomThemeSupplier {
|
| // Maps image ids to maps of scale factors to file paths.
|
| typedef std::map<int, ScaleFactorToFileMap> FilePathMap;
|
|
|
| - // Default. Everything is empty.
|
| - BrowserThemePack();
|
| -
|
| ~BrowserThemePack() override;
|
|
|
| // Builds a header ready to write to disk.
|
| @@ -217,7 +219,7 @@ class BrowserThemePack : public CustomThemeSupplier {
|
|
|
| // theme_id without NULL terminator.
|
| uint8_t theme_id[16];
|
| - } *header_;
|
| + }* header_ = nullptr;
|
|
|
| // The remaining structs represent individual entries in an array. For the
|
| // following three structs, BrowserThemePack will either allocate an array or
|
| @@ -227,21 +229,21 @@ class BrowserThemePack : public CustomThemeSupplier {
|
| double h;
|
| double s;
|
| double l;
|
| - } *tints_;
|
| + }* tints_ = nullptr;
|
|
|
| struct ColorPair {
|
| int32_t id;
|
| SkColor color;
|
| - } *colors_;
|
| + }* colors_ = nullptr;
|
|
|
| struct DisplayPropertyPair {
|
| int32_t id;
|
| int32_t property;
|
| - } *display_properties_;
|
| + }* display_properties_ = nullptr;
|
|
|
| // A list of included source images. A pointer to a -1 terminated array of
|
| // our persistent IDs.
|
| - int* source_images_;
|
| + int* source_images_ = nullptr;
|
| #pragma pack(pop)
|
|
|
| // The scale factors represented by the images in the theme pack.
|
| @@ -254,9 +256,8 @@ class BrowserThemePack : public CustomThemeSupplier {
|
| RawImages image_memory_;
|
|
|
| // Loaded images. These are loaded from |image_memory_|, from |data_pack_|,
|
| - // and by BuildFromExtension(). These images should only be accessed on the UI
|
| - // thread.
|
| - ImageCache images_on_ui_thread_;
|
| + // and by BuildFromExtension().
|
| + ImageCache images_;
|
|
|
| // Cache of images created in BuildFromExtension(). Once the theme pack is
|
| // created, this cache should only be accessed on the file thread. There
|
| @@ -264,6 +265,10 @@ class BrowserThemePack : public CustomThemeSupplier {
|
| // or vice versa.
|
| ImageCache images_on_file_thread_;
|
|
|
| + // Whether the theme pack has been succesfully initialized and is ready to
|
| + // use.
|
| + bool is_valid_ = false;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(BrowserThemePack);
|
| };
|
|
|
|
|