summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/extension_resource.cc
diff options
context:
space:
mode:
authorfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-25 03:00:49 +0000
committerfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-25 03:00:49 +0000
commit27fbcccda73e7bd257c20f0bbf4b4c31af15c9c2 (patch)
tree1733e5af0ff85042f99f9165c93015e7df6b40c0 /chrome/common/extensions/extension_resource.cc
parenta25fa87a6cf2d10414454d8b8ad75ffeb13fb2cd (diff)
downloadchromium_src-27fbcccda73e7bd257c20f0bbf4b4c31af15c9c2.zip
chromium_src-27fbcccda73e7bd257c20f0bbf4b4c31af15c9c2.tar.gz
chromium_src-27fbcccda73e7bd257c20f0bbf4b4c31af15c9c2.tar.bz2
Ensure all callers to GetFilePath are on the File thread
by DCHECKing based on the thread type. TEST=Extensions and automated tests should work as before BUG=http://crbug.com/38521 Review URL: http://codereview.chromium.org/1293001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42578 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/extension_resource.cc')
-rw-r--r--chrome/common/extensions/extension_resource.cc27
1 files changed, 23 insertions, 4 deletions
diff --git a/chrome/common/extensions/extension_resource.cc b/chrome/common/extensions/extension_resource.cc
index 8eed2e9..eda2d26 100644
--- a/chrome/common/extensions/extension_resource.cc
+++ b/chrome/common/extensions/extension_resource.cc
@@ -7,6 +7,10 @@
#include "base/file_util.h"
#include "base/logging.h"
+PlatformThreadId ExtensionResource::file_thread_id_ = 0;
+
+bool ExtensionResource::check_for_file_thread_ = false;
+
ExtensionResource::ExtensionResource() {
}
@@ -16,7 +20,7 @@ ExtensionResource::ExtensionResource(const FilePath& extension_root,
relative_path_(relative_path) {
}
-const FilePath& ExtensionResource::GetFilePath() const {
+const FilePath& ExtensionResource::GetFilePathOnAnyThreadHack() const {
if (extension_root_.empty() || relative_path_.empty()) {
DCHECK(full_resource_path_.empty());
return full_resource_path_;
@@ -26,13 +30,20 @@ const FilePath& ExtensionResource::GetFilePath() const {
if (!full_resource_path_.empty())
return full_resource_path_;
- full_resource_path_ = GetFilePath(extension_root_, relative_path_);
+ full_resource_path_ =
+ GetFilePathOnAnyThreadHack(extension_root_, relative_path_);
return full_resource_path_;
}
+const FilePath& ExtensionResource::GetFilePath() const {
+ DCHECK(!check_for_file_thread_ ||
+ ExtensionResource::file_thread_id_ == PlatformThread::CurrentId());
+ return GetFilePathOnAnyThreadHack();
+}
+
// static
-FilePath ExtensionResource::GetFilePath(const FilePath& extension_root,
- const FilePath& relative_path) {
+FilePath ExtensionResource::GetFilePathOnAnyThreadHack(
+ const FilePath& extension_root, const FilePath& relative_path) {
// We need to resolve the parent references in the extension_root
// path on its own because IsParent doesn't like parent references.
FilePath clean_extension_root(extension_root);
@@ -57,6 +68,14 @@ FilePath ExtensionResource::GetFilePath(const FilePath& extension_root,
return FilePath();
}
+// static
+FilePath ExtensionResource::GetFilePath(
+ const FilePath& extension_root, const FilePath& relative_path) {
+ DCHECK(!check_for_file_thread_ ||
+ ExtensionResource::file_thread_id_ == PlatformThread::CurrentId());
+ return GetFilePathOnAnyThreadHack(extension_root, relative_path);
+}
+
// Unit-testing helpers.
FilePath::StringType ExtensionResource::NormalizeSeperators(
FilePath::StringType path) const {