diff options
Diffstat (limited to 'chrome/browser')
11 files changed, 72 insertions, 43 deletions
diff --git a/chrome/browser/file_system/browser_file_system_callback_dispatcher.cc b/chrome/browser/file_system/browser_file_system_callback_dispatcher.cc index 129d4a7..1d2ec0a 100644 --- a/chrome/browser/file_system/browser_file_system_callback_dispatcher.cc +++ b/chrome/browser/file_system/browser_file_system_callback_dispatcher.cc @@ -5,6 +5,7 @@ #include "chrome/browser/file_system/browser_file_system_callback_dispatcher.h" #include "chrome/browser/file_system/file_system_dispatcher_host.h" +#include "chrome/common/render_messages.h" BrowserFileSystemCallbackDispatcher::BrowserFileSystemCallbackDispatcher( FileSystemDispatcherHost* dispatcher_host, int request_id) @@ -33,7 +34,7 @@ void BrowserFileSystemCallbackDispatcher::DidReadDirectory( } void BrowserFileSystemCallbackDispatcher::DidOpenFileSystem( - const string16&, const FilePath&) { + const std::string&, const FilePath&) { NOTREACHED(); } diff --git a/chrome/browser/file_system/browser_file_system_callback_dispatcher.h b/chrome/browser/file_system/browser_file_system_callback_dispatcher.h index 075ae30..f24ce71 100644 --- a/chrome/browser/file_system/browser_file_system_callback_dispatcher.h +++ b/chrome/browser/file_system/browser_file_system_callback_dispatcher.h @@ -21,7 +21,7 @@ class BrowserFileSystemCallbackDispatcher virtual void DidReadDirectory( const std::vector<base::file_util_proxy::Entry>& entries, bool has_more); - virtual void DidOpenFileSystem(const string16& name, + virtual void DidOpenFileSystem(const std::string& name, const FilePath& root_path); virtual void DidFail(base::PlatformFileError error_code); virtual void DidWrite(int64 bytes, bool complete); diff --git a/chrome/browser/file_system/file_system_dispatcher_host.cc b/chrome/browser/file_system/file_system_dispatcher_host.cc index 5cfa5be..324612d 100644 --- a/chrome/browser/file_system/file_system_dispatcher_host.cc +++ b/chrome/browser/file_system/file_system_dispatcher_host.cc @@ -7,7 +7,6 @@ #include "base/file_path.h" #include "base/thread.h" #include "base/time.h" -#include "base/utf_string_conversions.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_thread.h" #include "chrome/browser/file_system/browser_file_system_callback_dispatcher.h" @@ -17,19 +16,17 @@ #include "chrome/common/render_messages.h" #include "chrome/common/render_messages_params.h" #include "googleurl/src/gurl.h" -#include "webkit/glue/webkit_glue.h" // A class to hold an ongoing openFileSystem completion task. struct OpenFileSystemCompletionTask { public: static void Run( int request_id, - int routing_id, const std::string& name, const FilePath& root_path, FileSystemDispatcherHost* dispatcher_host) { // The task is self-destructed. - new OpenFileSystemCompletionTask(request_id, routing_id, name, root_path, + new OpenFileSystemCompletionTask(request_id, name, root_path, dispatcher_host); } @@ -37,24 +34,21 @@ struct OpenFileSystemCompletionTask { if (error == base::PLATFORM_FILE_OK) dispatcher_host_->Send( new ViewMsg_OpenFileSystemRequest_Complete( - routing_id_, request_id_, true, UTF8ToUTF16(name_), - webkit_glue::FilePathToWebString(root_path_))); + request_id_, true, name_, root_path_)); else dispatcher_host_->Send( new ViewMsg_OpenFileSystemRequest_Complete( - routing_id_, request_id_, false, string16(), string16())); + request_id_, false, std::string(), FilePath())); delete this; } private: OpenFileSystemCompletionTask( int request_id, - int routing_id, const std::string& name, const FilePath& root_path, FileSystemDispatcherHost* dispatcher_host) : request_id_(request_id), - routing_id_(routing_id), name_(name), root_path_(root_path), dispatcher_host_(dispatcher_host), @@ -66,7 +60,6 @@ struct OpenFileSystemCompletionTask { } int request_id_; - int routing_id_; std::string name_; FilePath root_path_; scoped_refptr<FileSystemDispatcherHost> dispatcher_host_; @@ -124,30 +117,29 @@ bool FileSystemDispatcherHost::OnMessageReceived( } void FileSystemDispatcherHost::OnOpenFileSystem( - const ViewHostMsg_OpenFileSystemRequest_Params& params) { + int request_id, const GURL& origin_url, fileapi::FileSystemType type, + int64 requested_size) { // TODO(kinuko): hook up ContentSettings cookies type checks. FilePath root_path; std::string name; - if (!context_->GetFileSystemRootPath(params.origin_url, - params.type, + if (!context_->GetFileSystemRootPath(origin_url, + type, &root_path, &name)) { Send(new ViewMsg_OpenFileSystemRequest_Complete( - params.routing_id, - params.request_id, + request_id, false, - string16(), - string16())); + std::string(), + FilePath())); return; } // Run the completion task that creates the root directory and sends // back the status code to the dispatcher. - OpenFileSystemCompletionTask::Run( - params.request_id, params.routing_id, name, root_path, this); + OpenFileSystemCompletionTask::Run(request_id, name, root_path, this); } void FileSystemDispatcherHost::OnMove( diff --git a/chrome/browser/file_system/file_system_dispatcher_host.h b/chrome/browser/file_system/file_system_dispatcher_host.h index 561350c..20bb77c 100644 --- a/chrome/browser/file_system/file_system_dispatcher_host.h +++ b/chrome/browser/file_system/file_system_dispatcher_host.h @@ -13,9 +13,11 @@ #include "base/platform_file.h" #include "base/scoped_callback_factory.h" #include "base/ref_counted.h" -#include "chrome/common/render_messages.h" +#include "ipc/ipc_message.h" #include "webkit/fileapi/file_system_operation.h" +#include "webkit/fileapi/file_system_types.h" +class ChromeFileSystemOperation; class FileSystemHostContext; class GURL; class HostContentSettingsMap; @@ -34,7 +36,10 @@ class FileSystemDispatcherHost bool OnMessageReceived(const IPC::Message& message, bool* message_was_ok); - void OnOpenFileSystem(const ViewHostMsg_OpenFileSystemRequest_Params&); + void OnOpenFileSystem(int request_id, + const GURL& origin_url, + fileapi::FileSystemType type, + int64 requested_size); void OnMove(int request_id, const FilePath& src_path, const FilePath& dest_path); diff --git a/chrome/browser/file_system/file_system_host_context.cc b/chrome/browser/file_system/file_system_host_context.cc index c14dfe1..f0cea3b 100644 --- a/chrome/browser/file_system/file_system_host_context.cc +++ b/chrome/browser/file_system/file_system_host_context.cc @@ -7,9 +7,9 @@ #include "base/file_util.h" #include "base/logging.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/profile.h" -#include "third_party/WebKit/WebKit/chromium/public/WebFileSystem.h" +#include "googleurl/src/gurl.h" #include "third_party/WebKit/WebKit/chromium/public/WebCString.h" +#include "third_party/WebKit/WebKit/chromium/public/WebFileSystem.h" #include "third_party/WebKit/WebKit/chromium/public/WebSecurityOrigin.h" const FilePath::CharType FileSystemHostContext::kFileSystemDirectory[] = @@ -25,21 +25,21 @@ FileSystemHostContext::FileSystemHostContext( } bool FileSystemHostContext::GetFileSystemRootPath( - const GURL& origin_url, WebKit::WebFileSystem::Type type, + const GURL& origin_url, fileapi::FileSystemType type, FilePath* root_path, std::string* name) const { // TODO(kinuko): should return an isolated temporary file system space. if (is_incognito_) return false; std::string storage_identifier = GetStorageIdentifierFromURL(origin_url); switch (type) { - case WebKit::WebFileSystem::TypeTemporary: + case fileapi::kFileSystemTypeTemporary: if (root_path) *root_path = base_path_.AppendASCII(storage_identifier) .AppendASCII(kTemporaryName); if (name) *name = storage_identifier + ":" + kTemporaryName; return true; - case WebKit::WebFileSystem::TypePersistent: + case fileapi::kFileSystemTypePersistent: if (root_path) *root_path = base_path_.AppendASCII(storage_identifier) .AppendASCII(kPersistentName); @@ -63,3 +63,8 @@ std::string FileSystemHostContext::GetStorageIdentifierFromURL( WebKit::WebSecurityOrigin::createFromString(UTF8ToUTF16(url.spec())); return web_security_origin.databaseIdentifier().utf8(); } + +COMPILE_ASSERT(int(WebKit::WebFileSystem::TypeTemporary) == \ + int(fileapi::kFileSystemTypeTemporary), mismatching_enums); +COMPILE_ASSERT(int(WebKit::WebFileSystem::TypePersistent) == \ + int(fileapi::kFileSystemTypePersistent), mismatching_enums); diff --git a/chrome/browser/file_system/file_system_host_context.h b/chrome/browser/file_system/file_system_host_context.h index 592ccd6..e651a43 100644 --- a/chrome/browser/file_system/file_system_host_context.h +++ b/chrome/browser/file_system/file_system_host_context.h @@ -8,8 +8,9 @@ #include "base/file_path.h" #include "base/ref_counted.h" #include "base/scoped_ptr.h" -#include "googleurl/src/gurl.h" -#include "third_party/WebKit/WebKit/chromium/public/WebFileSystem.h" +#include "webkit/fileapi/file_system_types.h" + +class GURL; // This is owned by profile and shared by all the FileSystemDispatcherHost // that shared by the same profile. @@ -23,11 +24,10 @@ class FileSystemHostContext // Returns the root path and name for the file system specified by given // |origin_url| and |type|. Returns true if the file system is available // for the profile and |root_path| and |name| are filled successfully. - bool GetFileSystemRootPath( - const GURL& origin_url, - WebKit::WebFileSystem::Type type, - FilePath* root_path, - std::string* name) const; + bool GetFileSystemRootPath(const GURL& origin_url, + fileapi::FileSystemType type, + FilePath* root_path, + std::string* name) const; // Check if the given |path| is in the FileSystem base directory. bool CheckValidFileSystemPath(const FilePath& path) const; diff --git a/chrome/browser/file_system/file_system_host_context_unittest.cc b/chrome/browser/file_system/file_system_host_context_unittest.cc index 6bcda9d..3837e00 100644 --- a/chrome/browser/file_system/file_system_host_context_unittest.cc +++ b/chrome/browser/file_system/file_system_host_context_unittest.cc @@ -9,7 +9,6 @@ #include "chrome/browser/file_system/file_system_host_context.h" #include "googleurl/src/gurl.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/WebKit/chromium/public/WebFileSystem.h" namespace { @@ -24,19 +23,19 @@ const FilePath::CharType kTestDataPath[] = FILE_PATH_LITERAL( "//tmp/TestingProfilePath"); const struct RootPathTest { - WebKit::WebFileSystem::Type type; + fileapi::FileSystemType type; bool off_the_record; const char* origin_url; bool expect_root_path; const char* expected_path; } kRootPathTestCases[] = { - { WebKit::WebFileSystem::TypeTemporary, false, "http://host:1/", + { fileapi::kFileSystemTypeTemporary, false, "http://host:1/", true, "FileSystem" PS "http_host_1" PS "Temporary" }, - { WebKit::WebFileSystem::TypePersistent, false, "http://host:2/", + { fileapi::kFileSystemTypePersistent, false, "http://host:2/", true, "FileSystem" PS "http_host_2" PS "Persistent" }, - { WebKit::WebFileSystem::TypeTemporary, true, "http://host:3/", + { fileapi::kFileSystemTypeTemporary, true, "http://host:3/", false, "" }, - { WebKit::WebFileSystem::TypePersistent, true, "http://host:4/", + { fileapi::kFileSystemTypePersistent, true, "http://host:4/", false, "" }, }; @@ -89,7 +88,7 @@ TEST(FileSystemHostContextTest, CheckValidPath) { FilePath root_path; EXPECT_TRUE(context->GetFileSystemRootPath( - GURL("http://foo.com/"), WebKit::WebFileSystem::TypePersistent, + GURL("http://foo.com/"), fileapi::kFileSystemTypePersistent, &root_path, NULL)); FilePath path(kCheckValidPathTestCases[i].path); if (!path.IsAbsolute()) diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc index e7811fc..7cc4a91 100644 --- a/chrome/browser/net/chrome_url_request_context.cc +++ b/chrome/browser/net/chrome_url_request_context.cc @@ -944,6 +944,7 @@ ChromeURLRequestContext::ChromeURLRequestContext( is_media_ = other->is_media_; is_off_the_record_ = other->is_off_the_record_; blob_storage_context_ = other->blob_storage_context_; + file_system_host_context_ = other->file_system_host_context_; } void ChromeURLRequestContext::OnAcceptLanguageChange( @@ -1029,6 +1030,7 @@ ChromeURLRequestContextFactory::ChromeURLRequestContextFactory(Profile* profile) appcache_service_ = profile->GetAppCacheService(); database_tracker_ = profile->GetDatabaseTracker(); blob_storage_context_ = profile->GetBlobStorageContext(); + file_system_host_context_ = profile->GetFileSystemHostContext(); } ChromeURLRequestContextFactory::~ChromeURLRequestContextFactory() { @@ -1054,6 +1056,7 @@ void ChromeURLRequestContextFactory::ApplyProfileParametersToContext( context->set_appcache_service(appcache_service_); context->set_database_tracker(database_tracker_); context->set_blob_storage_context(blob_storage_context_); + context->set_file_system_host_context(file_system_host_context_); } // ---------------------------------------------------------------------------- diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context.h index cd4200c..ebae377 100644 --- a/chrome/browser/net/chrome_url_request_context.h +++ b/chrome/browser/net/chrome_url_request_context.h @@ -14,6 +14,7 @@ #include "base/linked_ptr.h" #include "chrome/browser/appcache/chrome_appcache_service.h" #include "chrome/browser/chrome_blob_storage_context.h" +#include "chrome/browser/file_system/file_system_host_context.h" #include "chrome/browser/host_content_settings_map.h" #include "chrome/browser/host_zoom_map.h" #include "chrome/browser/io_thread.h" @@ -134,6 +135,11 @@ class ChromeURLRequestContext : public URLRequestContext { return blob_storage_context_.get(); } + // Gets the file system host context with this context's profile. + FileSystemHostContext* file_system_host_context() const { + return file_system_host_context_.get(); + } + bool is_off_the_record() const { return is_off_the_record_; } @@ -237,6 +243,9 @@ class ChromeURLRequestContext : public URLRequestContext { void set_blob_storage_context(ChromeBlobStorageContext* context) { blob_storage_context_ = context; } + void set_file_system_host_context(FileSystemHostContext* context) { + file_system_host_context_ = context; + } void set_net_log(net::NetLog* net_log) { net_log_ = net_log; } @@ -263,6 +272,7 @@ class ChromeURLRequestContext : public URLRequestContext { scoped_refptr<HostContentSettingsMap> host_content_settings_map_; scoped_refptr<HostZoomMap> host_zoom_map_; scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; + scoped_refptr<FileSystemHostContext> file_system_host_context_; bool is_media_; bool is_off_the_record_; @@ -431,6 +441,7 @@ class ChromeURLRequestContextFactory { scoped_refptr<net::SSLConfigService> ssl_config_service_; scoped_refptr<net::CookieMonster::Delegate> cookie_monster_delegate_; scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; + scoped_refptr<FileSystemHostContext> file_system_host_context_; FilePath profile_dir_path_; diff --git a/chrome/browser/worker_host/worker_process_host.cc b/chrome/browser/worker_host/worker_process_host.cc index 32ce928..868ba6c 100644 --- a/chrome/browser/worker_host/worker_process_host.cc +++ b/chrome/browser/worker_host/worker_process_host.cc @@ -16,6 +16,7 @@ #include "chrome/browser/appcache/appcache_dispatcher_host.h" #include "chrome/browser/chrome_thread.h" #include "chrome/browser/child_process_security_policy.h" +#include "chrome/browser/file_system/file_system_dispatcher_host.h" #include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/profile.h" #include "chrome/browser/renderer_host/blob_dispatcher_host.h" @@ -67,7 +68,11 @@ WorkerProcessHost::WorkerProcessHost( new AppCacheDispatcherHost(request_context)), ALLOW_THIS_IN_INITIALIZER_LIST(blob_dispatcher_host_( new BlobDispatcherHost( - this->id(), request_context->blob_storage_context()))) { + this->id(), request_context->blob_storage_context()))), + ALLOW_THIS_IN_INITIALIZER_LIST(file_system_dispatcher_host_( + new FileSystemDispatcherHost(this, + request_context->file_system_host_context(), + request_context->host_content_settings_map()))) { next_route_id_callback_.reset(NewCallbackWithReturnValue( WorkerService::GetInstance(), &WorkerService::next_worker_route_id)); db_dispatcher_host_ = new DatabaseDispatcherHost( @@ -83,6 +88,9 @@ WorkerProcessHost::~WorkerProcessHost() { // Shut down the blob dispatcher host. blob_dispatcher_host_->Shutdown(); + // Shut down the file system dispatcher host. + file_system_dispatcher_host_->Shutdown(); + // Let interested observers know we are being deleted. NotificationService::current()->Notify( NotificationType::WORKER_PROCESS_HOST_SHUTDOWN, @@ -129,6 +137,7 @@ bool WorkerProcessHost::Init() { #if defined(OS_WIN) switches::kDisableDesktopNotifications, #endif + switches::kEnableFileSystem, }; cmd_line->CopySwitchesFrom(*CommandLine::ForCurrentProcess(), kSwitchNames, arraysize(kSwitchNames)); @@ -241,6 +250,7 @@ void WorkerProcessHost::OnMessageReceived(const IPC::Message& message) { appcache_dispatcher_host_->OnMessageReceived(message, &msg_is_ok) || db_dispatcher_host_->OnMessageReceived(message, &msg_is_ok) || blob_dispatcher_host_->OnMessageReceived(message, &msg_is_ok) || + file_system_dispatcher_host_->OnMessageReceived(message, &msg_is_ok) || MessagePortDispatcher::GetInstance()->OnMessageReceived( message, this, next_route_id_callback_.get(), &msg_is_ok); @@ -289,6 +299,7 @@ void WorkerProcessHost::OnMessageReceived(const IPC::Message& message) { void WorkerProcessHost::OnProcessLaunched() { db_dispatcher_host_->Init(handle()); + file_system_dispatcher_host_->Init(handle()); } CallbackWithReturnValue<int>::Type* WorkerProcessHost::GetNextRouteIdCallback( diff --git a/chrome/browser/worker_host/worker_process_host.h b/chrome/browser/worker_host/worker_process_host.h index e009813..0bdc4ef 100644 --- a/chrome/browser/worker_host/worker_process_host.h +++ b/chrome/browser/worker_host/worker_process_host.h @@ -22,6 +22,7 @@ class BlobDispatcherHost; class ChromeURLRequestContext; class ChromeURLRequestContextGetter; class DatabaseDispatcherHost; +class FileSystemDispatcherHost; namespace webkit_database { class DatabaseTracker; } // namespace webkit_database @@ -197,6 +198,7 @@ class WorkerProcessHost : public BrowserChildProcessHost { scoped_ptr<AppCacheDispatcherHost> appcache_dispatcher_host_; scoped_refptr<DatabaseDispatcherHost> db_dispatcher_host_; scoped_ptr<BlobDispatcherHost> blob_dispatcher_host_; + scoped_refptr<FileSystemDispatcherHost> file_system_dispatcher_host_; // A callback to create a routing id for the associated worker process. scoped_ptr<CallbackWithReturnValue<int>::Type> next_route_id_callback_; |