diff options
author | Zeno Albisser <zeno.albisser@digia.com> | 2013-11-21 14:09:57 +0100 |
---|---|---|
committer | Andras Becsi <andras.becsi@digia.com> | 2013-11-29 15:14:36 +0100 |
commit | eb32ba6f51d0c21d58cd7d89785285ff8fa64624 (patch) | |
tree | 2c7c940e1dbee81b89d935626110816b494aa32c /chromium/webkit | |
parent | 9427c1a0222ebd67efef1a2c7990a0fa5c9aac84 (diff) | |
download | qtwebengine-chromium-eb32ba6f51d0c21d58cd7d89785285ff8fa64624.tar.gz |
Update chromium to branch 1599.
Change-Id: I04e775a946a208bb4500d3b722bcb05c82b9d7cb
Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'chromium/webkit')
51 files changed, 1561 insertions, 265 deletions
diff --git a/chromium/webkit/browser/fileapi/file_permission_policy.cc b/chromium/webkit/browser/fileapi/file_permission_policy.cc index 164548791db..6f1a36c3440 100644 --- a/chromium/webkit/browser/fileapi/file_permission_policy.cc +++ b/chromium/webkit/browser/fileapi/file_permission_policy.cc @@ -21,14 +21,17 @@ const int kWriteFilePermissions = base::PLATFORM_FILE_OPEN | const int kCreateFilePermissions = base::PLATFORM_FILE_CREATE; -const int kOpenFilePermissions = base::PLATFORM_FILE_CREATE | - base::PLATFORM_FILE_OPEN_ALWAYS | - base::PLATFORM_FILE_CREATE_ALWAYS | - base::PLATFORM_FILE_OPEN_TRUNCATED | - base::PLATFORM_FILE_WRITE | - base::PLATFORM_FILE_EXCLUSIVE_WRITE | - base::PLATFORM_FILE_DELETE_ON_CLOSE | - base::PLATFORM_FILE_WRITE_ATTRIBUTES; +const int kOpenPepperFilePermissions = base::PLATFORM_FILE_OPEN | + base::PLATFORM_FILE_CREATE | + base::PLATFORM_FILE_OPEN_ALWAYS | + base::PLATFORM_FILE_CREATE_ALWAYS | + base::PLATFORM_FILE_OPEN_TRUNCATED | + base::PLATFORM_FILE_READ | + base::PLATFORM_FILE_WRITE | + base::PLATFORM_FILE_APPEND | + base::PLATFORM_FILE_EXCLUSIVE_WRITE | + base::PLATFORM_FILE_DELETE_ON_CLOSE | + base::PLATFORM_FILE_WRITE_ATTRIBUTES; } // namespace fileapi diff --git a/chromium/webkit/browser/fileapi/file_permission_policy.h b/chromium/webkit/browser/fileapi/file_permission_policy.h index 3975c3ccace..5c9ced54e8a 100644 --- a/chromium/webkit/browser/fileapi/file_permission_policy.h +++ b/chromium/webkit/browser/fileapi/file_permission_policy.h @@ -12,7 +12,7 @@ namespace fileapi { WEBKIT_STORAGE_BROWSER_EXPORT extern const int kReadFilePermissions; WEBKIT_STORAGE_BROWSER_EXPORT extern const int kWriteFilePermissions; WEBKIT_STORAGE_BROWSER_EXPORT extern const int kCreateFilePermissions; -WEBKIT_STORAGE_BROWSER_EXPORT extern const int kOpenFilePermissions; +WEBKIT_STORAGE_BROWSER_EXPORT extern const int kOpenPepperFilePermissions; enum FilePermissionPolicy { // Any access should be always denied. diff --git a/chromium/webkit/browser/fileapi/file_system_context.cc b/chromium/webkit/browser/fileapi/file_system_context.cc index f2973d35fa2..d43ba8a846e 100644 --- a/chromium/webkit/browser/fileapi/file_system_context.cc +++ b/chromium/webkit/browser/fileapi/file_system_context.cc @@ -108,14 +108,14 @@ FileSystemContext::FileSystemContext( : io_task_runner_(io_task_runner), default_file_task_runner_(file_task_runner), quota_manager_proxy_(quota_manager_proxy), - sandbox_delegate_(new SandboxFileSystemBackendDelegate( + sandbox_context_(new SandboxContext( quota_manager_proxy, file_task_runner, partition_path, special_storage_policy, options)), sandbox_backend_(new SandboxFileSystemBackend( - sandbox_delegate_.get())), + sandbox_context_.get())), isolated_backend_(new IsolatedFileSystemBackend()), additional_backends_(additional_backends.Pass()), external_mount_points_(external_mount_points), diff --git a/chromium/webkit/browser/fileapi/file_system_context.h b/chromium/webkit/browser/fileapi/file_system_context.h index 528f7a26021..d6934ec7c68 100644 --- a/chromium/webkit/browser/fileapi/file_system_context.h +++ b/chromium/webkit/browser/fileapi/file_system_context.h @@ -17,7 +17,7 @@ #include "base/sequenced_task_runner_helpers.h" #include "webkit/browser/fileapi/file_system_url.h" #include "webkit/browser/fileapi/open_file_system_mode.h" -#include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h" +#include "webkit/browser/fileapi/sandbox_context.h" #include "webkit/browser/fileapi/task_runner_bound_observer_list.h" #include "webkit/browser/webkit_storage_browser_export.h" #include "webkit/common/fileapi/file_system_types.h" @@ -228,9 +228,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext void EnableTemporaryFileSystemInIncognito(); #endif - SandboxFileSystemBackendDelegate* sandbox_delegate() { - return sandbox_delegate_.get(); - } + SandboxContext* sandbox_context() { return sandbox_context_.get(); } private: typedef std::map<FileSystemType, FileSystemBackend*> @@ -285,7 +283,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; - scoped_ptr<SandboxFileSystemBackendDelegate> sandbox_delegate_; + scoped_ptr<SandboxContext> sandbox_context_; // Regular file system backends. scoped_ptr<SandboxFileSystemBackend> sandbox_backend_; diff --git a/chromium/webkit/browser/fileapi/file_system_quota_util.h b/chromium/webkit/browser/fileapi/file_system_quota_util.h index 5655c990d4d..be98936c2f5 100644 --- a/chromium/webkit/browser/fileapi/file_system_quota_util.h +++ b/chromium/webkit/browser/fileapi/file_system_quota_util.h @@ -56,6 +56,11 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemQuotaUtil { const GURL& origin_url, fileapi::FileSystemType type) = 0; + virtual void InvalidateUsageCache(const GURL& origin_url, + fileapi::FileSystemType type) = 0; + virtual void StickyInvalidateUsageCache(const GURL& origin, + fileapi::FileSystemType type) = 0; + virtual void AddFileUpdateObserver( FileSystemType type, FileUpdateObserver* observer, diff --git a/chromium/webkit/browser/fileapi/obfuscated_file_util.cc b/chromium/webkit/browser/fileapi/obfuscated_file_util.cc index 7e2f7df12a8..77e2d86a7e7 100644 --- a/chromium/webkit/browser/fileapi/obfuscated_file_util.cc +++ b/chromium/webkit/browser/fileapi/obfuscated_file_util.cc @@ -276,7 +276,7 @@ PlatformFileError ObfuscatedFileUtil::CreateOrOpen( file_flags & base::PLATFORM_FILE_WRITE && context->quota_limit_type() == quota::kQuotaLimitTypeUnlimited) { DCHECK_EQ(base::PLATFORM_FILE_OK, error); - context->file_system_context()->sandbox_delegate()-> + context->file_system_context()->GetQuotaUtil(url.type())-> StickyInvalidateUsageCache(url.origin(), url.type()); } return error; @@ -1261,7 +1261,7 @@ void ObfuscatedFileUtil::InvalidateUsageCache( FileSystemOperationContext* context, const GURL& origin, FileSystemType type) { - context->file_system_context()->sandbox_delegate()-> + context->file_system_context()->GetQuotaUtil(type)-> InvalidateUsageCache(origin, type); } diff --git a/chromium/webkit/browser/fileapi/sandbox_file_system_backend_delegate.cc b/chromium/webkit/browser/fileapi/sandbox_context.cc index 0a6034e7d9a..d8b7293b6a4 100644 --- a/chromium/webkit/browser/fileapi/sandbox_file_system_backend_delegate.cc +++ b/chromium/webkit/browser/fileapi/sandbox_context.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h" +#include "webkit/browser/fileapi/sandbox_context.h" #include "base/command_line.h" #include "base/file_util.h" @@ -53,7 +53,7 @@ const base::FilePath::CharType kRestrictedChars[] = { }; class ObfuscatedOriginEnumerator - : public SandboxFileSystemBackendDelegate::OriginEnumerator { + : public SandboxContext::OriginEnumerator { public: explicit ObfuscatedOriginEnumerator(ObfuscatedFileUtil* file_util) { enum_.reset(file_util->CreateOriginEnumerator()); @@ -94,21 +94,20 @@ void OpenFileSystemOnFileThread( } void DidOpenFileSystem( - base::WeakPtr<SandboxFileSystemBackendDelegate> delegate, + base::WeakPtr<SandboxContext> sandbox_context, const base::Callback<void(base::PlatformFileError error)>& callback, base::PlatformFileError* error) { - if (delegate.get()) - delegate.get()->CollectOpenFileSystemMetrics(*error); + if (sandbox_context.get()) + sandbox_context.get()->CollectOpenFileSystemMetrics(*error); callback.Run(*error); } } // namespace const base::FilePath::CharType -SandboxFileSystemBackendDelegate::kFileSystemDirectory[] = - FILE_PATH_LITERAL("File System"); +SandboxContext::kFileSystemDirectory[] = FILE_PATH_LITERAL("File System"); -SandboxFileSystemBackendDelegate::SandboxFileSystemBackendDelegate( +SandboxContext::SandboxContext( quota::QuotaManagerProxy* quota_manager_proxy, base::SequencedTaskRunner* file_task_runner, const base::FilePath& profile_path, @@ -124,16 +123,16 @@ SandboxFileSystemBackendDelegate::SandboxFileSystemBackendDelegate( quota_observer_(new SandboxQuotaObserver( quota_manager_proxy, file_task_runner, - obfuscated_file_util(), + sync_file_util(), usage_cache())), special_storage_policy_(special_storage_policy), file_system_options_(file_system_options), weak_factory_(this) { } -SandboxFileSystemBackendDelegate::~SandboxFileSystemBackendDelegate() { +SandboxContext::~SandboxContext() { if (!file_task_runner_->RunsTasksOnCurrentThread()) { - AsyncFileUtil* sandbox_file_util = sandbox_file_util_.release(); + AsyncFileUtilAdapter* sandbox_file_util = sandbox_file_util_.release(); SandboxQuotaObserver* quota_observer = quota_observer_.release(); FileSystemUsageCache* file_system_usage_cache = file_system_usage_cache_.release(); @@ -146,8 +145,7 @@ SandboxFileSystemBackendDelegate::~SandboxFileSystemBackendDelegate() { } } -bool SandboxFileSystemBackendDelegate::IsAccessValid( - const FileSystemURL& url) const { +bool SandboxContext::IsAccessValid(const FileSystemURL& url) const { if (!IsAllowedScheme(url.origin())) return false; @@ -178,7 +176,7 @@ bool SandboxFileSystemBackendDelegate::IsAccessValid( return true; } -bool SandboxFileSystemBackendDelegate::IsAllowedScheme(const GURL& url) const { +bool SandboxContext::IsAllowedScheme(const GURL& url) const { // Basically we only accept http or https. We allow file:// URLs // only if --allow-file-access-from-files flag is given. if (url.SchemeIs("http") || url.SchemeIs("https")) @@ -196,25 +194,21 @@ bool SandboxFileSystemBackendDelegate::IsAllowedScheme(const GURL& url) const { return false; } -SandboxFileSystemBackendDelegate::OriginEnumerator* -SandboxFileSystemBackendDelegate::CreateOriginEnumerator() { - return new ObfuscatedOriginEnumerator(obfuscated_file_util()); +SandboxContext::OriginEnumerator* SandboxContext::CreateOriginEnumerator() { + return new ObfuscatedOriginEnumerator(sync_file_util()); } -base::FilePath -SandboxFileSystemBackendDelegate::GetBaseDirectoryForOriginAndType( - const GURL& origin_url, - fileapi::FileSystemType type, - bool create) { +base::FilePath SandboxContext::GetBaseDirectoryForOriginAndType( + const GURL& origin_url, fileapi::FileSystemType type, bool create) { base::PlatformFileError error = base::PLATFORM_FILE_OK; - base::FilePath path = obfuscated_file_util()->GetDirectoryForOriginAndType( + base::FilePath path = sync_file_util()->GetDirectoryForOriginAndType( origin_url, type, create, &error); if (error != base::PLATFORM_FILE_OK) return base::FilePath(); return path; } -void SandboxFileSystemBackendDelegate::OpenFileSystem( +void SandboxContext::OpenFileSystem( const GURL& origin_url, fileapi::FileSystemType type, OpenFileSystemMode mode, @@ -231,7 +225,7 @@ void SandboxFileSystemBackendDelegate::OpenFileSystem( file_task_runner_->PostTaskAndReply( FROM_HERE, base::Bind(&OpenFileSystemOnFileThread, - obfuscated_file_util(), origin_url, type, mode, + sync_file_util(), origin_url, type, mode, base::Unretained(error_ptr)), base::Bind(&DidOpenFileSystem, weak_factory_.GetWeakPtr(), @@ -239,8 +233,7 @@ void SandboxFileSystemBackendDelegate::OpenFileSystem( base::Owned(error_ptr))); } -base::PlatformFileError -SandboxFileSystemBackendDelegate::DeleteOriginDataOnFileThread( +base::PlatformFileError SandboxContext::DeleteOriginDataOnFileThread( FileSystemContext* file_system_context, quota::QuotaManagerProxy* proxy, const GURL& origin_url, @@ -248,7 +241,7 @@ SandboxFileSystemBackendDelegate::DeleteOriginDataOnFileThread( int64 usage = GetOriginUsageOnFileThread( file_system_context, origin_url, type); usage_cache()->CloseCacheFiles(); - bool result = obfuscated_file_util()->DeleteDirectoryForOriginAndType( + bool result = sync_file_util()->DeleteDirectoryForOriginAndType( origin_url, type); if (result && proxy) { proxy->NotifyStorageModified( @@ -263,7 +256,7 @@ SandboxFileSystemBackendDelegate::DeleteOriginDataOnFileThread( return base::PLATFORM_FILE_ERROR_FAILED; } -void SandboxFileSystemBackendDelegate::GetOriginsForTypeOnFileThread( +void SandboxContext::GetOriginsForTypeOnFileThread( fileapi::FileSystemType type, std::set<GURL>* origins) { DCHECK(origins); scoped_ptr<OriginEnumerator> enumerator(CreateOriginEnumerator()); @@ -274,7 +267,7 @@ void SandboxFileSystemBackendDelegate::GetOriginsForTypeOnFileThread( } } -void SandboxFileSystemBackendDelegate::GetOriginsForHostOnFileThread( +void SandboxContext::GetOriginsForHostOnFileThread( fileapi::FileSystemType type, const std::string& host, std::set<GURL>* origins) { DCHECK(origins); @@ -287,7 +280,7 @@ void SandboxFileSystemBackendDelegate::GetOriginsForHostOnFileThread( } } -int64 SandboxFileSystemBackendDelegate::GetOriginUsageOnFileThread( +int64 SandboxContext::GetOriginUsageOnFileThread( FileSystemContext* file_system_context, const GURL& origin_url, fileapi::FileSystemType type) { @@ -325,18 +318,18 @@ int64 SandboxFileSystemBackendDelegate::GetOriginUsageOnFileThread( return usage; } -void SandboxFileSystemBackendDelegate::InvalidateUsageCache( +void SandboxContext::InvalidateUsageCache( const GURL& origin, fileapi::FileSystemType type) { base::PlatformFileError error = base::PLATFORM_FILE_OK; base::FilePath usage_file_path = GetUsageCachePathForOriginAndType( - obfuscated_file_util(), origin, type, &error); + sync_file_util(), origin, type, &error); if (error != base::PLATFORM_FILE_OK) return; usage_cache()->IncrementDirty(usage_file_path); } -void SandboxFileSystemBackendDelegate::StickyInvalidateUsageCache( +void SandboxContext::StickyInvalidateUsageCache( const GURL& origin, fileapi::FileSystemType type) { sticky_dirty_origins_.insert(std::make_pair(origin, type)); @@ -344,25 +337,19 @@ void SandboxFileSystemBackendDelegate::StickyInvalidateUsageCache( InvalidateUsageCache(origin, type); } -FileSystemFileUtil* SandboxFileSystemBackendDelegate::sync_file_util() { - return static_cast<AsyncFileUtilAdapter*>(file_util())->sync_file_util(); -} - -base::FilePath -SandboxFileSystemBackendDelegate::GetUsageCachePathForOriginAndType( +base::FilePath SandboxContext::GetUsageCachePathForOriginAndType( const GURL& origin_url, FileSystemType type) { base::PlatformFileError error; base::FilePath path = GetUsageCachePathForOriginAndType( - obfuscated_file_util(), origin_url, type, &error); + sync_file_util(), origin_url, type, &error); if (error != base::PLATFORM_FILE_OK) return base::FilePath(); return path; } // static -base::FilePath -SandboxFileSystemBackendDelegate::GetUsageCachePathForOriginAndType( +base::FilePath SandboxContext::GetUsageCachePathForOriginAndType( ObfuscatedFileUtil* sandbox_file_util, const GURL& origin_url, fileapi::FileSystemType type, @@ -376,16 +363,14 @@ SandboxFileSystemBackendDelegate::GetUsageCachePathForOriginAndType( return base_path.Append(FileSystemUsageCache::kUsageFileName); } -int64 SandboxFileSystemBackendDelegate::RecalculateUsage( - FileSystemContext* context, - const GURL& origin, - FileSystemType type) { +int64 SandboxContext::RecalculateUsage(FileSystemContext* context, + const GURL& origin, + FileSystemType type) { FileSystemOperationContext operation_context(context); FileSystemURL url = context->CreateCrackedFileSystemURL( origin, type, base::FilePath()); scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> enumerator( - obfuscated_file_util()->CreateFileEnumerator( - &operation_context, url, true)); + sync_file_util()->CreateFileEnumerator(&operation_context, url, true)); base::FilePath file_path_each; int64 usage = 0; @@ -398,7 +383,7 @@ int64 SandboxFileSystemBackendDelegate::RecalculateUsage( return usage; } -void SandboxFileSystemBackendDelegate::CollectOpenFileSystemMetrics( +void SandboxContext::CollectOpenFileSystemMetrics( base::PlatformFileError error_code) { base::Time now = base::Time::Now(); bool throttled = now < next_release_time_for_open_filesystem_stat_; @@ -435,8 +420,8 @@ void SandboxFileSystemBackendDelegate::CollectOpenFileSystemMetrics( #undef REPORT } -ObfuscatedFileUtil* SandboxFileSystemBackendDelegate::obfuscated_file_util() { - return static_cast<ObfuscatedFileUtil*>(sync_file_util()); +ObfuscatedFileUtil* SandboxContext::sync_file_util() { + return static_cast<ObfuscatedFileUtil*>(file_util()->sync_file_util()); } } // namespace fileapi diff --git a/chromium/webkit/browser/fileapi/sandbox_file_system_backend_delegate.h b/chromium/webkit/browser/fileapi/sandbox_context.h index 5fb83f082b9..c765077b8d3 100644 --- a/chromium/webkit/browser/fileapi/sandbox_file_system_backend_delegate.h +++ b/chromium/webkit/browser/fileapi/sandbox_context.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_DELEGATE_H_ -#define WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_DELEGATE_H_ +#ifndef WEBKIT_BROWSER_FILEAPI_SANDBOX_CONTEXT_H_ +#define WEBKIT_BROWSER_FILEAPI_SANDBOX_CONTEXT_H_ #include <set> #include <string> @@ -30,8 +30,7 @@ class SpecialStoragePolicy; namespace fileapi { -class AsyncFileUtil; -class FileSystemFileUtil; +class AsyncFileUtilAdapter; class FileSystemURL; class FileSystemUsageCache; class ObfuscatedFileUtil; @@ -39,9 +38,9 @@ class SandboxFileSystemBackend; class SandboxFileSystemTestHelper; class SandboxQuotaObserver; -// Delegate implementation of the some methods in Sandbox/SyncFileSystemBackend. +// This class keeps and provides a sandbox file system context. // An instance of this class is created and owned by FileSystemContext. -class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackendDelegate { +class WEBKIT_STORAGE_BROWSER_EXPORT SandboxContext { public: typedef FileSystemBackend::OpenFileSystemCallback OpenFileSystemCallback; @@ -61,14 +60,14 @@ class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackendDelegate { virtual bool HasFileSystemType(FileSystemType type) const = 0; }; - SandboxFileSystemBackendDelegate( + SandboxContext( quota::QuotaManagerProxy* quota_manager_proxy, base::SequencedTaskRunner* file_task_runner, const base::FilePath& profile_path, quota::SpecialStoragePolicy* special_storage_policy, const FileSystemOptions& file_system_options); - ~SandboxFileSystemBackendDelegate(); + ~SandboxContext(); // Performs API-specific validity checks on the given path |url|. // Returns true if access to |url| is valid in this filesystem. @@ -131,7 +130,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackendDelegate { return file_task_runner_.get(); } - AsyncFileUtil* file_util() { return sandbox_file_util_.get(); } + AsyncFileUtilAdapter* file_util() { return sandbox_file_util_.get(); } FileSystemUsageCache* usage_cache() { return file_system_usage_cache_.get(); } SandboxQuotaObserver* quota_observer() { return quota_observer_.get(); }; @@ -139,11 +138,9 @@ class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackendDelegate { return special_storage_policy_.get(); } - const FileSystemOptions& file_system_options() const { - return file_system_options_; - } + FileSystemOptions file_system_options() { return file_system_options_; } - FileSystemFileUtil* sync_file_util(); + ObfuscatedFileUtil* sync_file_util(); private: friend class SandboxQuotaObserver; @@ -165,11 +162,9 @@ class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackendDelegate { const GURL& origin, FileSystemType type); - ObfuscatedFileUtil* obfuscated_file_util(); - scoped_refptr<base::SequencedTaskRunner> file_task_runner_; - scoped_ptr<AsyncFileUtil> sandbox_file_util_; + scoped_ptr<AsyncFileUtilAdapter> sandbox_file_util_; scoped_ptr<FileSystemUsageCache> file_system_usage_cache_; scoped_ptr<SandboxQuotaObserver> quota_observer_; @@ -184,11 +179,11 @@ class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackendDelegate { base::Time next_release_time_for_open_filesystem_stat_; - base::WeakPtrFactory<SandboxFileSystemBackendDelegate> weak_factory_; + base::WeakPtrFactory<SandboxContext> weak_factory_; - DISALLOW_COPY_AND_ASSIGN(SandboxFileSystemBackendDelegate); + DISALLOW_COPY_AND_ASSIGN(SandboxContext); }; } // namespace fileapi -#endif // WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_DELEGATE_H_ +#endif // WEBKIT_BROWSER_FILEAPI_SANDBOX_CONTEXT_H_ diff --git a/chromium/webkit/browser/fileapi/sandbox_file_system_backend_delegate_unittest.cc b/chromium/webkit/browser/fileapi/sandbox_context_unittest.cc index 48c3b8c4e70..841e10b5b83 100644 --- a/chromium/webkit/browser/fileapi/sandbox_file_system_backend_delegate_unittest.cc +++ b/chromium/webkit/browser/fileapi/sandbox_context_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h" +#include "webkit/browser/fileapi/sandbox_context.h" #include "base/basictypes.h" #include "base/file_util.h" @@ -27,11 +27,11 @@ FileSystemURL CreateFileSystemURL(const char* path) { } // namespace -class SandboxFileSystemBackendDelegateTest : public testing::Test { +class SandboxContextTest : public testing::Test { protected: virtual void SetUp() { ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); - delegate_.reset(new SandboxFileSystemBackendDelegate( + context_.reset(new SandboxContext( NULL /* quota_manager_proxy */, base::MessageLoopProxy::current().get(), data_dir_.path(), @@ -41,42 +41,42 @@ class SandboxFileSystemBackendDelegateTest : public testing::Test { base::ScopedTempDir data_dir_; base::MessageLoop message_loop_; - scoped_ptr<SandboxFileSystemBackendDelegate> delegate_; + scoped_ptr<SandboxContext> context_; }; -TEST_F(SandboxFileSystemBackendDelegateTest, IsAccessValid) { +TEST_F(SandboxContextTest, IsAccessValid) { // Normal case. - EXPECT_TRUE(delegate_->IsAccessValid(CreateFileSystemURL("a"))); + EXPECT_TRUE(context_->IsAccessValid(CreateFileSystemURL("a"))); // Access to a path with parent references ('..') should be disallowed. - EXPECT_FALSE(delegate_->IsAccessValid(CreateFileSystemURL("a/../b"))); + EXPECT_FALSE(context_->IsAccessValid(CreateFileSystemURL("a/../b"))); // Access from non-allowed scheme should be disallowed. - EXPECT_FALSE(delegate_->IsAccessValid( + EXPECT_FALSE(context_->IsAccessValid( FileSystemURL::CreateForTest( GURL("unknown://bar"), kFileSystemTypeTemporary, base::FilePath::FromUTF8Unsafe("foo")))); // Access with restricted name should be disallowed. - EXPECT_FALSE(delegate_->IsAccessValid(CreateFileSystemURL("."))); - EXPECT_FALSE(delegate_->IsAccessValid(CreateFileSystemURL(".."))); + EXPECT_FALSE(context_->IsAccessValid(CreateFileSystemURL("."))); + EXPECT_FALSE(context_->IsAccessValid(CreateFileSystemURL(".."))); // This is also disallowed due to Windows XP parent path handling. - EXPECT_FALSE(delegate_->IsAccessValid(CreateFileSystemURL("..."))); + EXPECT_FALSE(context_->IsAccessValid(CreateFileSystemURL("..."))); // These are identified as unsafe cases due to weird path handling // on Windows. - EXPECT_FALSE(delegate_->IsAccessValid(CreateFileSystemURL(" .."))); - EXPECT_FALSE(delegate_->IsAccessValid(CreateFileSystemURL(".. "))); + EXPECT_FALSE(context_->IsAccessValid(CreateFileSystemURL(" .."))); + EXPECT_FALSE(context_->IsAccessValid(CreateFileSystemURL(".. "))); // Similar but safe cases. - EXPECT_TRUE(delegate_->IsAccessValid(CreateFileSystemURL(" ."))); - EXPECT_TRUE(delegate_->IsAccessValid(CreateFileSystemURL(". "))); - EXPECT_TRUE(delegate_->IsAccessValid(CreateFileSystemURL("b."))); - EXPECT_TRUE(delegate_->IsAccessValid(CreateFileSystemURL(".b"))); + EXPECT_TRUE(context_->IsAccessValid(CreateFileSystemURL(" ."))); + EXPECT_TRUE(context_->IsAccessValid(CreateFileSystemURL(". "))); + EXPECT_TRUE(context_->IsAccessValid(CreateFileSystemURL("b."))); + EXPECT_TRUE(context_->IsAccessValid(CreateFileSystemURL(".b"))); // A path that looks like a drive letter. - EXPECT_TRUE(delegate_->IsAccessValid(CreateFileSystemURL("c:"))); + EXPECT_TRUE(context_->IsAccessValid(CreateFileSystemURL("c:"))); } } // namespace fileapi diff --git a/chromium/webkit/browser/fileapi/sandbox_directory_database.cc b/chromium/webkit/browser/fileapi/sandbox_directory_database.cc index 24790b15e31..8a90bd33479 100644 --- a/chromium/webkit/browser/fileapi/sandbox_directory_database.cc +++ b/chromium/webkit/browser/fileapi/sandbox_directory_database.cc @@ -715,7 +715,7 @@ bool SandboxDirectoryDatabase::Init(RecoveryOption recovery_option) { FilePathToString(filesystem_data_directory_.Append( kDirectoryDatabaseName)); leveldb::Options options; - options.max_open_files = 0; // Use minimum. + options.max_open_files = 64; // Use minimum. options.create_if_missing = true; leveldb::DB* db; leveldb::Status status = leveldb::DB::Open(options, path, &db); @@ -763,7 +763,7 @@ bool SandboxDirectoryDatabase::Init(RecoveryOption recovery_option) { bool SandboxDirectoryDatabase::RepairDatabase(const std::string& db_path) { DCHECK(!db_.get()); leveldb::Options options; - options.max_open_files = 0; // Use minimum. + options.max_open_files = 64; // Use minimum. if (!leveldb::RepairDB(db_path, options).ok()) return false; if (!Init(FAIL_ON_CORRUPTION)) diff --git a/chromium/webkit/browser/fileapi/sandbox_file_system_backend.cc b/chromium/webkit/browser/fileapi/sandbox_file_system_backend.cc index 665c0f1f798..20f732989d4 100644 --- a/chromium/webkit/browser/fileapi/sandbox_file_system_backend.cc +++ b/chromium/webkit/browser/fileapi/sandbox_file_system_backend.cc @@ -19,8 +19,8 @@ #include "webkit/browser/fileapi/file_system_options.h" #include "webkit/browser/fileapi/file_system_usage_cache.h" #include "webkit/browser/fileapi/obfuscated_file_util.h" +#include "webkit/browser/fileapi/sandbox_context.h" #include "webkit/browser/fileapi/sandbox_file_stream_writer.h" -#include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h" #include "webkit/browser/fileapi/sandbox_quota_observer.h" #include "webkit/browser/quota/quota_manager.h" #include "webkit/common/fileapi/file_system_types.h" @@ -39,8 +39,8 @@ const char kPersistentOriginsCountLabel[] = "FileSystem.PersistentOriginsCount"; } // anonymous namespace SandboxFileSystemBackend::SandboxFileSystemBackend( - SandboxFileSystemBackendDelegate* delegate) - : delegate_(delegate), + SandboxContext* sandbox_context) + : sandbox_context_(sandbox_context), enable_temporary_file_system_in_incognito_(false) { } @@ -55,10 +55,10 @@ bool SandboxFileSystemBackend::CanHandleType(FileSystemType type) const { void SandboxFileSystemBackend::Initialize(FileSystemContext* context) { // Set quota observers. update_observers_ = update_observers_.AddObserver( - delegate_->quota_observer(), - delegate_->file_task_runner()); + sandbox_context_->quota_observer(), + sandbox_context_->file_task_runner()); access_observers_ = access_observers_.AddObserver( - delegate_->quota_observer(), NULL); + sandbox_context_->quota_observer(), NULL); } void SandboxFileSystemBackend::OpenFileSystem( @@ -67,8 +67,8 @@ void SandboxFileSystemBackend::OpenFileSystem( OpenFileSystemMode mode, const OpenFileSystemCallback& callback) { DCHECK(CanHandleType(type)); - DCHECK(delegate_); - if (delegate_->file_system_options().is_incognito() && + DCHECK(sandbox_context_); + if (sandbox_context_->file_system_options().is_incognito() && !(type == kFileSystemTypeTemporary && enable_temporary_file_system_in_incognito_)) { // TODO(kinuko): return an isolated temporary directory. @@ -76,20 +76,20 @@ void SandboxFileSystemBackend::OpenFileSystem( return; } - delegate_->OpenFileSystem( + sandbox_context_->OpenFileSystem( origin_url, type, mode, callback, GetFileSystemRootURI(origin_url, type)); } FileSystemFileUtil* SandboxFileSystemBackend::GetFileUtil( FileSystemType type) { - return delegate_->sync_file_util(); + return sandbox_context_->sync_file_util(); } AsyncFileUtil* SandboxFileSystemBackend::GetAsyncFileUtil( FileSystemType type) { - DCHECK(delegate_); - return delegate_->file_util(); + DCHECK(sandbox_context_); + return sandbox_context_->file_util(); } CopyOrMoveFileValidatorFactory* @@ -106,8 +106,8 @@ FileSystemOperation* SandboxFileSystemBackend::CreateFileSystemOperation( FileSystemContext* context, base::PlatformFileError* error_code) const { DCHECK(CanHandleType(url.type())); - DCHECK(delegate_); - if (!delegate_->IsAccessValid(url)) { + DCHECK(sandbox_context_); + if (!sandbox_context_->IsAccessValid(url)) { *error_code = base::PLATFORM_FILE_ERROR_SECURITY; return NULL; } @@ -117,7 +117,7 @@ FileSystemOperation* SandboxFileSystemBackend::CreateFileSystemOperation( operation_context->set_update_observers(update_observers_); operation_context->set_change_observers(change_observers_); - SpecialStoragePolicy* policy = delegate_->special_storage_policy(); + SpecialStoragePolicy* policy = sandbox_context_->special_storage_policy(); if (policy && policy->IsStorageUnlimited(url.origin())) operation_context->set_quota_limit_type(quota::kQuotaLimitTypeUnlimited); else @@ -133,8 +133,8 @@ SandboxFileSystemBackend::CreateFileStreamReader( const base::Time& expected_modification_time, FileSystemContext* context) const { DCHECK(CanHandleType(url.type())); - DCHECK(delegate_); - if (!delegate_->IsAccessValid(url)) + DCHECK(sandbox_context_); + if (!sandbox_context_->IsAccessValid(url)) return scoped_ptr<webkit_blob::FileStreamReader>(); return scoped_ptr<webkit_blob::FileStreamReader>( new FileSystemFileStreamReader( @@ -147,8 +147,8 @@ SandboxFileSystemBackend::CreateFileStreamWriter( int64 offset, FileSystemContext* context) const { DCHECK(CanHandleType(url.type())); - DCHECK(delegate_); - if (!delegate_->IsAccessValid(url)) + DCHECK(sandbox_context_); + if (!sandbox_context_->IsAccessValid(url)) return scoped_ptr<fileapi::FileStreamWriter>(); return scoped_ptr<fileapi::FileStreamWriter>( new SandboxFileStreamWriter(context, url, offset, update_observers_)); @@ -158,10 +158,10 @@ FileSystemQuotaUtil* SandboxFileSystemBackend::GetQuotaUtil() { return this; } -SandboxFileSystemBackendDelegate::OriginEnumerator* +SandboxContext::OriginEnumerator* SandboxFileSystemBackend::CreateOriginEnumerator() { - DCHECK(delegate_); - return delegate_->CreateOriginEnumerator(); + DCHECK(sandbox_context_); + return sandbox_context_->CreateOriginEnumerator(); } base::PlatformFileError @@ -171,16 +171,16 @@ SandboxFileSystemBackend::DeleteOriginDataOnFileThread( const GURL& origin_url, fileapi::FileSystemType type) { DCHECK(CanHandleType(type)); - DCHECK(delegate_); - return delegate_->DeleteOriginDataOnFileThread( + DCHECK(sandbox_context_); + return sandbox_context_->DeleteOriginDataOnFileThread( file_system_context, proxy, origin_url, type); } void SandboxFileSystemBackend::GetOriginsForTypeOnFileThread( fileapi::FileSystemType type, std::set<GURL>* origins) { DCHECK(CanHandleType(type)); - DCHECK(delegate_); - delegate_->GetOriginsForTypeOnFileThread(type, origins); + DCHECK(sandbox_context_); + sandbox_context_->GetOriginsForTypeOnFileThread(type, origins); switch (type) { case kFileSystemTypeTemporary: UMA_HISTOGRAM_COUNTS(kTemporaryOriginsCountLabel, origins->size()); @@ -197,8 +197,8 @@ void SandboxFileSystemBackend::GetOriginsForHostOnFileThread( fileapi::FileSystemType type, const std::string& host, std::set<GURL>* origins) { DCHECK(CanHandleType(type)); - DCHECK(delegate_); - delegate_->GetOriginsForHostOnFileThread(type, host, origins); + DCHECK(sandbox_context_); + sandbox_context_->GetOriginsForHostOnFileThread(type, host, origins); } int64 SandboxFileSystemBackend::GetOriginUsageOnFileThread( @@ -206,11 +206,27 @@ int64 SandboxFileSystemBackend::GetOriginUsageOnFileThread( const GURL& origin_url, fileapi::FileSystemType type) { DCHECK(CanHandleType(type)); - DCHECK(delegate_); - return delegate_->GetOriginUsageOnFileThread( + DCHECK(sandbox_context_); + return sandbox_context_->GetOriginUsageOnFileThread( file_system_context, origin_url, type); } +void SandboxFileSystemBackend::InvalidateUsageCache( + const GURL& origin, + fileapi::FileSystemType type) { + DCHECK(CanHandleType(type)); + DCHECK(sandbox_context_); + sandbox_context_->InvalidateUsageCache(origin, type); +} + +void SandboxFileSystemBackend::StickyInvalidateUsageCache( + const GURL& origin, + fileapi::FileSystemType type) { + DCHECK(CanHandleType(type)); + DCHECK(sandbox_context_); + sandbox_context_->StickyInvalidateUsageCache(origin, type); +} + void SandboxFileSystemBackend::AddFileUpdateObserver( FileSystemType type, FileUpdateObserver* observer, diff --git a/chromium/webkit/browser/fileapi/sandbox_file_system_backend.h b/chromium/webkit/browser/fileapi/sandbox_file_system_backend.h index a1a568637a0..3e7ff60b529 100644 --- a/chromium/webkit/browser/fileapi/sandbox_file_system_backend.h +++ b/chromium/webkit/browser/fileapi/sandbox_file_system_backend.h @@ -14,7 +14,7 @@ #include "base/memory/scoped_ptr.h" #include "webkit/browser/fileapi/file_system_backend.h" #include "webkit/browser/fileapi/file_system_quota_util.h" -#include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h" +#include "webkit/browser/fileapi/sandbox_context.h" #include "webkit/browser/fileapi/task_runner_bound_observer_list.h" #include "webkit/browser/quota/special_storage_policy.h" #include "webkit/browser/webkit_storage_browser_export.h" @@ -30,7 +30,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackend : public FileSystemBackend, public FileSystemQuotaUtil { public: - explicit SandboxFileSystemBackend(SandboxFileSystemBackendDelegate* delegate); + explicit SandboxFileSystemBackend(SandboxContext* sandbox_context); virtual ~SandboxFileSystemBackend(); // FileSystemBackend overrides. @@ -63,7 +63,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackend // Returns an origin enumerator of this backend. // This method can only be called on the file thread. - SandboxFileSystemBackendDelegate::OriginEnumerator* CreateOriginEnumerator(); + SandboxContext::OriginEnumerator* CreateOriginEnumerator(); // FileSystemQuotaUtil overrides. virtual base::PlatformFileError DeleteOriginDataOnFileThread( @@ -82,6 +82,12 @@ class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackend FileSystemContext* context, const GURL& origin_url, FileSystemType type) OVERRIDE; + virtual void InvalidateUsageCache( + const GURL& origin_url, + FileSystemType type) OVERRIDE; + virtual void StickyInvalidateUsageCache( + const GURL& origin_url, + FileSystemType type) OVERRIDE; virtual void AddFileUpdateObserver( FileSystemType type, FileUpdateObserver* observer, @@ -106,7 +112,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackend } private: - SandboxFileSystemBackendDelegate* delegate_; // Not owned. + SandboxContext* sandbox_context_; // Not owned. bool enable_temporary_file_system_in_incognito_; diff --git a/chromium/webkit/browser/fileapi/sandbox_file_system_backend_unittest.cc b/chromium/webkit/browser/fileapi/sandbox_file_system_backend_unittest.cc index c7f03170e42..ec213a36386 100644 --- a/chromium/webkit/browser/fileapi/sandbox_file_system_backend_unittest.cc +++ b/chromium/webkit/browser/fileapi/sandbox_file_system_backend_unittest.cc @@ -17,7 +17,7 @@ #include "webkit/browser/fileapi/file_system_backend.h" #include "webkit/browser/fileapi/file_system_url.h" #include "webkit/browser/fileapi/mock_file_system_options.h" -#include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h" +#include "webkit/browser/fileapi/sandbox_context.h" #include "webkit/common/fileapi/file_system_util.h" // PS stands for path separator. @@ -85,11 +85,11 @@ class SandboxFileSystemBackendTest : public testing::Test { protected: virtual void SetUp() { ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); - SetUpNewDelegate(CreateAllowFileAccessOptions()); + SetUpNewSandboxContext(CreateAllowFileAccessOptions()); } - void SetUpNewDelegate(const FileSystemOptions& options) { - delegate_.reset(new SandboxFileSystemBackendDelegate( + void SetUpNewSandboxContext(const FileSystemOptions& options) { + context_.reset(new SandboxContext( NULL /* quota_manager_proxy */, base::MessageLoopProxy::current().get(), data_dir_.path(), @@ -98,18 +98,17 @@ class SandboxFileSystemBackendTest : public testing::Test { } void SetUpNewBackend(const FileSystemOptions& options) { - SetUpNewDelegate(options); - backend_.reset(new SandboxFileSystemBackend(delegate_.get())); + SetUpNewSandboxContext(options); + backend_.reset(new SandboxFileSystemBackend(context_.get())); } - SandboxFileSystemBackendDelegate::OriginEnumerator* - CreateOriginEnumerator() const { + SandboxContext::OriginEnumerator* CreateOriginEnumerator() const { return backend_->CreateOriginEnumerator(); } void CreateOriginTypeDirectory(const GURL& origin, fileapi::FileSystemType type) { - base::FilePath target = delegate_-> + base::FilePath target = context_-> GetBaseDirectoryForOriginAndType(origin, type, true); ASSERT_TRUE(!target.empty()); ASSERT_TRUE(base::DirectoryExists(target)); @@ -127,7 +126,7 @@ class SandboxFileSystemBackendTest : public testing::Test { if (error != base::PLATFORM_FILE_OK) return false; base::FilePath returned_root_path = - delegate_->GetBaseDirectoryForOriginAndType( + context_->GetBaseDirectoryForOriginAndType( origin_url, type, false /* create */); if (root_path) *root_path = returned_root_path; @@ -135,19 +134,18 @@ class SandboxFileSystemBackendTest : public testing::Test { } base::FilePath file_system_path() const { - return data_dir_.path().Append( - SandboxFileSystemBackendDelegate::kFileSystemDirectory); + return data_dir_.path().Append(SandboxContext::kFileSystemDirectory); } base::ScopedTempDir data_dir_; base::MessageLoop message_loop_; - scoped_ptr<SandboxFileSystemBackendDelegate> delegate_; + scoped_ptr<SandboxContext> context_; scoped_ptr<SandboxFileSystemBackend> backend_; }; TEST_F(SandboxFileSystemBackendTest, Empty) { SetUpNewBackend(CreateAllowFileAccessOptions()); - scoped_ptr<SandboxFileSystemBackendDelegate::OriginEnumerator> enumerator( + scoped_ptr<SandboxContext::OriginEnumerator> enumerator( CreateOriginEnumerator()); ASSERT_TRUE(enumerator->Next().is_empty()); } @@ -180,7 +178,7 @@ TEST_F(SandboxFileSystemBackendTest, EnumerateOrigins) { persistent_set.insert(GURL(persistent_origins[i])); } - scoped_ptr<SandboxFileSystemBackendDelegate::OriginEnumerator> enumerator( + scoped_ptr<SandboxContext::OriginEnumerator> enumerator( CreateOriginEnumerator()); size_t temporary_actual_size = 0; size_t persistent_actual_size = 0; diff --git a/chromium/webkit/browser/fileapi/sandbox_file_system_test_helper.cc b/chromium/webkit/browser/fileapi/sandbox_file_system_test_helper.cc index 97d7a5f2e4a..179bf9b2c1a 100644 --- a/chromium/webkit/browser/fileapi/sandbox_file_system_test_helper.cc +++ b/chromium/webkit/browser/fileapi/sandbox_file_system_test_helper.cc @@ -61,7 +61,7 @@ void SandboxFileSystemTestHelper::TearDown() { } base::FilePath SandboxFileSystemTestHelper::GetOriginRootPath() { - return file_system_context_->sandbox_delegate()-> + return file_system_context_->sandbox_context()-> GetBaseDirectoryForOriginAndType(origin_, type_, false); } @@ -80,8 +80,8 @@ base::FilePath SandboxFileSystemTestHelper::GetLocalPathFromASCII( } base::FilePath SandboxFileSystemTestHelper::GetUsageCachePath() const { - return file_system_context_->sandbox_delegate()-> - GetUsageCachePathForOriginAndType(origin_, type_); + return file_system_context_-> + sandbox_context()->GetUsageCachePathForOriginAndType(origin_, type_); } FileSystemURL SandboxFileSystemTestHelper::CreateURL( @@ -129,7 +129,7 @@ void SandboxFileSystemTestHelper::AddFileChangeObserver( } FileSystemUsageCache* SandboxFileSystemTestHelper::usage_cache() { - return file_system_context()->sandbox_delegate()->usage_cache(); + return file_system_context()->sandbox_context()->usage_cache(); } void SandboxFileSystemTestHelper::SetUpFileSystem() { @@ -140,7 +140,7 @@ void SandboxFileSystemTestHelper::SetUpFileSystem() { DCHECK(file_util_); // Prepare the origin's root directory. - file_system_context_->sandbox_delegate()-> + file_system_context_->sandbox_context()-> GetBaseDirectoryForOriginAndType(origin_, type_, true /* create */); // Initialize the usage cache file. diff --git a/chromium/webkit/browser/fileapi/sandbox_origin_database.cc b/chromium/webkit/browser/fileapi/sandbox_origin_database.cc index 4ce83017cc0..9ca399673fd 100644 --- a/chromium/webkit/browser/fileapi/sandbox_origin_database.cc +++ b/chromium/webkit/browser/fileapi/sandbox_origin_database.cc @@ -76,7 +76,7 @@ bool SandboxOriginDatabase::Init(InitOption init_option, std::string path = FilePathToString(db_path); leveldb::Options options; - options.max_open_files = 0; // Use minimum. + options.max_open_files = 64; // Use minimum. options.create_if_missing = true; leveldb::DB* db; leveldb::Status status = leveldb::DB::Open(options, path, &db); @@ -122,7 +122,7 @@ bool SandboxOriginDatabase::Init(InitOption init_option, bool SandboxOriginDatabase::RepairDatabase(const std::string& db_path) { DCHECK(!db_.get()); leveldb::Options options; - options.max_open_files = 0; // Use minimum. + options.max_open_files = 64; // Use minimum. if (!leveldb::RepairDB(db_path, options).ok() || !Init(FAIL_IF_NONEXISTENT, FAIL_ON_CORRUPTION)) { LOG(WARNING) << "Failed to repair SandboxOriginDatabase."; diff --git a/chromium/webkit/browser/fileapi/sandbox_quota_observer.cc b/chromium/webkit/browser/fileapi/sandbox_quota_observer.cc index fe5ee3796fb..02a47ee255c 100644 --- a/chromium/webkit/browser/fileapi/sandbox_quota_observer.cc +++ b/chromium/webkit/browser/fileapi/sandbox_quota_observer.cc @@ -7,7 +7,7 @@ #include "base/sequenced_task_runner.h" #include "webkit/browser/fileapi/file_system_url.h" #include "webkit/browser/fileapi/file_system_usage_cache.h" -#include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h" +#include "webkit/browser/fileapi/sandbox_context.h" #include "webkit/browser/fileapi/timed_task_helper.h" #include "webkit/browser/quota/quota_client.h" #include "webkit/browser/quota/quota_manager.h" @@ -107,7 +107,7 @@ base::FilePath SandboxQuotaObserver::GetUsageCachePath( DCHECK(sandbox_file_util_); base::PlatformFileError error = base::PLATFORM_FILE_OK; base::FilePath path = - SandboxFileSystemBackendDelegate::GetUsageCachePathForOriginAndType( + SandboxContext::GetUsageCachePathForOriginAndType( sandbox_file_util_, url.origin(), url.type(), &error); if (error != base::PLATFORM_FILE_OK) { LOG(WARNING) << "Could not get usage cache path for: " diff --git a/chromium/webkit/browser/fileapi/test_file_system_backend.cc b/chromium/webkit/browser/fileapi/test_file_system_backend.cc index 1cff5c2fb14..584e2e3a10d 100644 --- a/chromium/webkit/browser/fileapi/test_file_system_backend.cc +++ b/chromium/webkit/browser/fileapi/test_file_system_backend.cc @@ -66,6 +66,17 @@ class TestFileSystemBackend::QuotaUtil return usage_; } + virtual void InvalidateUsageCache(const GURL& origin_url, + FileSystemType type) OVERRIDE { + // Do nothing. + } + + virtual void StickyInvalidateUsageCache( + const GURL& origin, + FileSystemType type) OVERRIDE { + // Do nothing. + } + virtual void AddFileUpdateObserver( FileSystemType type, FileUpdateObserver* observer, diff --git a/chromium/webkit/common/gpu/context_provider_in_process.cc b/chromium/webkit/common/gpu/context_provider_in_process.cc index 1e42ab04d6b..e56da80fd0a 100644 --- a/chromium/webkit/common/gpu/context_provider_in_process.cc +++ b/chromium/webkit/common/gpu/context_provider_in_process.cc @@ -4,7 +4,6 @@ #include "webkit/common/gpu/context_provider_in_process.h" -#include "base/bind.h" #include "base/callback_helpers.h" #include "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h" #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" @@ -54,35 +53,6 @@ class ContextProviderInProcess::MemoryAllocationCallbackProxy ContextProviderInProcess* provider_; }; -// static -scoped_refptr<ContextProviderInProcess> ContextProviderInProcess::Create( - const CreateCallback& create_callback) { - scoped_refptr<ContextProviderInProcess> provider = - new ContextProviderInProcess; - if (!provider->InitializeOnMainThread(create_callback)) - return NULL; - return provider; -} - -static scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> -CreateOffscreenContext() { - WebKit::WebGraphicsContext3D::Attributes attributes; - attributes.depth = false; - attributes.stencil = true; - attributes.antialias = false; - attributes.shareResources = true; - attributes.noAutomaticFlushes = true; - - return WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( - attributes).Pass(); -} - -// static -scoped_refptr<ContextProviderInProcess> -ContextProviderInProcess::CreateOffscreen() { - return Create(base::Bind(&CreateOffscreenContext)); -} - ContextProviderInProcess::ContextProviderInProcess() : destroyed_(false) { DCHECK(main_thread_checker_.CalledOnValidThread()); @@ -94,13 +64,22 @@ ContextProviderInProcess::~ContextProviderInProcess() { context_thread_checker_.CalledOnValidThread()); } -bool ContextProviderInProcess::InitializeOnMainThread( - const CreateCallback& create_callback) { +bool ContextProviderInProcess::InitializeOnMainThread() { DCHECK(!context3d_); DCHECK(main_thread_checker_.CalledOnValidThread()); - DCHECK(!create_callback.is_null()); - context3d_ = create_callback.Run(); + WebKit::WebGraphicsContext3D::Attributes attributes; + attributes.depth = false; + attributes.stencil = true; + attributes.antialias = false; + attributes.shareResources = true; + attributes.noAutomaticFlushes = true; + + using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; + context3d_ = + WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( + attributes); + return context3d_; } diff --git a/chromium/webkit/common/gpu/context_provider_in_process.h b/chromium/webkit/common/gpu/context_provider_in_process.h index 169a1a8fdd3..b427abeb043 100644 --- a/chromium/webkit/common/gpu/context_provider_in_process.h +++ b/chromium/webkit/common/gpu/context_provider_in_process.h @@ -19,21 +19,17 @@ class WebGraphicsContext3D; namespace webkit { namespace gpu { class GrContextForWebGraphicsContext3D; -class WebGraphicsContext3DInProcessCommandBufferImpl; class WEBKIT_GPU_EXPORT ContextProviderInProcess : NON_EXPORTED_BASE(public cc::ContextProvider) { public: - typedef base::Callback< - scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>(void)> - CreateCallback; - - static scoped_refptr<ContextProviderInProcess> Create( - const CreateCallback& create_callback); - - // Calls Create() with a default factory method for creating an offscreen - // context. - static scoped_refptr<ContextProviderInProcess> CreateOffscreen(); + static scoped_refptr<ContextProviderInProcess> Create() { + scoped_refptr<ContextProviderInProcess> provider = + new ContextProviderInProcess; + if (!provider->InitializeOnMainThread()) + return NULL; + return provider; + } virtual bool BindToCurrentThread() OVERRIDE; virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE; @@ -47,8 +43,7 @@ class WEBKIT_GPU_EXPORT ContextProviderInProcess ContextProviderInProcess(); virtual ~ContextProviderInProcess(); - bool InitializeOnMainThread( - const CreateCallback& create_callback); + bool InitializeOnMainThread(); void OnLostContext(); void OnMemoryAllocationChanged(bool nonzero_allocation); diff --git a/chromium/webkit/common/gpu/test_context_provider_factory.cc b/chromium/webkit/common/gpu/test_context_provider_factory.cc index 7e4f04f949e..88464c00074 100644 --- a/chromium/webkit/common/gpu/test_context_provider_factory.cc +++ b/chromium/webkit/common/gpu/test_context_provider_factory.cc @@ -27,7 +27,7 @@ TestContextProviderFactory::~TestContextProviderFactory() {} scoped_refptr<cc::ContextProvider> TestContextProviderFactory:: OffscreenContextProviderForMainThread() { if (!main_thread_.get() || main_thread_->DestroyedOnMainThread()) { - main_thread_ = ContextProviderInProcess::CreateOffscreen(); + main_thread_ = ContextProviderInProcess::Create(); if (main_thread_.get() && !main_thread_->BindToCurrentThread()) main_thread_ = NULL; } diff --git a/chromium/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc b/chromium/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc index 66c7a53a525..886e40f5f46 100644 --- a/chromium/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc +++ b/chromium/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc @@ -66,11 +66,11 @@ static base::LazyInstance<GLES2Initializer> g_gles2_initializer = } // namespace anonymous // static -scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> +scoped_ptr<WebKit::WebGraphicsContext3D> WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext( const WebKit::WebGraphicsContext3D::Attributes& attributes, gfx::AcceleratedWidget window) { - scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context; + scoped_ptr<WebKit::WebGraphicsContext3D> context; if (gfx::GLSurface::InitializeOneOff()) { context.reset(new WebGraphicsContext3DInProcessCommandBufferImpl( scoped_ptr< ::gpu::GLInProcessContext>(), attributes, false, window)); @@ -79,7 +79,7 @@ WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext( } // static -scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> +scoped_ptr<WebKit::WebGraphicsContext3D> WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( const WebKit::WebGraphicsContext3D::Attributes& attributes) { return make_scoped_ptr(new WebGraphicsContext3DInProcessCommandBufferImpl( @@ -87,10 +87,10 @@ WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( attributes, true, gfx::kNullAcceleratedWidget)) - .Pass(); + .PassAs<WebKit::WebGraphicsContext3D>(); } -scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> +scoped_ptr<WebKit::WebGraphicsContext3D> WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext( scoped_ptr< ::gpu::GLInProcessContext> context, const WebKit::WebGraphicsContext3D::Attributes& attributes) { @@ -100,7 +100,7 @@ WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext( attributes, true /* is_offscreen. Not used. */, gfx::kNullAcceleratedWidget /* window. Not used. */)) - .Pass(); + .PassAs<WebKit::WebGraphicsContext3D>(); } WebGraphicsContext3DInProcessCommandBufferImpl:: diff --git a/chromium/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h b/chromium/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h index f96607d7dc3..d3620b411b2 100644 --- a/chromium/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h +++ b/chromium/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h @@ -48,19 +48,16 @@ namespace gpu { class WEBKIT_GPU_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl : public NON_EXPORTED_BASE(WebKit::WebGraphicsContext3D) { public: - static scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> - CreateViewContext( - const WebKit::WebGraphicsContext3D::Attributes& attributes, - gfx::AcceleratedWidget window); - - static scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> - CreateOffscreenContext( - const WebKit::WebGraphicsContext3D::Attributes& attributes); - - static scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> - WrapContext( - scoped_ptr< ::gpu::GLInProcessContext> context, - const WebKit::WebGraphicsContext3D::Attributes& attributes); + static scoped_ptr<WebKit::WebGraphicsContext3D> CreateViewContext( + const WebKit::WebGraphicsContext3D::Attributes& attributes, + gfx::AcceleratedWidget window); + + static scoped_ptr<WebKit::WebGraphicsContext3D> CreateOffscreenContext( + const WebKit::WebGraphicsContext3D::Attributes& attributes); + + static scoped_ptr<WebKit::WebGraphicsContext3D> WrapContext( + scoped_ptr< ::gpu::GLInProcessContext> context, + const WebKit::WebGraphicsContext3D::Attributes& attributes); virtual ~WebGraphicsContext3DInProcessCommandBufferImpl(); diff --git a/chromium/webkit/common/webpreferences.cc b/chromium/webkit/common/webpreferences.cc index 9ae6118b0ab..865b7199fed 100644 --- a/chromium/webkit/common/webpreferences.cc +++ b/chromium/webkit/common/webpreferences.cc @@ -126,7 +126,11 @@ WebPreferences::WebPreferences() double_tap_to_zoom_enabled(true), user_gesture_required_for_media_playback(true), support_deprecated_target_density_dpi(false), - use_wide_viewport(true) + use_legacy_background_size_shorthand_behavior(false), + wide_viewport_quirk(false), + use_wide_viewport(true), + viewport_meta_layout_size_quirk(false), + viewport_meta_zero_values_quirk(false) #endif { standard_font_family_map[webkit_glue::kCommonScript] = diff --git a/chromium/webkit/common/webpreferences.h b/chromium/webkit/common/webpreferences.h index 5f697d15527..45f7eb03643 100644 --- a/chromium/webkit/common/webpreferences.h +++ b/chromium/webkit/common/webpreferences.h @@ -169,7 +169,11 @@ struct WEBKIT_COMMON_EXPORT WebPreferences { bool user_gesture_required_for_media_playback; GURL default_video_poster_url; bool support_deprecated_target_density_dpi; + bool use_legacy_background_size_shorthand_behavior; + bool wide_viewport_quirk; bool use_wide_viewport; + bool viewport_meta_layout_size_quirk; + bool viewport_meta_zero_values_quirk; #endif // We try to keep the default values the same as the default values in diff --git a/chromium/webkit/glue/resources/webkit_strings_ar.xtb b/chromium/webkit/glue/resources/webkit_strings_ar.xtb index b2f2c5b0bb3..4dbc3a06f7c 100644 --- a/chromium/webkit/glue/resources/webkit_strings_ar.xtb +++ b/chromium/webkit/glue/resources/webkit_strings_ar.xtb @@ -31,7 +31,7 @@ <translation id="2723001399770238859">الصوت</translation> <translation id="6845533974506654842">اضغط</translation> <translation id="8244226242650769279">مخطّط صورة</translation> -<translation id="310520048233152454">الرجاء إدخال عنوان URL.</translation> +<translation id="310520048233152454">الرجاء إدخال عنوان URL.</translation> <translation id="9039488204461337220">محاولة الانتقال للأمام بسرعة</translation> <translation id="4812940957355064477">الرجاء إدخال عدد.</translation> <translation id="2548326553472216322">لا عمليات بحث حديثة</translation> @@ -77,7 +77,7 @@ <translation id="5466621249238537318">الرجاء تحديد ملف واحد أو أكثر.</translation> <translation id="9132465097189459683">آخر...</translation> <translation id="8750798805984357768">الرجاء اختيار أحد هذه الخيارات.</translation> -<translation id="7740050170769002709">محتوى HTML</translation> +<translation id="7740050170769002709">محتوى HTML</translation> <translation id="6692633176391053278">تخطي</translation> <translation id="8541249477527128034">التحكم في الوسائط</translation> <translation id="2226276347425096477">الرجاء اختصار هذا النص حتى يصل إلى <ph name="MAX_CHARACTERS"/> من الحروف أو أقل (أنت الآن تستخدم <ph name="CURRENT_LENGTH"/> من الحروف).</translation> @@ -101,7 +101,7 @@ <translation id="6643016212128521049">محو</translation> <translation id="4851297395436456855">تقديم سريع</translation> <translation id="1088086359088493902">ثوانٍ</translation> -<translation id="3934680773876859118">إخفاق تحميل مستند PDF</translation> +<translation id="3934680773876859118">إخفاق تحميل مستند PDF</translation> <translation id="3632707345189162177">عدد الثواني المتبقية من الفيلم</translation> <translation id="6359256949422175976">صورة مصغرة لشريط تمرير وقت الفيلم</translation> <translation id="8597182159515967513">العنوان</translation> diff --git a/chromium/webkit/glue/resources/webkit_strings_fa.xtb b/chromium/webkit/glue/resources/webkit_strings_fa.xtb index acb0ffac4cf..d64898e023d 100644 --- a/chromium/webkit/glue/resources/webkit_strings_fa.xtb +++ b/chromium/webkit/glue/resources/webkit_strings_fa.xtb @@ -31,7 +31,7 @@ <translation id="2723001399770238859">صدا</translation> <translation id="6845533974506654842">فشار دادن</translation> <translation id="8244226242650769279">نقشه تصویر</translation> -<translation id="310520048233152454">لطفاً یک URL وارد کنید.</translation> +<translation id="310520048233152454">لطفاً یک URL وارد کنید.</translation> <translation id="9039488204461337220">جستجو به جلو</translation> <translation id="4812940957355064477">لطفاً شمارهای را وارد کنید.</translation> <translation id="2548326553472216322">جستجوی جدیدی وجود ندارد</translation> @@ -77,7 +77,7 @@ <translation id="5466621249238537318">لطفاً یک یا چند فایل را انتخاب کنید.</translation> <translation id="9132465097189459683">موارد دیگر...</translation> <translation id="8750798805984357768">لطفاً یکی از این گزینهها را انتخاب کنید.</translation> -<translation id="7740050170769002709">محتوای HTML</translation> +<translation id="7740050170769002709">محتوای HTML</translation> <translation id="6692633176391053278">گام به گام</translation> <translation id="8541249477527128034">کنترل رسانه</translation> <translation id="2226276347425096477">لطفاً این متن را به اندازه <ph name="MAX_CHARACTERS"/> نویسه یا کمتر کوتاه کنید (شما در حال حاضر از <ph name="CURRENT_LENGTH"/> نویسه استفاده میکنید).</translation> @@ -101,7 +101,7 @@ <translation id="6643016212128521049">پاک کردن</translation> <translation id="4851297395436456855">سریع به جلو</translation> <translation id="1088086359088493902">ثانیه</translation> -<translation id="3934680773876859118">بارگیری سند PDF انجام نشد</translation> +<translation id="3934680773876859118">بارگیری سند PDF انجام نشد</translation> <translation id="3632707345189162177">مقدار ثانیههای باقیمانده فیلم</translation> <translation id="6359256949422175976">نشانگر حذفکننده زمان فیلم</translation> <translation id="8597182159515967513">عنوان</translation> diff --git a/chromium/webkit/glue/resources/webkit_strings_iw.xtb b/chromium/webkit/glue/resources/webkit_strings_iw.xtb index a2c31fbc68c..e0adf0e94e1 100644 --- a/chromium/webkit/glue/resources/webkit_strings_iw.xtb +++ b/chromium/webkit/glue/resources/webkit_strings_iw.xtb @@ -77,7 +77,7 @@ <translation id="5466621249238537318">בחר קובץ אחד או יותר.</translation> <translation id="9132465097189459683">אחר...</translation> <translation id="8750798805984357768">בחר אחת מהאפשרויות הבאות.</translation> -<translation id="7740050170769002709">תוכן HTML</translation> +<translation id="7740050170769002709">תוכן HTML</translation> <translation id="6692633176391053278">פקד חצים</translation> <translation id="8541249477527128034">שליטה במדיה</translation> <translation id="2226276347425096477">קצר טקסט זה ל-<ph name="MAX_CHARACTERS"/> תווים או פחות (אתה משתמש כעת ב-<ph name="CURRENT_LENGTH"/> תווים).</translation> @@ -101,7 +101,7 @@ <translation id="6643016212128521049">נקה</translation> <translation id="4851297395436456855">הרץ קדימה</translation> <translation id="1088086359088493902">שניות</translation> -<translation id="3934680773876859118">הטעינה של מסמך PDF נכשלה</translation> +<translation id="3934680773876859118">הטעינה של מסמך PDF נכשלה</translation> <translation id="3632707345189162177">מספר שניות שנותרו עד לסיום הסרט</translation> <translation id="6359256949422175976">תמונה ממוזערת של מסתיר זמן סרט</translation> <translation id="8597182159515967513">כותרת</translation> diff --git a/chromium/webkit/glue/resources/webkit_strings_nl.xtb b/chromium/webkit/glue/resources/webkit_strings_nl.xtb index b52f04aa964..5f813c93006 100644 --- a/chromium/webkit/glue/resources/webkit_strings_nl.xtb +++ b/chromium/webkit/glue/resources/webkit_strings_nl.xtb @@ -55,7 +55,7 @@ <translation id="8987927404178983737">Maand</translation> <translation id="8115662671911883373">het weergeven van ondertiteling starten</translation> <translation id="7364796246159120393">Bestand kiezen</translation> -<translation id="2761667185364618470">Vink dit selectievakje aan als u wilt doorgaan.</translation> +<translation id="2761667185364618470">Vink dit selectievakje aan als je wilt doorgaan.</translation> <translation id="8534579021159131403">Minuten</translation> <translation id="819205353528511139">film afspelen op volledig scherm</translation> <translation id="8964020114565522021">Sleep bestand hier naartoe</translation> @@ -80,7 +80,7 @@ <translation id="7740050170769002709">HTML-inhoud</translation> <translation id="6692633176391053278">stappenregelaar</translation> <translation id="8541249477527128034">mediacontrole</translation> -<translation id="2226276347425096477">Kort deze tekst in tot <ph name="MAX_CHARACTERS"/> tekens of minder (u gebruikt momenteel <ph name="CURRENT_LENGTH"/> tekens).</translation> +<translation id="2226276347425096477">Kort deze tekst in tot <ph name="MAX_CHARACTERS"/> tekens of minder (je gebruikt momenteel <ph name="CURRENT_LENGTH"/> tekens).</translation> <translation id="6101327004457443354">dempen van audiotrack opheffen</translation> <translation id="1822429046913737220">a.m./p.m.</translation> <translation id="1639239467298939599">Laden</translation> diff --git a/chromium/webkit/glue/resources/webkit_strings_ru.xtb b/chromium/webkit/glue/resources/webkit_strings_ru.xtb index 57d1920f7f6..43f80d90e0c 100644 --- a/chromium/webkit/glue/resources/webkit_strings_ru.xtb +++ b/chromium/webkit/glue/resources/webkit_strings_ru.xtb @@ -82,10 +82,10 @@ <translation id="8541249477527128034">управление мультимедиа</translation> <translation id="2226276347425096477">Длина текста не должна превышать <ph name="MAX_CHARACTERS"/> симв. (сейчас <ph name="CURRENT_LENGTH"/> симв.).</translation> <translation id="6101327004457443354">включение звуковой дорожки</translation> -<translation id="1822429046913737220">до полудня/после полудня</translation> +<translation id="1822429046913737220">AM/PM</translation> <translation id="1639239467298939599">Загрузка</translation> <translation id="2908441821576996758">Введите адреса электронной почты через запятую.</translation> -<translation id="5939518447894949180">Изменить</translation> +<translation id="5939518447894949180">Сбросить</translation> <translation id="1921819250265091946">дд</translation> <translation id="835897206747267392">Недопустимые данные.</translation> <translation id="1842960171412779397">выбрать</translation> diff --git a/chromium/webkit/glue/simple_webmimeregistry_impl.cc b/chromium/webkit/glue/simple_webmimeregistry_impl.cc index 48364efbeeb..8340458df38 100644 --- a/chromium/webkit/glue/simple_webmimeregistry_impl.cc +++ b/chromium/webkit/glue/simple_webmimeregistry_impl.cc @@ -94,4 +94,12 @@ WebString SimpleWebMimeRegistryImpl::mimeTypeFromFile( return WebString::fromUTF8(mime_type); } +WebString SimpleWebMimeRegistryImpl::preferredExtensionForMIMEType( + const WebString& mime_type) { + base::FilePath::StringType file_extension; + net::GetPreferredExtensionForMimeType(ToASCIIOrEmpty(mime_type), + &file_extension); + return base::FilePath(file_extension).AsUTF16Unsafe(); +} + } // namespace webkit_glue diff --git a/chromium/webkit/glue/simple_webmimeregistry_impl.h b/chromium/webkit/glue/simple_webmimeregistry_impl.h index 1055dfe18ab..39972ebe516 100644 --- a/chromium/webkit/glue/simple_webmimeregistry_impl.h +++ b/chromium/webkit/glue/simple_webmimeregistry_impl.h @@ -45,6 +45,8 @@ class WEBKIT_GLUE_EXPORT SimpleWebMimeRegistryImpl : virtual WebKit::WebString wellKnownMimeTypeForExtension( const WebKit::WebString&); virtual WebKit::WebString mimeTypeFromFile(const WebKit::WebString&); + virtual WebKit::WebString preferredExtensionForMIMEType( + const WebKit::WebString&); }; } // namespace webkit_glue diff --git a/chromium/webkit/renderer/fileapi/OWNERS b/chromium/webkit/renderer/fileapi/OWNERS new file mode 100644 index 00000000000..13c32887350 --- /dev/null +++ b/chromium/webkit/renderer/fileapi/OWNERS @@ -0,0 +1 @@ +ericu@chromium.org diff --git a/chromium/webkit/renderer/fileapi/webfilewriter_base.cc b/chromium/webkit/renderer/fileapi/webfilewriter_base.cc new file mode 100644 index 00000000000..92c7ae1db20 --- /dev/null +++ b/chromium/webkit/renderer/fileapi/webfilewriter_base.cc @@ -0,0 +1,154 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "webkit/renderer/fileapi/webfilewriter_base.h" + +#include "base/logging.h" +#include "third_party/WebKit/public/platform/WebURL.h" +#include "third_party/WebKit/public/web/WebFileError.h" +#include "third_party/WebKit/public/web/WebFileWriterClient.h" +#include "webkit/common/fileapi/file_system_util.h" + +namespace fileapi { + +WebFileWriterBase::WebFileWriterBase( + const GURL& path, WebKit::WebFileWriterClient* client) + : path_(path), + client_(client), + operation_(kOperationNone), + cancel_state_(kCancelNotInProgress) { +} + +WebFileWriterBase::~WebFileWriterBase() { +} + +void WebFileWriterBase::truncate(long long length) { + DCHECK(kOperationNone == operation_); + DCHECK(kCancelNotInProgress == cancel_state_); + operation_ = kOperationTruncate; + DoTruncate(path_, length); +} + +void WebFileWriterBase::write( + long long position, + const WebKit::WebURL& blob_url) { + DCHECK(kOperationNone == operation_); + DCHECK(kCancelNotInProgress == cancel_state_); + operation_ = kOperationWrite; + DoWrite(path_, blob_url, position); +} + +// When we cancel a write/truncate, we always get back the result of the write +// before the result of the cancel, no matter what happens. +// So we'll get back either +// success [of the write/truncate, in a DidWrite(XXX, true)/DidSucceed() call] +// followed by failure [of the cancel]; or +// failure [of the write, either from cancel or other reasons] followed by +// the result of the cancel. +// In the write case, there could also be queued up non-terminal DidWrite calls +// before any of that comes back, but there will always be a terminal write +// response [success or failure] after them, followed by the cancel result, so +// we can ignore non-terminal write responses, take the terminal write success +// or the first failure as the last write response, then know that the next +// thing to come back is the cancel response. We only notify the +// AsyncFileWriterClient when it's all over. +void WebFileWriterBase::cancel() { + // Check for the cancel passing the previous operation's return in-flight. + if (kOperationWrite != operation_ && kOperationTruncate != operation_) + return; + if (kCancelNotInProgress != cancel_state_) + return; + cancel_state_ = kCancelSent; + DoCancel(); +} + +void WebFileWriterBase::DidFinish(base::PlatformFileError error_code) { + if (error_code == base::PLATFORM_FILE_OK) + DidSucceed(); + else + DidFail(error_code); +} + +void WebFileWriterBase::DidWrite(int64 bytes, bool complete) { + DCHECK(kOperationWrite == operation_); + switch (cancel_state_) { + case kCancelNotInProgress: + if (complete) + operation_ = kOperationNone; + client_->didWrite(bytes, complete); + break; + case kCancelSent: + // This is the success call of the write, which we'll eat, even though + // it succeeded before the cancel got there. We accepted the cancel call, + // so the write will eventually return an error. + if (complete) + cancel_state_ = kCancelReceivedWriteResponse; + break; + case kCancelReceivedWriteResponse: + default: + NOTREACHED(); + } +} + +void WebFileWriterBase::DidSucceed() { + // Write never gets a DidSucceed call, so this is either a cancel or truncate + // response. + switch (cancel_state_) { + case kCancelNotInProgress: + // A truncate succeeded, with no complications. + DCHECK(kOperationTruncate == operation_); + operation_ = kOperationNone; + client_->didTruncate(); + break; + case kCancelSent: + DCHECK(kOperationTruncate == operation_); + // This is the success call of the truncate, which we'll eat, even though + // it succeeded before the cancel got there. We accepted the cancel call, + // so the truncate will eventually return an error. + cancel_state_ = kCancelReceivedWriteResponse; + break; + case kCancelReceivedWriteResponse: + // This is the success of the cancel operation. + FinishCancel(); + break; + default: + NOTREACHED(); + } +} + +void WebFileWriterBase::DidFail(base::PlatformFileError error_code) { + DCHECK(kOperationNone != operation_); + switch (cancel_state_) { + case kCancelNotInProgress: + // A write or truncate failed. + operation_ = kOperationNone; + client_->didFail( + PlatformFileErrorToWebFileError(error_code)); + break; + case kCancelSent: + // This is the failure of a write or truncate; the next message should be + // the result of the cancel. We don't assume that it'll be a success, as + // the write/truncate could have failed for other reasons. + cancel_state_ = kCancelReceivedWriteResponse; + break; + case kCancelReceivedWriteResponse: + // The cancel reported failure, meaning that the write or truncate + // finished before the cancel got there. But we suppressed the + // write/truncate's response, and will now report that it was cancelled. + FinishCancel(); + break; + default: + NOTREACHED(); + } +} + +void WebFileWriterBase::FinishCancel() { + DCHECK(kCancelReceivedWriteResponse == cancel_state_); + DCHECK(kOperationNone != operation_); + cancel_state_ = kCancelNotInProgress; + operation_ = kOperationNone; + client_->didFail(WebKit::WebFileErrorAbort); +} + +} // namespace fileapi diff --git a/chromium/webkit/renderer/fileapi/webfilewriter_base.h b/chromium/webkit/renderer/fileapi/webfilewriter_base.h new file mode 100644 index 00000000000..dc1d730163d --- /dev/null +++ b/chromium/webkit/renderer/fileapi/webfilewriter_base.h @@ -0,0 +1,71 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef WEBKIT_RENDERER_FILEAPI_WEBFILEWRITER_BASE_H_ +#define WEBKIT_RENDERER_FILEAPI_WEBFILEWRITER_BASE_H_ + +#include "base/platform_file.h" +#include "third_party/WebKit/public/web/WebFileWriter.h" +#include "url/gurl.h" +#include "webkit/renderer/webkit_storage_renderer_export.h" + +namespace WebKit { +class WebFileWriterClient; +class WebURL; +} + +namespace fileapi { + +class WEBKIT_STORAGE_RENDERER_EXPORT WebFileWriterBase + : public NON_EXPORTED_BASE(WebKit::WebFileWriter) { + public: + WebFileWriterBase( + const GURL& path, WebKit::WebFileWriterClient* client); + virtual ~WebFileWriterBase(); + + // WebFileWriter implementation + virtual void truncate(long long length); + virtual void write(long long position, const WebKit::WebURL& blobURL); + virtual void cancel(); + + protected: + // This calls DidSucceed() or DidFail() based on the value of |error_code|. + void DidFinish(base::PlatformFileError error_code); + + void DidWrite(int64 bytes, bool complete); + void DidSucceed(); + void DidFail(base::PlatformFileError error_code); + + // Derived classes must provide these methods to asynchronously perform + // the requested operation, and they must call the appropiate DidSomething + // method upon completion and as progress is made in the Write case. + virtual void DoTruncate(const GURL& path, int64 offset) = 0; + virtual void DoWrite(const GURL& path, const GURL& blob_url, + int64 offset) = 0; + virtual void DoCancel() = 0; + + private: + enum OperationType { + kOperationNone, + kOperationWrite, + kOperationTruncate + }; + + enum CancelState { + kCancelNotInProgress, + kCancelSent, + kCancelReceivedWriteResponse, + }; + + void FinishCancel(); + + GURL path_; + WebKit::WebFileWriterClient* client_; + OperationType operation_; + CancelState cancel_state_; +}; + +} // namespace fileapi + +#endif // WEBKIT_RENDERER_FILEAPI_WEBFILEWRITER_BASE_H_ diff --git a/chromium/webkit/renderer/fileapi/webfilewriter_base_unittest.cc b/chromium/webkit/renderer/fileapi/webfilewriter_base_unittest.cc new file mode 100644 index 00000000000..d7067380b95 --- /dev/null +++ b/chromium/webkit/renderer/fileapi/webfilewriter_base_unittest.cc @@ -0,0 +1,411 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "webkit/renderer/fileapi/webfilewriter_base.h" + +#include "base/logging.h" +#include "base/memory/scoped_ptr.h" +#include "base/message_loop/message_loop.h" +#include "base/strings/utf_string_conversions.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "third_party/WebKit/public/platform/WebURL.h" +#include "third_party/WebKit/public/web/WebFileError.h" +#include "third_party/WebKit/public/web/WebFileWriterClient.h" +#include "url/gurl.h" + +namespace fileapi { + +namespace { + +// We use particular offsets to trigger particular behaviors +// in the TestableFileWriter. +const int kNoOffset = -1; +const int kBasicFileTruncate_Offset = 1; +const int kErrorFileTruncate_Offset = 2; +const int kCancelFileTruncate_Offset = 3; +const int kCancelFailedTruncate_Offset = 4; +const int kBasicFileWrite_Offset = 1; +const int kErrorFileWrite_Offset = 2; +const int kMultiFileWrite_Offset = 3; +const int kCancelFileWriteBeforeCompletion_Offset = 4; +const int kCancelFileWriteAfterCompletion_Offset = 5; + +GURL mock_path_as_gurl() { + return GURL("MockPath"); +} + +} // namespace + +class TestableFileWriter : public WebFileWriterBase { + public: + explicit TestableFileWriter(WebKit::WebFileWriterClient* client) + : WebFileWriterBase(mock_path_as_gurl(), client) { + reset(); + } + + void reset() { + received_truncate_ = false; + received_truncate_path_ = GURL(); + received_truncate_offset_ = kNoOffset; + received_write_ = false; + received_write_path_ = GURL(); + received_write_offset_ = kNoOffset; + received_write_blob_url_ = GURL(); + received_cancel_ = false; + } + + bool received_truncate_; + GURL received_truncate_path_; + int64 received_truncate_offset_; + bool received_write_; + GURL received_write_path_; + GURL received_write_blob_url_; + int64 received_write_offset_; + bool received_cancel_; + + protected: + virtual void DoTruncate(const GURL& path, int64 offset) OVERRIDE { + received_truncate_ = true; + received_truncate_path_ = path; + received_truncate_offset_ = offset; + + if (offset == kBasicFileTruncate_Offset) { + DidSucceed(); + } else if (offset == kErrorFileTruncate_Offset) { + DidFail(base::PLATFORM_FILE_ERROR_NOT_FOUND); + } else if (offset == kCancelFileTruncate_Offset) { + cancel(); + DidSucceed(); // truncate completion + DidSucceed(); // cancel completion + } else if (offset == kCancelFailedTruncate_Offset) { + cancel(); + DidFail(base::PLATFORM_FILE_ERROR_NOT_FOUND); // truncate completion + DidSucceed(); // cancel completion + } else { + FAIL(); + } + } + + virtual void DoWrite(const GURL& path, const GURL& blob_url, + int64 offset) OVERRIDE { + received_write_ = true; + received_write_path_ = path; + received_write_offset_ = offset; + received_write_blob_url_ = blob_url; + + if (offset == kBasicFileWrite_Offset) { + DidWrite(1, true); + } else if (offset == kErrorFileWrite_Offset) { + DidFail(base::PLATFORM_FILE_ERROR_NOT_FOUND); + } else if (offset == kMultiFileWrite_Offset) { + DidWrite(1, false); + DidWrite(1, false); + DidWrite(1, true); + } else if (offset == kCancelFileWriteBeforeCompletion_Offset) { + DidWrite(1, false); + cancel(); + DidWrite(1, false); + DidWrite(1, false); + DidFail(base::PLATFORM_FILE_ERROR_FAILED); // write completion + DidSucceed(); // cancel completion + } else if (offset == kCancelFileWriteAfterCompletion_Offset) { + DidWrite(1, false); + cancel(); + DidWrite(1, false); + DidWrite(1, false); + DidWrite(1, true); // write completion + DidFail(base::PLATFORM_FILE_ERROR_FAILED); // cancel completion + } else { + FAIL(); + } + } + + virtual void DoCancel() OVERRIDE { + received_cancel_ = true; + } +}; + +class FileWriterTest : public testing::Test, + public WebKit::WebFileWriterClient { + public: + FileWriterTest() { + reset(); + } + + WebKit::WebFileWriter* writer() { + return testable_writer_.get(); + } + + // WebFileWriterClient overrides + virtual void didWrite(long long bytes, bool complete) { + EXPECT_FALSE(received_did_write_complete_); + ++received_did_write_count_; + received_did_write_bytes_total_ += bytes; + if (complete) + received_did_write_complete_ = true; + + if (delete_in_client_callback_) + testable_writer_.reset(NULL); + } + + virtual void didTruncate() { + EXPECT_FALSE(received_did_truncate_); + received_did_truncate_ = true; + if (delete_in_client_callback_) + testable_writer_.reset(NULL); + } + + virtual void didFail(WebKit::WebFileError error) { + EXPECT_FALSE(received_did_fail_); + received_did_fail_ = true; + fail_error_received_ = error; + if (delete_in_client_callback_) + testable_writer_.reset(NULL); + } + + protected: + void reset() { + testable_writer_.reset(new TestableFileWriter(this)); + delete_in_client_callback_ = false; + received_did_write_count_ = 0; + received_did_write_bytes_total_ = 0; + received_did_write_complete_ = false; + received_did_truncate_ = false; + received_did_fail_ = false; + fail_error_received_ = static_cast<WebKit::WebFileError>(0); + } + + scoped_ptr<TestableFileWriter> testable_writer_; + bool delete_in_client_callback_; + + // Observed WebFileWriterClient artifacts. + int received_did_write_count_; + long long received_did_write_bytes_total_; + bool received_did_write_complete_; + bool received_did_truncate_; + bool received_did_fail_; + WebKit::WebFileError fail_error_received_; + + DISALLOW_COPY_AND_ASSIGN(FileWriterTest); +}; + +TEST_F(FileWriterTest, BasicFileWrite) { + // Call the webkit facing api. + const GURL kBlobUrl("blob://bloburl/"); + writer()->write(kBasicFileWrite_Offset, kBlobUrl); + + // Check that the derived class gets called correctly. + EXPECT_TRUE(testable_writer_->received_write_); + EXPECT_EQ(testable_writer_->received_write_path_, + mock_path_as_gurl()); + EXPECT_EQ(kBasicFileWrite_Offset, + testable_writer_->received_write_offset_); + EXPECT_EQ(kBlobUrl, testable_writer_->received_write_blob_url_); + EXPECT_FALSE(testable_writer_->received_truncate_); + EXPECT_FALSE(testable_writer_->received_cancel_); + + // Check that the client gets called correctly. + EXPECT_EQ(1, received_did_write_count_); + EXPECT_TRUE(received_did_write_complete_); + EXPECT_EQ(1, received_did_write_bytes_total_); + EXPECT_FALSE(received_did_truncate_); + EXPECT_FALSE(received_did_fail_); +} + +TEST_F(FileWriterTest, BasicFileTruncate) { + // Call the webkit facing api. + writer()->truncate(kBasicFileTruncate_Offset); + + // Check that the derived class gets called correctly. + EXPECT_TRUE(testable_writer_->received_truncate_); + EXPECT_EQ(mock_path_as_gurl(), + testable_writer_->received_truncate_path_); + EXPECT_EQ(kBasicFileTruncate_Offset, + testable_writer_->received_truncate_offset_); + EXPECT_FALSE(testable_writer_->received_write_); + EXPECT_FALSE(testable_writer_->received_cancel_); + + // Check that the client gets called correctly. + EXPECT_TRUE(received_did_truncate_); + EXPECT_EQ(0, received_did_write_count_); + EXPECT_FALSE(received_did_fail_); +} + +TEST_F(FileWriterTest, ErrorFileWrite) { + // Call the webkit facing api. + const GURL kBlobUrl("blob://bloburl/"); + writer()->write(kErrorFileWrite_Offset, kBlobUrl); + + // Check that the derived class gets called correctly. + EXPECT_TRUE(testable_writer_->received_write_); + EXPECT_EQ(testable_writer_->received_write_path_, + mock_path_as_gurl()); + EXPECT_EQ(kErrorFileWrite_Offset, + testable_writer_->received_write_offset_); + EXPECT_EQ(kBlobUrl, testable_writer_->received_write_blob_url_); + EXPECT_FALSE(testable_writer_->received_truncate_); + EXPECT_FALSE(testable_writer_->received_cancel_); + + // Check that the client gets called correctly. + EXPECT_TRUE(received_did_fail_); + EXPECT_EQ(WebKit::WebFileErrorNotFound, fail_error_received_); + EXPECT_EQ(0, received_did_write_count_); + EXPECT_FALSE(received_did_truncate_); +} + +TEST_F(FileWriterTest, ErrorFileTruncate) { + // Call the webkit facing api. + writer()->truncate(kErrorFileTruncate_Offset); + + // Check that the derived class gets called correctly. + EXPECT_TRUE(testable_writer_->received_truncate_); + EXPECT_EQ(mock_path_as_gurl(), + testable_writer_->received_truncate_path_); + EXPECT_EQ(kErrorFileTruncate_Offset, + testable_writer_->received_truncate_offset_); + EXPECT_FALSE(testable_writer_->received_write_); + EXPECT_FALSE(testable_writer_->received_cancel_); + + // Check that the client gets called correctly. + EXPECT_TRUE(received_did_fail_); + EXPECT_EQ(WebKit::WebFileErrorNotFound, fail_error_received_); + EXPECT_FALSE(received_did_truncate_); + EXPECT_EQ(0, received_did_write_count_); +} + +TEST_F(FileWriterTest, MultiFileWrite) { + // Call the webkit facing api. + const GURL kBlobUrl("blob://bloburl/"); + writer()->write(kMultiFileWrite_Offset, kBlobUrl); + + // Check that the derived class gets called correctly. + EXPECT_TRUE(testable_writer_->received_write_); + EXPECT_EQ(testable_writer_->received_write_path_, + mock_path_as_gurl()); + EXPECT_EQ(kMultiFileWrite_Offset, + testable_writer_->received_write_offset_); + EXPECT_EQ(kBlobUrl, testable_writer_->received_write_blob_url_); + EXPECT_FALSE(testable_writer_->received_truncate_); + EXPECT_FALSE(testable_writer_->received_cancel_); + + // Check that the client gets called correctly. + EXPECT_EQ(3, received_did_write_count_); + EXPECT_TRUE(received_did_write_complete_); + EXPECT_EQ(3, received_did_write_bytes_total_); + EXPECT_FALSE(received_did_truncate_); + EXPECT_FALSE(received_did_fail_); +} + +TEST_F(FileWriterTest, CancelFileWriteBeforeCompletion) { + // Call the webkit facing api. + const GURL kBlobUrl("blob://bloburl/"); + writer()->write(kCancelFileWriteBeforeCompletion_Offset, kBlobUrl); + + // Check that the derived class gets called correctly. + EXPECT_TRUE(testable_writer_->received_write_); + EXPECT_EQ(testable_writer_->received_write_path_, + mock_path_as_gurl()); + EXPECT_EQ(kCancelFileWriteBeforeCompletion_Offset, + testable_writer_->received_write_offset_); + EXPECT_EQ(kBlobUrl, testable_writer_->received_write_blob_url_); + EXPECT_TRUE(testable_writer_->received_cancel_); + EXPECT_FALSE(testable_writer_->received_truncate_); + + // Check that the client gets called correctly. + EXPECT_TRUE(received_did_fail_); + EXPECT_EQ(WebKit::WebFileErrorAbort, fail_error_received_); + EXPECT_EQ(1, received_did_write_count_); + EXPECT_FALSE(received_did_write_complete_); + EXPECT_EQ(1, received_did_write_bytes_total_); + EXPECT_FALSE(received_did_truncate_); +} + +TEST_F(FileWriterTest, CancelFileWriteAfterCompletion) { + // Call the webkit facing api. + const GURL kBlobUrl("blob://bloburl/"); + writer()->write(kCancelFileWriteAfterCompletion_Offset, kBlobUrl); + + // Check that the derived class gets called correctly. + EXPECT_TRUE(testable_writer_->received_write_); + EXPECT_EQ(testable_writer_->received_write_path_, + mock_path_as_gurl()); + EXPECT_EQ(kCancelFileWriteAfterCompletion_Offset, + testable_writer_->received_write_offset_); + EXPECT_EQ(kBlobUrl, testable_writer_->received_write_blob_url_); + EXPECT_TRUE(testable_writer_->received_cancel_); + EXPECT_FALSE(testable_writer_->received_truncate_); + + // Check that the client gets called correctly. + EXPECT_TRUE(received_did_fail_); + EXPECT_EQ(WebKit::WebFileErrorAbort, fail_error_received_); + EXPECT_EQ(1, received_did_write_count_); + EXPECT_FALSE(received_did_write_complete_); + EXPECT_EQ(1, received_did_write_bytes_total_); + EXPECT_FALSE(received_did_truncate_); +} + +TEST_F(FileWriterTest, CancelFileTruncate) { + // Call the webkit facing api. + writer()->truncate(kCancelFileTruncate_Offset); + + // Check that the derived class gets called correctly. + EXPECT_TRUE(testable_writer_->received_truncate_); + EXPECT_EQ(mock_path_as_gurl(), + testable_writer_->received_truncate_path_); + EXPECT_EQ(kCancelFileTruncate_Offset, + testable_writer_->received_truncate_offset_); + EXPECT_TRUE(testable_writer_->received_cancel_); + EXPECT_FALSE(testable_writer_->received_write_); + + // Check that the client gets called correctly. + EXPECT_TRUE(received_did_fail_); + EXPECT_EQ(WebKit::WebFileErrorAbort, fail_error_received_); + EXPECT_FALSE(received_did_truncate_); + EXPECT_EQ(0, received_did_write_count_); +} + +TEST_F(FileWriterTest, CancelFailedTruncate) { + // Call the webkit facing api. + writer()->truncate(kCancelFailedTruncate_Offset); + + // Check that the derived class gets called correctly. + EXPECT_TRUE(testable_writer_->received_truncate_); + EXPECT_EQ(mock_path_as_gurl(), + testable_writer_->received_truncate_path_); + EXPECT_EQ(kCancelFailedTruncate_Offset, + testable_writer_->received_truncate_offset_); + EXPECT_TRUE(testable_writer_->received_cancel_); + EXPECT_FALSE(testable_writer_->received_write_); + + // Check that the client gets called correctly. + EXPECT_TRUE(received_did_fail_); + EXPECT_EQ(WebKit::WebFileErrorAbort, fail_error_received_); + EXPECT_FALSE(received_did_truncate_); + EXPECT_EQ(0, received_did_write_count_); +} + +TEST_F(FileWriterTest, DeleteInCompletionCallbacks) { + delete_in_client_callback_ = true; + writer()->write(kBasicFileWrite_Offset, GURL("blob://bloburl/")); + EXPECT_FALSE(testable_writer_.get()); + + reset(); + delete_in_client_callback_ = true; + writer()->truncate(kBasicFileTruncate_Offset); + EXPECT_FALSE(testable_writer_.get()); + + reset(); + delete_in_client_callback_ = true; + writer()->write(kErrorFileWrite_Offset, GURL("blob://bloburl/")); + EXPECT_FALSE(testable_writer_.get()); + + reset(); + delete_in_client_callback_ = true; + writer()->truncate(kErrorFileTruncate_Offset); + EXPECT_FALSE(testable_writer_.get()); + + // Not crashing counts as passing. +} + +} // namespace fileapi diff --git a/chromium/webkit/renderer/webkit_storage_renderer_export.h b/chromium/webkit/renderer/webkit_storage_renderer_export.h new file mode 100644 index 00000000000..4225bc683e9 --- /dev/null +++ b/chromium/webkit/renderer/webkit_storage_renderer_export.h @@ -0,0 +1,29 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef WEBKIT_RENDERER_WEBKIT_STORAGE_RENDERER_EXPORT_H_ +#define WEBKIT_RENDERER_WEBKIT_STORAGE_RENDERER_EXPORT_H_ + +#if defined(COMPONENT_BUILD) +#if defined(WIN32) + +#if defined(WEBKIT_STORAGE_RENDERER_IMPLEMENTATION) +#define WEBKIT_STORAGE_RENDERER_EXPORT __declspec(dllexport) +#else +#define WEBKIT_STORAGE_RENDERER_EXPORT __declspec(dllimport) +#endif // defined(WEBKIT_STORAGE_RENDERER_IMPLEMENTATION) + +#else // defined(WIN32) +#if defined(WEBKIT_STORAGE_RENDERER_IMPLEMENTATION) +#define WEBKIT_STORAGE_RENDERER_EXPORT __attribute__((visibility("default"))) +#else +#define WEBKIT_STORAGE_RENDERER_EXPORT +#endif +#endif + +#else // defined(COMPONENT_BUILD) +#define WEBKIT_STORAGE_RENDERER_EXPORT +#endif + +#endif // WEBKIT_RENDERER_WEBKIT_STORAGE_RENDERER_EXPORT_H_ diff --git a/chromium/webkit/renderer/webpreferences_renderer.cc b/chromium/webkit/renderer/webpreferences_renderer.cc index 0b0738534a0..5952110c88e 100644 --- a/chromium/webkit/renderer/webpreferences_renderer.cc +++ b/chromium/webkit/renderer/webpreferences_renderer.cc @@ -331,7 +331,14 @@ void ApplyWebPreferences(const WebPreferences& prefs, WebView* web_view) { ASCIIToUTF16(prefs.default_video_poster_url.spec())); settings->setSupportDeprecatedTargetDensityDPI( prefs.support_deprecated_target_density_dpi); + settings->setUseLegacyBackgroundSizeShorthandBehavior( + prefs.use_legacy_background_size_shorthand_behavior); + settings->setWideViewportQuirkEnabled(prefs.wide_viewport_quirk); settings->setUseWideViewport(prefs.use_wide_viewport); + settings->setViewportMetaLayoutSizeQuirk( + prefs.viewport_meta_layout_size_quirk); + settings->setViewportMetaZeroValuesQuirk( + prefs.viewport_meta_zero_values_quirk); #endif WebNetworkStateNotifier::setOnLine(prefs.is_online); diff --git a/chromium/webkit/storage_browser.gyp b/chromium/webkit/storage_browser.gyp index 04d25656bd5..04e609ae6fc 100644 --- a/chromium/webkit/storage_browser.gyp +++ b/chromium/webkit/storage_browser.gyp @@ -154,14 +154,14 @@ 'browser/fileapi/recursive_operation_delegate.h', 'browser/fileapi/remove_operation_delegate.cc', 'browser/fileapi/remove_operation_delegate.h', + 'browser/fileapi/sandbox_context.cc', + 'browser/fileapi/sandbox_context.h', 'browser/fileapi/sandbox_directory_database.cc', 'browser/fileapi/sandbox_directory_database.h', 'browser/fileapi/sandbox_file_stream_writer.cc', 'browser/fileapi/sandbox_file_stream_writer.h', 'browser/fileapi/sandbox_file_system_backend.cc', 'browser/fileapi/sandbox_file_system_backend.h', - 'browser/fileapi/sandbox_file_system_backend_delegate.cc', - 'browser/fileapi/sandbox_file_system_backend_delegate.h', 'browser/fileapi/sandbox_isolated_origin_database.cc', 'browser/fileapi/sandbox_isolated_origin_database.h', 'browser/fileapi/sandbox_origin_database.cc', diff --git a/chromium/webkit/storage_renderer.gyp b/chromium/webkit/storage_renderer.gyp new file mode 100644 index 00000000000..dc406e202dd --- /dev/null +++ b/chromium/webkit/storage_renderer.gyp @@ -0,0 +1,29 @@ +# Copyright 2013 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +{ + 'targets': [ + { + 'target_name': 'webkit_storage_renderer', + 'type': '<(component)', + 'variables': { 'enable_wexit_time_destructors': 1, }, + 'dependencies': [ + '<(DEPTH)/base/base.gyp:base', + '<(DEPTH)/base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations', + '<(DEPTH)/third_party/WebKit/public/blink.gyp:blink', + '<(DEPTH)/url/url.gyp:url_lib', + '<(DEPTH)/webkit/common/webkit_common.gyp:webkit_common', + '<(DEPTH)/webkit/storage_common.gyp:webkit_storage_common', + ], + 'defines': ['WEBKIT_STORAGE_RENDERER_IMPLEMENTATION'], + 'sources': [ + 'renderer/webkit_storage_renderer_export.h', + 'renderer/fileapi/webfilewriter_base.cc', + 'renderer/fileapi/webfilewriter_base.h', + ], + # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. + 'msvs_disabled_warnings': [ 4267, ], + }, + ], +} diff --git a/chromium/webkit/support/drt_application_mac.h b/chromium/webkit/support/drt_application_mac.h new file mode 100644 index 00000000000..969894f9500 --- /dev/null +++ b/chromium/webkit/support/drt_application_mac.h @@ -0,0 +1,23 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef WEBKIT_SUPPORT_DRT_APPLICATION_MAC_H +#define WEBKIT_SUPPORT_DRT_APPLICATION_MAC_H + +#include "base/mac/scoped_sending_event.h" +#include "base/message_loop/message_pump_mac.h" + +@interface CrDrtApplication : NSApplication<CrAppProtocol, + CrAppControlProtocol> { + @private + BOOL handlingSendEvent_; +} +// CrAppProtocol +- (BOOL)isHandlingSendEvent; + +// CrAppControlProtocol +- (void)setHandlingSendEvent:(BOOL)handlingSendEvent; +@end + +#endif // WEBKIT_SUPPORT_DRT_APPLICATION_MAC_H diff --git a/chromium/webkit/support/drt_application_mac.mm b/chromium/webkit/support/drt_application_mac.mm new file mode 100644 index 00000000000..0c2f900039c --- /dev/null +++ b/chromium/webkit/support/drt_application_mac.mm @@ -0,0 +1,24 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "webkit/support/drt_application_mac.h" + +#include "base/auto_reset.h" + +@implementation CrDrtApplication + +- (BOOL)isHandlingSendEvent { + return handlingSendEvent_; +} + +- (void)sendEvent:(NSEvent*)event { + base::AutoReset<BOOL> scoper(&handlingSendEvent_, YES); + [super sendEvent:event]; +} + +- (void)setHandlingSendEvent:(BOOL)handlingSendEvent { + handlingSendEvent_ = handlingSendEvent; +} + +@end diff --git a/chromium/webkit/support/mac/DumpRenderTreePasteboard.h b/chromium/webkit/support/mac/DumpRenderTreePasteboard.h new file mode 100644 index 00000000000..41796ea3779 --- /dev/null +++ b/chromium/webkit/support/mac/DumpRenderTreePasteboard.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2005, 2006, 2007 Apple, Inc. All rights reserved. + * (C) 2007 Graham Dennis (graham.dennis@gmail.com) + * (C) 2007 Eric Seidel <eric@webkit.org> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// +// This file comes from WebKit: +// WebKit/Tools/DumpRenderTree/mac/DumpRenderTreePasteboard.m +// It is copied here since that location is the best for pulling into Chromium +// and has a few includes commented out. darin@chromium.org suggests in the +// future we see if there is a better place for it to live so it could be +// shared. +// + +#import <AppKit/AppKit.h> +// #import <WebKit/WebTypesInternal.h> + +@interface DumpRenderTreePasteboard : NSPasteboard +- (NSInteger)declareType:(NSString *)type owner:(id)newOwner; ++ (void)releaseLocalPasteboards; +@end diff --git a/chromium/webkit/support/mac/DumpRenderTreePasteboard.m b/chromium/webkit/support/mac/DumpRenderTreePasteboard.m new file mode 100644 index 00000000000..3e3cf1c47d3 --- /dev/null +++ b/chromium/webkit/support/mac/DumpRenderTreePasteboard.m @@ -0,0 +1,214 @@ +/* + * Copyright (C) 2005, 2006, 2007 Apple, Inc. All rights reserved. + * (C) 2007 Graham Dennis (graham.dennis@gmail.com) + * (C) 2007 Eric Seidel <eric@webkit.org> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// +// This file comes from WebKit: +// WebKit/Tools/DumpRenderTree/mac/DumpRenderTreePasteboard.m +// It is copied here since that location is the best for pulling into Chromium +// and has a few includes commented out. darin@chromium.org suggests in the +// future we see if there is a better place for it to live so it could be +// shared. +// + +// #import "DumpRenderTreeMac.h" +#import "DumpRenderTreePasteboard.h" + +// #import <WebKit/WebTypesInternal.h> + +@interface LocalPasteboard : NSPasteboard +{ + NSMutableArray *typesArray; + NSMutableSet *typesSet; + NSMutableDictionary *dataByType; + NSInteger changeCount; +} +@end + +static NSMutableDictionary *localPasteboards; + +@implementation DumpRenderTreePasteboard + +// Return a local pasteboard so we don't disturb the real pasteboards when running tests. ++ (NSPasteboard *)_pasteboardWithName:(NSString *)name +{ + static int number = 0; + if (!name) + name = [NSString stringWithFormat:@"LocalPasteboard%d", ++number]; + if (!localPasteboards) + localPasteboards = [[NSMutableDictionary alloc] init]; + LocalPasteboard *pasteboard = [localPasteboards objectForKey:name]; + if (pasteboard) + return pasteboard; + pasteboard = [[LocalPasteboard alloc] init]; + [localPasteboards setObject:pasteboard forKey:name]; + [pasteboard release]; + return pasteboard; +} + ++ (void)releaseLocalPasteboards +{ + [localPasteboards release]; + localPasteboards = nil; +} + +// Convenience method for JS so that it doesn't have to try and create a NSArray on the objc side instead +// of the usual WebScriptObject that is passed around +- (NSInteger)declareType:(NSString *)type owner:(id)newOwner +{ + return [self declareTypes:[NSArray arrayWithObject:type] owner:newOwner]; +} + +@end + +@implementation LocalPasteboard + ++ (id)alloc +{ + return NSAllocateObject(self, 0, 0); +} + +- (id)init +{ + typesArray = [[NSMutableArray alloc] init]; + typesSet = [[NSMutableSet alloc] init]; + dataByType = [[NSMutableDictionary alloc] init]; + return self; +} + +- (void)dealloc +{ + [typesArray release]; + [typesSet release]; + [dataByType release]; + [super dealloc]; +} + +- (NSString *)name +{ + return nil; +} + +- (void)releaseGlobally +{ +} + +- (NSInteger)declareTypes:(NSArray *)newTypes owner:(id)newOwner +{ + [typesArray removeAllObjects]; + [typesSet removeAllObjects]; + [dataByType removeAllObjects]; + return [self addTypes:newTypes owner:newOwner]; +} + +- (NSInteger)addTypes:(NSArray *)newTypes owner:(id)newOwner +{ + unsigned count = [newTypes count]; + unsigned i; + for (i = 0; i < count; ++i) { + NSString *type = [newTypes objectAtIndex:i]; + NSString *setType = [typesSet member:type]; + if (!setType) { + setType = [type copy]; + [typesArray addObject:setType]; + [typesSet addObject:setType]; + [setType release]; + } + if (newOwner && [newOwner respondsToSelector:@selector(pasteboard:provideDataForType:)]) + [newOwner pasteboard:self provideDataForType:setType]; + } + return ++changeCount; +} + +- (NSInteger)changeCount +{ + return changeCount; +} + +- (NSArray *)types +{ + return typesArray; +} + +- (NSString *)availableTypeFromArray:(NSArray *)types +{ + unsigned count = [types count]; + unsigned i; + for (i = 0; i < count; ++i) { + NSString *type = [types objectAtIndex:i]; + NSString *setType = [typesSet member:type]; + if (setType) + return setType; + } + return nil; +} + +- (BOOL)setData:(NSData *)data forType:(NSString *)dataType +{ + if (data == nil) + data = [NSData data]; + if (![typesSet containsObject:dataType]) + return NO; + [dataByType setObject:data forKey:dataType]; + ++changeCount; + return YES; +} + +- (NSData *)dataForType:(NSString *)dataType +{ + return [dataByType objectForKey:dataType]; +} + +- (BOOL)setPropertyList:(id)propertyList forType:(NSString *)dataType +{ + CFDataRef data = NULL; + if (propertyList) + data = CFPropertyListCreateXMLData(NULL, propertyList); + BOOL result = [self setData:(NSData *)data forType:dataType]; + if (data) + CFRelease(data); + return result; +} + +- (BOOL)setString:(NSString *)string forType:(NSString *)dataType +{ + CFDataRef data = NULL; + if (string) { + if ([string length] == 0) + data = CFDataCreate(NULL, NULL, 0); + else + data = CFStringCreateExternalRepresentation(NULL, (CFStringRef)string, kCFStringEncodingUTF8, 0); + } + BOOL result = [self setData:(NSData *)data forType:dataType]; + if (data) + CFRelease(data); + return result; +} + +@end diff --git a/chromium/webkit/support/platform_support.h b/chromium/webkit/support/platform_support.h new file mode 100644 index 00000000000..73ab9501a7b --- /dev/null +++ b/chromium/webkit/support/platform_support.h @@ -0,0 +1,22 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef WEBKIT_SUPPORT_PLATFORM_SUPORT_H_ +#define WEBKIT_SUPPORT_PLATFORM_SUPORT_H_ + +namespace webkit_support { +// Called before WebKit::initialize(). +void BeforeInitialize(); + +// Called after WebKit::initialize(). +void AfterInitialize(); + +// Called before WebKit::shutdown(). +void BeforeShutdown(); + +// Called after WebKit::shutdown(). +void AfterShutdown(); +} // namespace webkit_support + +#endif // WEBKIT_SUPPORT_PLATFORM_SUPORT_H_ diff --git a/chromium/webkit/support/platform_support_android.cc b/chromium/webkit/support/platform_support_android.cc new file mode 100644 index 00000000000..582dc3a85bd --- /dev/null +++ b/chromium/webkit/support/platform_support_android.cc @@ -0,0 +1,62 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "webkit/support/platform_support.h" + +#include "base/android/jni_android.h" +#include "base/file_util.h" +#include "base/files/file_path.h" +#include "base/logging.h" +#include "base/path_service.h" +#include "base/strings/string16.h" +#include "base/strings/string_piece.h" +#include "base/test/test_support_android.h" +#include "grit/webkit_resources.h" +#include "media/base/android/media_jni_registrar.h" +#include "net/android/net_jni_registrar.h" +#include "net/android/network_library.h" +#include "ui/android/ui_jni_registrar.h" +#include "ui/base/resource/resource_bundle.h" +#include "ui/gl/android/gl_jni_registrar.h" +#include "url/gurl.h" +#include "webkit/support/test_webkit_platform_support.h" + +namespace { + +// The place where the Android layout test script will put the required tools +// and resources. Must keep consistent with DEVICE_DRT_DIR in +// WebKit/Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py. +const char kDumpRenderTreeDir[] = "/data/local/tmp/drt"; + +} + +namespace webkit_support { + +void BeforeInitialize() { + base::InitAndroidTestPaths(); + + // Place cache under kDumpRenderTreeDir to allow the NRWT script to clear it. + base::FilePath path(kDumpRenderTreeDir); + path = path.Append("cache"); + PathService::Override(base::DIR_CACHE, path); + + // Set XML_CATALOG_FILES environment variable to blank to prevent libxml from + // loading and complaining the non-exsistent /etc/xml/catalog file. + setenv("XML_CATALOG_FILES", "", 0); + + JNIEnv* env = base::android::AttachCurrentThread(); + net::android::RegisterNetworkLibrary(env); +} + +void AfterInitialize() { +} + +void BeforeShutdown() { +} + +void AfterShutdown() { +} + +} // namespace webkit_support + diff --git a/chromium/webkit/support/platform_support_linux.cc b/chromium/webkit/support/platform_support_linux.cc new file mode 100644 index 00000000000..85cc8418eaa --- /dev/null +++ b/chromium/webkit/support/platform_support_linux.cc @@ -0,0 +1,35 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "webkit/support/platform_support.h" + +#include "base/file_util.h" +#include "base/files/file_path.h" +#include "base/logging.h" +#include "base/path_service.h" +#include "base/strings/string16.h" +#include "base/strings/string_piece.h" +#include "grit/webkit_resources.h" +#include "ui/base/resource/resource_bundle.h" +#include "webkit/support/test_webkit_platform_support.h" + +namespace webkit_support { + +// TODO(tkent): Implement some of the followings for platform-dependent tasks +// such as loading resource. + +void BeforeInitialize() { +} + +void AfterInitialize() { +} + +void BeforeShutdown() { +} + +void AfterShutdown() { +} + +} // namespace webkit_support + diff --git a/chromium/webkit/support/platform_support_mac.mm b/chromium/webkit/support/platform_support_mac.mm new file mode 100644 index 00000000000..6d96ec13cf8 --- /dev/null +++ b/chromium/webkit/support/platform_support_mac.mm @@ -0,0 +1,46 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "webkit/support/platform_support.h" + +#import <AppKit/AppKit.h> +#include <AvailabilityMacros.h> +#import <Foundation/Foundation.h> +#import <objc/objc-runtime.h> + +#include "base/base_paths.h" +#include "base/file_util.h" +#include "base/logging.h" +#include "base/path_service.h" +#include "base/strings/string16.h" +#include "base/strings/utf_string_conversions.h" +#include "grit/webkit_resources.h" +#include "ui/base/resource/data_pack.h" +#import "webkit/support/drt_application_mac.h" +#import "webkit/support/mac/DumpRenderTreePasteboard.h" +#include "webkit/support/test_webkit_platform_support.h" + +namespace webkit_support { + +static NSAutoreleasePool* autorelease_pool; + +void BeforeInitialize() { + [CrDrtApplication sharedApplication]; + autorelease_pool = [[NSAutoreleasePool alloc] init]; + DCHECK(autorelease_pool); +} + +void AfterInitialize() { +} + +void BeforeShutdown() { +} + +void AfterShutdown() { + [DumpRenderTreePasteboard releaseLocalPasteboards]; + [autorelease_pool drain]; +} + +} // namespace webkit_support + diff --git a/chromium/webkit/support/platform_support_win.cc b/chromium/webkit/support/platform_support_win.cc new file mode 100644 index 00000000000..ce601c5490c --- /dev/null +++ b/chromium/webkit/support/platform_support_win.cc @@ -0,0 +1,36 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "webkit/support/platform_support.h" + +#include "base/base_paths.h" +#include "base/file_util.h" +#include "base/files/file_path.h" +#include "base/logging.h" +#include "base/path_service.h" +#include "base/strings/string16.h" +#include "base/strings/string_piece.h" +#include "base/win/resource_util.h" +#include "grit/blink_resources.h" +#include "grit/webkit_resources.h" +#include "ui/base/resource/resource_bundle.h" +#include "webkit/support/test_webkit_platform_support.h" + + +namespace webkit_support { + +void BeforeInitialize() { +} + +void AfterInitialize() { +} + +void BeforeShutdown() { +} + +void AfterShutdown() { +} + +} // namespace webkit_support + diff --git a/chromium/webkit/support/webkit_support.cc b/chromium/webkit/support/webkit_support.cc index 6f9d41ac3d7..c5846385a70 100644 --- a/chromium/webkit/support/webkit_support.cc +++ b/chromium/webkit/support/webkit_support.cc @@ -4,26 +4,77 @@ #include "webkit/support/webkit_support.h" +#include "base/command_line.h" +#include "base/debug/debugger.h" +#include "base/debug/stack_trace.h" +#include "base/logging.h" #include "base/message_loop/message_loop.h" +#include "base/path_service.h" +#include "base/process/memory.h" #include "base/run_loop.h" +#include "testing/gtest/include/gtest/gtest.h" #include "third_party/WebKit/public/web/WebCache.h" #include "third_party/WebKit/public/web/WebKit.h" #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" #include "url/url_util.h" +#include "webkit/child/webkitplatformsupport_impl.h" #include "webkit/common/user_agent/user_agent.h" #include "webkit/common/user_agent/user_agent_util.h" +#include "webkit/glue/webkit_glue.h" +#include "webkit/support/platform_support.h" #include "webkit/support/test_webkit_platform_support.h" #if defined(OS_ANDROID) -#include "base/android/jni_android.h" -#include "net/android/network_library.h" +#include "base/test/test_support_android.h" #endif -#if defined(OS_MACOSX) -#include "base/test/mock_chrome_application_mac.h" +namespace { + +// All fatal log messages (e.g. DCHECK failures) imply unit test failures +void UnitTestAssertHandler(const std::string& str) { + FAIL() << str; +} + +void InitLogging() { +#if defined(OS_WIN) + if (!::IsDebuggerPresent()) { + UINT new_flags = SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX + | SEM_NOGPFAULTERRORBOX; + + // Preserve existing error mode, as discussed at + // http://blogs.msdn.com/oldnewthing/archive/2004/07/27/198410.aspx + UINT existing_flags = SetErrorMode(new_flags); + SetErrorMode(existing_flags | new_flags); + + // Don't pop up dialog on assertion failure, log to stdout instead. + _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE); + _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDOUT); + } #endif -namespace { +#if defined(OS_ANDROID) + // On Android we expect the log to appear in logcat. + base::InitAndroidTestLogging(); +#else + base::FilePath log_filename; + PathService::Get(base::DIR_EXE, &log_filename); + log_filename = log_filename.AppendASCII("DumpRenderTree.log"); + logging::LoggingSettings settings; + // Only log to a file. This prevents debugging output from disrupting + // whether or not we pass. + settings.logging_dest = logging::LOG_TO_FILE; + settings.log_file = log_filename.value().c_str(); + settings.delete_old = logging::DELETE_OLD_LOG_FILE; + logging::InitLogging(settings); + + // We want process and thread IDs because we may have multiple processes. + const bool kProcessId = true; + const bool kThreadId = true; + const bool kTimestamp = true; + const bool kTickcount = true; + logging::SetLogItems(kProcessId, kThreadId, !kTimestamp, kTickcount); +#endif // else defined(OS_ANDROID) +} class TestEnvironment { public: @@ -35,6 +86,7 @@ class TestEnvironment { #endif TestEnvironment() { + logging::SetLogAssertHandler(UnitTestAssertHandler); main_message_loop_.reset(new MessageLoopType); // TestWebKitPlatformSupport must be instantiated after MessageLoopType. @@ -57,24 +109,30 @@ TestEnvironment* test_environment; namespace webkit_support { void SetUpTestEnvironmentForUnitTests() { + base::debug::EnableInProcessStackDumping(); + base::EnableTerminationOnHeapCorruption(); + + // Initialize the singleton CommandLine with fixed values. Some code refer to + // CommandLine::ForCurrentProcess(). We don't use the actual command-line + // arguments of DRT to avoid unexpected behavior change. + // + // webkit/glue/plugin/plugin_list_posix.cc checks --debug-plugin-loading. + // webkit/glue/plugin/plugin_list_win.cc checks --old-wmp. + // If DRT needs these flags, specify them in the following kFixedArguments. + const char* kFixedArguments[] = {"DumpRenderTree"}; + CommandLine::Init(arraysize(kFixedArguments), kFixedArguments); + WebKit::WebRuntimeFeatures::enableStableFeatures(true); WebKit::WebRuntimeFeatures::enableExperimentalFeatures(true); WebKit::WebRuntimeFeatures::enableTestOnlyFeatures(true); -#if defined(OS_ANDROID) - JNIEnv* env = base::android::AttachCurrentThread(); - net::android::RegisterNetworkLibrary(env); -#endif - -#if defined(OS_MACOSX) - mock_cr_app::RegisterMockCrApp(); -#endif - // Explicitly initialize the GURL library before spawning any threads. // Otherwise crash may happend when different threads try to create a GURL // at same time. url_util::Initialize(); + webkit_support::BeforeInitialize(); test_environment = new TestEnvironment; + webkit_support::AfterInitialize(); webkit_glue::SetUserAgent(webkit_glue::BuildUserAgentFromProduct( "DumpRenderTree/0.0.0.0"), false); } @@ -84,11 +142,14 @@ void TearDownTestEnvironment() { // http://code.google.com/p/chromium/issues/detail?id=9500 base::RunLoop().RunUntilIdle(); + BeforeShutdown(); if (RunningOnValgrind()) WebKit::WebCache::clear(); WebKit::shutdown(); delete test_environment; test_environment = NULL; + AfterShutdown(); + logging::CloseLogFile(); } } // namespace webkit_support diff --git a/chromium/webkit/support/webkit_support.gypi b/chromium/webkit/support/webkit_support.gypi index e8227f06136..bc7fae0b9e7 100644 --- a/chromium/webkit/support/webkit_support.gypi +++ b/chromium/webkit/support/webkit_support.gypi @@ -31,6 +31,7 @@ '<(DEPTH)/webkit/renderer/webkit_renderer.gyp:webkit_renderer', '<(DEPTH)/webkit/storage_browser.gyp:webkit_storage_browser', '<(DEPTH)/webkit/storage_common.gyp:webkit_storage_common', + '<(DEPTH)/webkit/storage_renderer.gyp:webkit_storage_renderer', 'glue', 'glue_child', 'webkit_support_common', @@ -44,6 +45,13 @@ 'UNIT_TEST' ], 'sources': [ + 'drt_application_mac.h', + 'drt_application_mac.mm', + 'platform_support.h', + 'platform_support_android.cc', + 'platform_support_linux.cc', + 'platform_support_mac.mm', + 'platform_support_win.cc', 'test_webkit_platform_support.cc', 'test_webkit_platform_support.h', 'webkit_support.cc', @@ -99,6 +107,8 @@ '<(DEPTH)/base/base.gyp:base', ], 'sources': [ + '<(DEPTH)/webkit/support/mac/DumpRenderTreePasteboard.h', + '<(DEPTH)/webkit/support/mac/DumpRenderTreePasteboard.m', '<(DEPTH)/webkit/support/mock_webclipboard_impl.cc', '<(DEPTH)/webkit/support/mock_webclipboard_impl.h', ], diff --git a/chromium/webkit/support/webkit_support.h b/chromium/webkit/support/webkit_support.h index ed09e67f527..9369be1fe06 100644 --- a/chromium/webkit/support/webkit_support.h +++ b/chromium/webkit/support/webkit_support.h @@ -5,10 +5,19 @@ #ifndef WEBKIT_SUPPORT_WEBKIT_SUPPORT_H_ #define WEBKIT_SUPPORT_WEBKIT_SUPPORT_H_ -// This package provides functions used by webkit_unit_tests. +// This package provides functions used by DumpRenderTree/chromium. namespace webkit_support { -// Initializes or terminates a test environment for unit tests. +// Initializes or terminates a test environment. +// |unit_test_mode| should be set to true when running in a TestSuite, in which +// case no AtExitManager is created and ICU is not initialized (as it is already +// done by the TestSuite). +// SetUpTestEnvironment() and SetUpTestEnvironmentForUnitTests() calls +// WebKit::initialize(). +// TearDownTestEnvironment() calls WebKit::shutdown(). +// SetUpTestEnvironmentForUnitTests() should be used when running in a +// TestSuite, in which case no AtExitManager is created and ICU is not +// initialized (as it is already done by the TestSuite). void SetUpTestEnvironmentForUnitTests(); void TearDownTestEnvironment(); |