| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/common/extensions/extension_resource.h" | 5 #include "chrome/common/extensions/extension_resource.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/thread_restrictions.h" |
| 9 | 10 |
| 10 PlatformThreadId ExtensionResource::file_thread_id_ = 0; | 11 PlatformThreadId ExtensionResource::file_thread_id_ = 0; |
| 11 | 12 |
| 12 bool ExtensionResource::check_for_file_thread_ = false; | 13 bool ExtensionResource::check_for_file_thread_ = false; |
| 13 | 14 |
| 14 ExtensionResource::ExtensionResource() { | 15 ExtensionResource::ExtensionResource() { |
| 15 } | 16 } |
| 16 | 17 |
| 17 ExtensionResource::ExtensionResource(const std::string& extension_id, | 18 ExtensionResource::ExtensionResource(const std::string& extension_id, |
| 18 const FilePath& extension_root, | 19 const FilePath& extension_root, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 38 } | 39 } |
| 39 | 40 |
| 40 const FilePath& ExtensionResource::GetFilePath() const { | 41 const FilePath& ExtensionResource::GetFilePath() const { |
| 41 ExtensionResource::CheckFileAccessFromFileThread(); | 42 ExtensionResource::CheckFileAccessFromFileThread(); |
| 42 return GetFilePathOnAnyThreadHack(); | 43 return GetFilePathOnAnyThreadHack(); |
| 43 } | 44 } |
| 44 | 45 |
| 45 // static | 46 // static |
| 46 FilePath ExtensionResource::GetFilePathOnAnyThreadHack( | 47 FilePath ExtensionResource::GetFilePathOnAnyThreadHack( |
| 47 const FilePath& extension_root, const FilePath& relative_path) { | 48 const FilePath& extension_root, const FilePath& relative_path) { |
| 49 // This function is a hack, and causes us to block the IO thread. |
| 50 // Fixing |
| 51 // http://code.google.com/p/chromium/issues/detail?id=59849 |
| 52 // would also fix this. Suppress the error for now. |
| 53 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 54 |
| 48 // We need to resolve the parent references in the extension_root | 55 // We need to resolve the parent references in the extension_root |
| 49 // path on its own because IsParent doesn't like parent references. | 56 // path on its own because IsParent doesn't like parent references. |
| 50 FilePath clean_extension_root(extension_root); | 57 FilePath clean_extension_root(extension_root); |
| 51 if (!file_util::AbsolutePath(&clean_extension_root)) | 58 if (!file_util::AbsolutePath(&clean_extension_root)) |
| 52 return FilePath(); | 59 return FilePath(); |
| 53 | 60 |
| 54 FilePath full_path = clean_extension_root.Append(relative_path); | 61 FilePath full_path = clean_extension_root.Append(relative_path); |
| 55 | 62 |
| 56 // We must resolve the absolute path of the combined path when | 63 // We must resolve the absolute path of the combined path when |
| 57 // the relative path contains references to a parent folder (i.e., '..'). | 64 // the relative path contains references to a parent folder (i.e., '..'). |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // Make sure we have a cached value to test against... | 106 // Make sure we have a cached value to test against... |
| 100 if (full_resource_path_.empty()) | 107 if (full_resource_path_.empty()) |
| 101 GetFilePath(); | 108 GetFilePath(); |
| 102 if (NormalizeSeperators(path.value()) == | 109 if (NormalizeSeperators(path.value()) == |
| 103 NormalizeSeperators(full_resource_path_.value())) { | 110 NormalizeSeperators(full_resource_path_.value())) { |
| 104 return true; | 111 return true; |
| 105 } else { | 112 } else { |
| 106 return false; | 113 return false; |
| 107 } | 114 } |
| 108 } | 115 } |
| OLD | NEW |