diff options
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/extensions/extension.cc | 4 | ||||
-rw-r--r-- | chrome/common/extensions/extension.h | 14 | ||||
-rw-r--r-- | chrome/common/extensions/extension_resource.cc | 12 | ||||
-rw-r--r-- | chrome/common/extensions/extension_resource.h | 4 |
4 files changed, 21 insertions, 13 deletions
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc index 63d0b28..7e60ee4 100644 --- a/chrome/common/extensions/extension.cc +++ b/chrome/common/extensions/extension.cc @@ -851,6 +851,8 @@ void Extension::DecodeIcon(Extension* extension, void Extension::DecodeIconFromPath(const FilePath& icon_path, Icons icon_size, scoped_ptr<SkBitmap>* result) { + ExtensionResource::CheckFileAccessFromFileThread(); + if (icon_path.empty()) return; @@ -1492,8 +1494,8 @@ void Extension::SetCachedImage(const ExtensionResource& source, DCHECK(source.extension_root() == path()); // The resource must come from // this extension. image_cache_[source.relative_path()] = image; - } + bool Extension::HasCachedImage(const ExtensionResource& source) { DCHECK(source.extension_root() == path()); // The resource must come from // this extension. diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h index 7559162..165436a 100644 --- a/chrome/common/extensions/extension.h +++ b/chrome/common/extensions/extension.h @@ -187,20 +187,18 @@ class Extension { static bool IsPrivilegeIncrease(Extension* old_extension, Extension* new_extension); - // *** HITS THE FILESYSTEM. Do not call on UI thread! *** // Given an extension and icon size, read it if present and decode it into - // result. - // NOTE: If you need the icon on the UI thread, please use the - // ImageLoadingTracker, which uses the File thread internally to decode. + // result. In the browser process, this will DCHECK if not called on the + // file thread. To easily load extension images on the UI thread, see + // ImageLoadingTracker. static void DecodeIcon(Extension* extension, Icons icon_size, scoped_ptr<SkBitmap>* result); - // *** HITS THE FILESYSTEM. Do not call on UI thread! *** // Given an icon_path and icon size, read it if present and decode it into - // result. - // NOTE: If you need the icon on the UI thread, please use the - // ImageLoadingTracker, which uses the File thread internally to decode. + // result. In the browser process, this will DCHECK if not called on the + // file thread. To easily load extension images on the UI thread, see + // ImageLoadingTracker. static void DecodeIconFromPath(const FilePath& icon_path, Icons icon_size, scoped_ptr<SkBitmap>* result); diff --git a/chrome/common/extensions/extension_resource.cc b/chrome/common/extensions/extension_resource.cc index eda2d26..eb5b3626 100644 --- a/chrome/common/extensions/extension_resource.cc +++ b/chrome/common/extensions/extension_resource.cc @@ -36,8 +36,7 @@ const FilePath& ExtensionResource::GetFilePathOnAnyThreadHack() const { } const FilePath& ExtensionResource::GetFilePath() const { - DCHECK(!check_for_file_thread_ || - ExtensionResource::file_thread_id_ == PlatformThread::CurrentId()); + ExtensionResource::CheckFileAccessFromFileThread(); return GetFilePathOnAnyThreadHack(); } @@ -71,11 +70,16 @@ FilePath ExtensionResource::GetFilePathOnAnyThreadHack( // static FilePath ExtensionResource::GetFilePath( const FilePath& extension_root, const FilePath& relative_path) { - DCHECK(!check_for_file_thread_ || - ExtensionResource::file_thread_id_ == PlatformThread::CurrentId()); + CheckFileAccessFromFileThread(); return GetFilePathOnAnyThreadHack(extension_root, relative_path); } +// static +void ExtensionResource::CheckFileAccessFromFileThread() { + DCHECK(!check_for_file_thread_ || + file_thread_id_ == PlatformThread::CurrentId()); +} + // Unit-testing helpers. FilePath::StringType ExtensionResource::NormalizeSeperators( FilePath::StringType path) const { diff --git a/chrome/common/extensions/extension_resource.h b/chrome/common/extensions/extension_resource.h index 755c959..8856414 100644 --- a/chrome/common/extensions/extension_resource.h +++ b/chrome/common/extensions/extension_resource.h @@ -46,6 +46,10 @@ class ExtensionResource { check_for_file_thread_ = true; } + // Checks whether we are running on the file thread and DCHECKs if not. Relies + // on set_file_thread_id being called first, otherwise, it will not DCHECK. + static void CheckFileAccessFromFileThread(); + // Getters const FilePath& extension_root() const { return extension_root_; } const FilePath& relative_path() const { return relative_path_; } |