diff options
author | adamk@chromium.org <adamk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-22 18:48:47 +0000 |
---|---|---|
committer | adamk@chromium.org <adamk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-22 18:48:47 +0000 |
commit | 0823b9143684160aca939b83e9488926130b93b9 (patch) | |
tree | 18c3b0a0810edef2274acaa37f073829f65dc9bd /webkit/tools | |
parent | c47b853635474937b76aad67be388ebf675da445 (diff) | |
download | chromium_src-0823b9143684160aca939b83e9488926130b93b9.zip chromium_src-0823b9143684160aca939b83e9488926130b93b9.tar.gz chromium_src-0823b9143684160aca939b83e9488926130b93b9.tar.bz2 |
Hook up filesystem: URLs to the SimpleResourceLoaderBridge,
which should let layout tests load filesystem: URLs.
R=kinuko@chromium.org
BUG=75312
Review URL: http://codereview.chromium.org/6688020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79010 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools')
4 files changed, 55 insertions, 4 deletions
diff --git a/webkit/tools/test_shell/simple_file_system.h b/webkit/tools/test_shell/simple_file_system.h index f6c0c65..18669fa 100644 --- a/webkit/tools/test_shell/simple_file_system.h +++ b/webkit/tools/test_shell/simple_file_system.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// 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. @@ -36,6 +36,10 @@ class SimpleFileSystem bool create, WebKit::WebFileSystemCallbacks* callbacks); + fileapi::FileSystemContext* file_system_context() { + return file_system_context_.get(); + } + // WebKit::WebFileSystem methods. virtual void move(const WebKit::WebString& src_path, const WebKit::WebString& dest_path, diff --git a/webkit/tools/test_shell/simple_resource_loader_bridge.cc b/webkit/tools/test_shell/simple_resource_loader_bridge.cc index 6dbb0b2..85780c2 100644 --- a/webkit/tools/test_shell/simple_resource_loader_bridge.cc +++ b/webkit/tools/test_shell/simple_resource_loader_bridge.cc @@ -63,6 +63,9 @@ #include "webkit/blob/blob_storage_controller.h" #include "webkit/blob/blob_url_request_job.h" #include "webkit/blob/deletable_file_reference.h" +#include "webkit/fileapi/file_system_context.h" +#include "webkit/fileapi/file_system_dir_url_request_job.h" +#include "webkit/fileapi/file_system_url_request_job.h" #include "webkit/glue/resource_loader_bridge.h" #include "webkit/tools/test_shell/simple_appcache_system.h" #include "webkit/tools/test_shell/simple_file_writer.h" @@ -94,8 +97,8 @@ struct TestShellRequestContextParams { bool accept_all_cookies; }; -static net::URLRequestJob* BlobURLRequestJobFactory(net::URLRequest* request, - const std::string& scheme) { +net::URLRequestJob* BlobURLRequestJobFactory(net::URLRequest* request, + const std::string& scheme) { webkit_blob::BlobStorageController* blob_storage_controller = static_cast<TestShellRequestContext*>(request->context())-> blob_storage_controller(); @@ -105,6 +108,33 @@ static net::URLRequestJob* BlobURLRequestJobFactory(net::URLRequest* request, SimpleResourceLoaderBridge::GetIoThread()); } + +net::URLRequestJob* FileSystemURLRequestJobFactory(net::URLRequest* request, + const std::string& scheme) { + fileapi::FileSystemContext* fs_context = + static_cast<TestShellRequestContext*>(request->context()) + ->file_system_context(); + if (!fs_context) { + LOG(WARNING) << "No FileSystemContext found, ignoring filesystem: URL"; + return NULL; + } + + // If the path ends with a /, we know it's a directory. If the path refers + // to a directory and gets dispatched to FileSystemURLRequestJob, that class + // redirects back here, by adding a / to the URL. + const std::string path = request->url().path(); + if (!path.empty() && path[path.size() - 1] == '/') { + return new fileapi::FileSystemDirURLRequestJob( + request, + fs_context->path_manager(), + SimpleResourceLoaderBridge::GetIoThread()); + } + return new fileapi::FileSystemURLRequestJob( + request, + fs_context->path_manager(), + SimpleResourceLoaderBridge::GetIoThread()); +} + TestShellRequestContextParams* g_request_context_params = NULL; TestShellRequestContext* g_request_context = NULL; base::Thread* g_cache_thread = NULL; @@ -145,6 +175,8 @@ class IOThread : public base::Thread { g_request_context->blob_storage_controller()); net::URLRequest::RegisterProtocolFactory("blob", &BlobURLRequestJobFactory); + net::URLRequest::RegisterProtocolFactory("filesystem", + &FileSystemURLRequestJobFactory); } virtual void CleanUp() { diff --git a/webkit/tools/test_shell/test_shell_request_context.cc b/webkit/tools/test_shell/test_shell_request_context.cc index 6502674..89bed6f 100644 --- a/webkit/tools/test_shell/test_shell_request_context.cc +++ b/webkit/tools/test_shell/test_shell_request_context.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// 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. @@ -17,8 +17,12 @@ #include "net/proxy/proxy_config_service.h" #include "net/proxy/proxy_config_service_fixed.h" #include "net/proxy/proxy_service.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebKitClient.h" #include "webkit/blob/blob_storage_controller.h" +#include "webkit/fileapi/file_system_context.h" #include "webkit/glue/webkit_glue.h" +#include "webkit/tools/test_shell/simple_file_system.h" #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" TestShellRequestContext::TestShellRequestContext() { @@ -86,6 +90,8 @@ void TestShellRequestContext::Init( set_ftp_transaction_factory(new net::FtpNetworkLayer(host_resolver())); blob_storage_controller_.reset(new webkit_blob::BlobStorageController()); + file_system_context_ = static_cast<SimpleFileSystem*>( + WebKit::webKitClient()->fileSystem())->file_system_context(); } TestShellRequestContext::~TestShellRequestContext() { diff --git a/webkit/tools/test_shell/test_shell_request_context.h b/webkit/tools/test_shell/test_shell_request_context.h index ff88d8e..0f6c4e2 100644 --- a/webkit/tools/test_shell/test_shell_request_context.h +++ b/webkit/tools/test_shell/test_shell_request_context.h @@ -11,6 +11,10 @@ class FilePath; +namespace fileapi { +class FileSystemContext; +} + namespace webkit_blob { class BlobStorageController; } @@ -33,6 +37,10 @@ class TestShellRequestContext : public net::URLRequestContext { return blob_storage_controller_.get(); } + fileapi::FileSystemContext* file_system_context() const { + return file_system_context_.get(); + } + private: ~TestShellRequestContext(); @@ -40,6 +48,7 @@ class TestShellRequestContext : public net::URLRequestContext { bool no_proxy); scoped_ptr<webkit_blob::BlobStorageController> blob_storage_controller_; + scoped_refptr<fileapi::FileSystemContext> file_system_context_; }; #endif // WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_REQUEST_CONTEXT_H_ |