diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-31 06:52:22 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-31 06:52:22 +0000 |
commit | 35acadaf095771e36b121372c7185575abab2f95 (patch) | |
tree | 1ef6baede158dcd65cc9e9b2ac23c6a301c7ef4b /content | |
parent | b184045dd7ebe9a3b4db45febc563ba2b3bb6f7d (diff) | |
download | chromium_src-35acadaf095771e36b121372c7185575abab2f95.zip chromium_src-35acadaf095771e36b121372c7185575abab2f95.tar.gz chromium_src-35acadaf095771e36b121372c7185575abab2f95.tar.bz2 |
Revert 214160 "Implement Worker-MainThread bridge for FileSystem..."
Suspected to have performance regression, let's see if this changes anything
BUG=265658
> Implement Worker-MainThread bridge for FileSystem API in Chrome
>
> This basically adds the same worker/mainThread bridge functionality
> for FileSystem API in Chrome side.
>
> Keeping bridge code around is suboptimal, but this allows us to remove
> bridge code in Blink side which in turn allows us to make further
> worker-related cleanups in Blink.
>
> This change doesn't contain FileWriter related changes yet.
> (For reference, combined patch is uploaded here:
> https://codereview.chromium.org/19287010/)
>
> BUG=257349
> TEST=no behavioral changes yet
> R=atwilson@chromium.org, jochen@chromium.org, michaeln@chromium.org, tzik@chromium.org
>
> Review URL: https://codereview.chromium.org/19387002
TBR=kinuko@chromium.org
Review URL: https://codereview.chromium.org/21334002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214599 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/child/fileapi/file_system_dispatcher.cc | 10 | ||||
-rw-r--r-- | content/child/fileapi/file_system_dispatcher.h | 6 | ||||
-rw-r--r-- | content/child/fileapi/webfilesystem_callback_adapters.cc | 31 | ||||
-rw-r--r-- | content/child/fileapi/webfilesystem_callback_adapters.h | 14 | ||||
-rw-r--r-- | content/child/fileapi/webfilesystem_impl.cc | 402 | ||||
-rw-r--r-- | content/child/fileapi/webfilesystem_impl.h | 12 | ||||
-rw-r--r-- | content/renderer/renderer_webkitplatformsupport_impl.cc | 2 | ||||
-rw-r--r-- | content/worker/worker_webkitplatformsupport_impl.cc | 2 |
8 files changed, 141 insertions, 338 deletions
diff --git a/content/child/fileapi/file_system_dispatcher.cc b/content/child/fileapi/file_system_dispatcher.cc index b7a1367..f2ba527 100644 --- a/content/child/fileapi/file_system_dispatcher.cc +++ b/content/child/fileapi/file_system_dispatcher.cc @@ -6,7 +6,6 @@ #include "base/callback.h" #include "base/file_util.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/process/process.h" #include "content/child/child_thread.h" #include "content/common/fileapi/file_system_messages.h" @@ -89,9 +88,8 @@ class FileSystemDispatcher::CallbackDispatcher { void DidCreateSnapshotFile( const base::PlatformFileInfo& file_info, - const base::FilePath& platform_path, - int request_id) { - snapshot_callback_.Run(file_info, platform_path, request_id); + const base::FilePath& platform_path) { + snapshot_callback_.Run(file_info, platform_path); } void DidReadDirectory( @@ -365,8 +363,10 @@ void FileSystemDispatcher::OnDidCreateSnapshotFile( const base::FilePath& platform_path) { CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id); DCHECK(dispatcher); - dispatcher->DidCreateSnapshotFile(file_info, platform_path, request_id); + dispatcher->DidCreateSnapshotFile(file_info, platform_path); dispatchers_.Remove(request_id); + ChildThread::current()->Send( + new FileSystemHostMsg_DidReceiveSnapshotFile(request_id)); } void FileSystemDispatcher::OnDidReadDirectory( diff --git a/content/child/fileapi/file_system_dispatcher.h b/content/child/fileapi/file_system_dispatcher.h index e0260fda..4a8ced4 100644 --- a/content/child/fileapi/file_system_dispatcher.h +++ b/content/child/fileapi/file_system_dispatcher.h @@ -40,8 +40,7 @@ class FileSystemDispatcher : public IPC::Listener { const base::PlatformFileInfo& file_info)> MetadataCallback; typedef base::Callback<void( const base::PlatformFileInfo& file_info, - const base::FilePath& platform_path, - int request_id)> CreateSnapshotFileCallback; + const base::FilePath& platform_path)> CreateSnapshotFileCallback; typedef base::Callback<void( const std::vector<fileapi::DirectoryEntry>& entries, bool has_more)> ReadDirectoryCallback; @@ -123,9 +122,6 @@ class FileSystemDispatcher : public IPC::Listener { // raw PlatformFile returned from OpenFile. void NotifyCloseFile(int file_open_id); - // The caller must send FileSystemHostMsg_DidReceiveSnapshot message - // with |request_id| passed to |success_callback| after the snapshot file - // is successfully received. void CreateSnapshotFile(const GURL& file_path, const CreateSnapshotFileCallback& success_callback, const StatusCallback& error_callback); diff --git a/content/child/fileapi/webfilesystem_callback_adapters.cc b/content/child/fileapi/webfilesystem_callback_adapters.cc index de5a59c..a6e7187 100644 --- a/content/child/fileapi/webfilesystem_callback_adapters.cc +++ b/content/child/fileapi/webfilesystem_callback_adapters.cc @@ -35,6 +35,37 @@ void FileStatusCallbackAdapter( callbacks->didFail(::fileapi::PlatformFileErrorToWebFileError(error)); } +void ReadMetadataCallbackAdapter( + WebKit::WebFileSystemCallbacks* callbacks, + const base::PlatformFileInfo& file_info) { + WebFileInfo web_file_info; + webkit_glue::PlatformFileInfoToWebFileInfo(file_info, &web_file_info); + callbacks->didReadMetadata(web_file_info); +} + +void CreateSnapshotFileCallbackAdapter( + WebKit::WebFileSystemCallbacks* callbacks, + const base::PlatformFileInfo& file_info, + const base::FilePath& platform_path) { + WebFileInfo web_file_info; + webkit_glue::PlatformFileInfoToWebFileInfo(file_info, &web_file_info); + web_file_info.platformPath = platform_path.AsUTF16Unsafe(); + callbacks->didCreateSnapshotFile(web_file_info); +} + +void ReadDirectoryCallbackAdapater( + WebKit::WebFileSystemCallbacks* callbacks, + const std::vector<fileapi::DirectoryEntry>& entries, + bool has_more) { + WebVector<WebFileSystemEntry> file_system_entries(entries.size()); + for (size_t i = 0; i < entries.size(); i++) { + file_system_entries[i].name = + base::FilePath(entries[i].name).AsUTF16Unsafe(); + file_system_entries[i].isDirectory = entries[i].is_directory; + } + callbacks->didReadDirectory(file_system_entries, has_more); +} + void OpenFileSystemCallbackAdapter( WebKit::WebFileSystemCallbacks* callbacks, const std::string& name, const GURL& root) { diff --git a/content/child/fileapi/webfilesystem_callback_adapters.h b/content/child/fileapi/webfilesystem_callback_adapters.h index a6fb83c..850159e 100644 --- a/content/child/fileapi/webfilesystem_callback_adapters.h +++ b/content/child/fileapi/webfilesystem_callback_adapters.h @@ -24,6 +24,20 @@ void FileStatusCallbackAdapter( WebKit::WebFileSystemCallbacks* callbacks, base::PlatformFileError error); +void ReadMetadataCallbackAdapter( + WebKit::WebFileSystemCallbacks* callbacks, + const base::PlatformFileInfo& file_info); + +void CreateSnapshotFileCallbackAdapter( + WebKit::WebFileSystemCallbacks* callbacks, + const base::PlatformFileInfo& file_info, + const base::FilePath& platform_path); + +void ReadDirectoryCallbackAdapater( + WebKit::WebFileSystemCallbacks* callbacks, + const std::vector<fileapi::DirectoryEntry>& entries, + bool has_more); + void OpenFileSystemCallbackAdapter( WebKit::WebFileSystemCallbacks* callbacks, const std::string& name, const GURL& root); diff --git a/content/child/fileapi/webfilesystem_impl.cc b/content/child/fileapi/webfilesystem_impl.cc index e253a17..9bb8664 100644 --- a/content/child/fileapi/webfilesystem_impl.cc +++ b/content/child/fileapi/webfilesystem_impl.cc @@ -5,24 +5,14 @@ #include "content/child/fileapi/webfilesystem_impl.h" #include "base/bind.h" -#include "base/id_map.h" -#include "base/lazy_instance.h" -#include "base/logging.h" -#include "base/message_loop/message_loop_proxy.h" -#include "base/threading/thread_local.h" #include "content/child/child_thread.h" #include "content/child/fileapi/file_system_dispatcher.h" #include "content/child/fileapi/webfilesystem_callback_adapters.h" #include "content/child/fileapi/webfilewriter_impl.h" -#include "content/common/fileapi/file_system_messages.h" +#include "third_party/WebKit/public/web/WebFileSystemCallbacks.h" #include "third_party/WebKit/public/platform/WebFileInfo.h" #include "third_party/WebKit/public/platform/WebString.h" #include "third_party/WebKit/public/platform/WebURL.h" -#include "third_party/WebKit/public/web/WebFileSystemCallbacks.h" -#include "url/gurl.h" -#include "webkit/child/worker_task_runner.h" -#include "webkit/common/fileapi/directory_entry.h" -#include "webkit/common/fileapi/file_system_util.h" #include "webkit/glue/webkit_glue.h" using WebKit::WebFileInfo; @@ -31,69 +21,11 @@ using WebKit::WebFileSystemEntry; using WebKit::WebString; using WebKit::WebURL; using WebKit::WebVector; -using webkit_glue::WorkerTaskRunner; namespace content { namespace { -class CallbacksMap; - -base::LazyInstance<base::ThreadLocalPointer<CallbacksMap> >::Leaky - g_callbacks_map_tls = LAZY_INSTANCE_INITIALIZER; - -// TODO(kinuko): Integrate this into WebFileSystemImpl when blink side -// becomes ready to make WebFileSystemImpl thread-local. -class CallbacksMap : public WorkerTaskRunner::Observer { - public: - static CallbacksMap* Get() { - return g_callbacks_map_tls.Pointer()->Get(); - } - - static CallbacksMap* GetOrCreate() { - if (g_callbacks_map_tls.Pointer()->Get()) - return g_callbacks_map_tls.Pointer()->Get(); - CallbacksMap* map = new CallbacksMap; - if (WorkerTaskRunner::Instance()->CurrentWorkerId()) - WorkerTaskRunner::Instance()->AddStopObserver(map); - return map; - } - - virtual ~CallbacksMap() { - IDMap<WebFileSystemCallbacks>::iterator iter(&callbacks_); - while (!iter.IsAtEnd()) { - iter.GetCurrentValue()->didFail(WebKit::WebFileErrorAbort); - iter.Advance(); - } - g_callbacks_map_tls.Pointer()->Set(NULL); - } - - // webkit_glue::WorkerTaskRunner::Observer implementation. - virtual void OnWorkerRunLoopStopped() OVERRIDE { - delete this; - } - - int RegisterCallbacks(WebFileSystemCallbacks* callbacks) { - return callbacks_.Add(callbacks); - } - - WebFileSystemCallbacks* GetAndUnregisterCallbacks( - int callbacks_id) { - WebFileSystemCallbacks* callbacks = callbacks_.Lookup(callbacks_id); - callbacks_.Remove(callbacks_id); - return callbacks; - } - - private: - CallbacksMap() { - g_callbacks_map_tls.Pointer()->Set(this); - } - - IDMap<WebFileSystemCallbacks> callbacks_; - - DISALLOW_COPY_AND_ASSIGN(CallbacksMap); -}; - void DidReadMetadataForCreateFileWriter( const GURL& path, WebKit::WebFileWriterClient* client, @@ -107,263 +39,107 @@ void DidReadMetadataForCreateFileWriter( file_info.size); } -void DidReceiveSnapshotFile(int request_id) { - if (ChildThread::current()) - ChildThread::current()->Send( - new FileSystemHostMsg_DidReceiveSnapshotFile(request_id)); -} - -int CurrentWorkerId() { - return WorkerTaskRunner::Instance()->CurrentWorkerId(); -} - -template <typename Method, typename Params> -void CallDispatcherOnMainThread( - base::MessageLoopProxy* loop, - Method method, const Params& params) { - if (!loop->RunsTasksOnCurrentThread()) { - loop->PostTask(FROM_HERE, - base::Bind(&CallDispatcherOnMainThread<Method, Params>, - make_scoped_refptr(loop), method, params)); - return; - } - if (!ChildThread::current() || - !ChildThread::current()->file_system_dispatcher()) - return; - - DispatchToMethod(ChildThread::current()->file_system_dispatcher(), - method, params); -} - -template <typename Method, typename Params> -void CallbackFileSystemCallbacks( - int thread_id, int callbacks_id, - Method method, const Params& params) { - if (thread_id != CurrentWorkerId()) { - WorkerTaskRunner::Instance()->PostTask( - thread_id, - base::Bind(&CallbackFileSystemCallbacks<Method, Params>, - thread_id, callbacks_id, method, params)); - return; - } - if (!CallbacksMap::Get()) - return; - - WebFileSystemCallbacks* callbacks = - CallbacksMap::Get()->GetAndUnregisterCallbacks(callbacks_id); - DCHECK(callbacks); - DispatchToMethod(callbacks, method, params); -} - -void StatusCallbackAdapter(int thread_id, int callbacks_id, - base::PlatformFileError error) { - if (error == base::PLATFORM_FILE_OK) { - CallbackFileSystemCallbacks( - thread_id, callbacks_id, - &WebFileSystemCallbacks::didSucceed, MakeTuple()); - } else { - CallbackFileSystemCallbacks( - thread_id, callbacks_id, - &WebFileSystemCallbacks::didFail, - MakeTuple(fileapi::PlatformFileErrorToWebFileError(error))); - } -} - -void ReadMetadataCallbackAdapter(int thread_id, int callbacks_id, - const base::PlatformFileInfo& file_info) { - WebFileInfo web_file_info; - webkit_glue::PlatformFileInfoToWebFileInfo(file_info, &web_file_info); - CallbackFileSystemCallbacks( - thread_id, callbacks_id, - &WebFileSystemCallbacks::didReadMetadata, - MakeTuple(web_file_info)); -} - -void ReadDirectoryCallbackAdapater( - int thread_id, int callbacks_id, - const std::vector<fileapi::DirectoryEntry>& entries, - bool has_more) { - WebVector<WebFileSystemEntry> file_system_entries(entries.size()); - for (size_t i = 0; i < entries.size(); i++) { - file_system_entries[i].name = - base::FilePath(entries[i].name).AsUTF16Unsafe(); - file_system_entries[i].isDirectory = entries[i].is_directory; - } - CallbackFileSystemCallbacks( - thread_id, callbacks_id, - &WebFileSystemCallbacks::didReadDirectory, - MakeTuple(file_system_entries, has_more)); -} - -void CreateSnapshotFileCallbackAdapter( - int thread_id, int callbacks_id, - base::MessageLoopProxy* main_thread_loop, - const base::PlatformFileInfo& file_info, - const base::FilePath& platform_path, - int request_id) { - if (thread_id != CurrentWorkerId()) { - WorkerTaskRunner::Instance()->PostTask( - thread_id, - base::Bind(&CreateSnapshotFileCallbackAdapter, - thread_id, callbacks_id, - make_scoped_refptr(main_thread_loop), - file_info, platform_path, request_id)); - return; - } - - if (!CallbacksMap::Get()) - return; - - WebFileSystemCallbacks* callbacks = - CallbacksMap::Get()->GetAndUnregisterCallbacks(callbacks_id); - DCHECK(callbacks); - - WebFileInfo web_file_info; - webkit_glue::PlatformFileInfoToWebFileInfo(file_info, &web_file_info); - web_file_info.platformPath = platform_path.AsUTF16Unsafe(); - callbacks->didCreateSnapshotFile(web_file_info); - - // TODO(michaeln,kinuko): Use ThreadSafeSender when Blob becomes - // non-bridge model. - main_thread_loop->PostTask( - FROM_HERE, base::Bind(&DidReceiveSnapshotFile, request_id)); -} - } // namespace -WebFileSystemImpl::~WebFileSystemImpl() { -} - -WebFileSystemImpl::WebFileSystemImpl(base::MessageLoopProxy* main_thread_loop) - : main_thread_loop_(main_thread_loop) { +WebFileSystemImpl::WebFileSystemImpl() { } -void WebFileSystemImpl::move( - const WebKit::WebURL& src_path, - const WebKit::WebURL& dest_path, - WebKit::WebFileSystemCallbacks* callbacks) { - int callbacks_id = CallbacksMap::GetOrCreate()->RegisterCallbacks(callbacks); - CallDispatcherOnMainThread( - main_thread_loop_.get(), - &FileSystemDispatcher::Move, - MakeTuple(GURL(src_path), GURL(dest_path), - base::Bind(&StatusCallbackAdapter, - CurrentWorkerId(), callbacks_id))); +void WebFileSystemImpl::move(const WebURL& src_path, + const WebURL& dest_path, + WebFileSystemCallbacks* callbacks) { + FileSystemDispatcher* dispatcher = + ChildThread::current()->file_system_dispatcher(); + dispatcher->Move(GURL(src_path), + GURL(dest_path), + base::Bind(&FileStatusCallbackAdapter, callbacks)); } -void WebFileSystemImpl::copy( - const WebKit::WebURL& src_path, - const WebKit::WebURL& dest_path, - WebKit::WebFileSystemCallbacks* callbacks) { - int callbacks_id = CallbacksMap::GetOrCreate()->RegisterCallbacks(callbacks); - CallDispatcherOnMainThread( - main_thread_loop_.get(), - &FileSystemDispatcher::Copy, - MakeTuple(GURL(src_path), GURL(dest_path), - base::Bind(&StatusCallbackAdapter, - CurrentWorkerId(), callbacks_id))); +void WebFileSystemImpl::copy(const WebURL& src_path, + const WebURL& dest_path, + WebFileSystemCallbacks* callbacks) { + FileSystemDispatcher* dispatcher = + ChildThread::current()->file_system_dispatcher(); + dispatcher->Copy(GURL(src_path), + GURL(dest_path), + base::Bind(&FileStatusCallbackAdapter, callbacks)); } -void WebFileSystemImpl::remove( - const WebKit::WebURL& path, - WebKit::WebFileSystemCallbacks* callbacks) { - int callbacks_id = CallbacksMap::GetOrCreate()->RegisterCallbacks(callbacks); - CallDispatcherOnMainThread( - main_thread_loop_.get(), - &FileSystemDispatcher::Remove, - MakeTuple(GURL(path), false /* recursive */, - base::Bind(&StatusCallbackAdapter, - CurrentWorkerId(), callbacks_id))); +void WebFileSystemImpl::remove(const WebURL& path, + WebFileSystemCallbacks* callbacks) { + FileSystemDispatcher* dispatcher = + ChildThread::current()->file_system_dispatcher(); + dispatcher->Remove( + GURL(path), + false /* recursive */, + base::Bind(&FileStatusCallbackAdapter, callbacks)); } -void WebFileSystemImpl::removeRecursively( - const WebKit::WebURL& path, - WebKit::WebFileSystemCallbacks* callbacks) { - int callbacks_id = CallbacksMap::GetOrCreate()->RegisterCallbacks(callbacks); - CallDispatcherOnMainThread( - main_thread_loop_.get(), - &FileSystemDispatcher::Remove, - MakeTuple(GURL(path), true /* recursive */, - base::Bind(&StatusCallbackAdapter, - CurrentWorkerId(), callbacks_id))); +void WebFileSystemImpl::removeRecursively(const WebURL& path, + WebFileSystemCallbacks* callbacks) { + FileSystemDispatcher* dispatcher = + ChildThread::current()->file_system_dispatcher(); + dispatcher->Remove( + GURL(path), + true /* recursive */, + base::Bind(&FileStatusCallbackAdapter, callbacks)); } -void WebFileSystemImpl::readMetadata( - const WebKit::WebURL& path, - WebKit::WebFileSystemCallbacks* callbacks) { - int callbacks_id = CallbacksMap::GetOrCreate()->RegisterCallbacks(callbacks); - CallDispatcherOnMainThread( - main_thread_loop_.get(), - &FileSystemDispatcher::ReadMetadata, - MakeTuple(GURL(path), - base::Bind(&ReadMetadataCallbackAdapter, - CurrentWorkerId(), callbacks_id), - base::Bind(&StatusCallbackAdapter, - CurrentWorkerId(), callbacks_id))); +void WebFileSystemImpl::readMetadata(const WebURL& path, + WebFileSystemCallbacks* callbacks) { + FileSystemDispatcher* dispatcher = + ChildThread::current()->file_system_dispatcher(); + dispatcher->ReadMetadata( + GURL(path), + base::Bind(&ReadMetadataCallbackAdapter, callbacks), + base::Bind(&FileStatusCallbackAdapter, callbacks)); } -void WebFileSystemImpl::createFile( - const WebKit::WebURL& path, - bool exclusive, - WebKit::WebFileSystemCallbacks* callbacks) { - int callbacks_id = CallbacksMap::GetOrCreate()->RegisterCallbacks(callbacks); - CallDispatcherOnMainThread( - main_thread_loop_.get(), - &FileSystemDispatcher::CreateFile, - MakeTuple(GURL(path), exclusive, - base::Bind(&StatusCallbackAdapter, - CurrentWorkerId(), callbacks_id))); +void WebFileSystemImpl::createFile(const WebURL& path, + bool exclusive, + WebFileSystemCallbacks* callbacks) { + FileSystemDispatcher* dispatcher = + ChildThread::current()->file_system_dispatcher(); + dispatcher->CreateFile( + GURL(path), exclusive, + base::Bind(&FileStatusCallbackAdapter, callbacks)); } -void WebFileSystemImpl::createDirectory( - const WebKit::WebURL& path, - bool exclusive, - WebKit::WebFileSystemCallbacks* callbacks) { - int callbacks_id = CallbacksMap::GetOrCreate()->RegisterCallbacks(callbacks); - CallDispatcherOnMainThread( - main_thread_loop_.get(), - &FileSystemDispatcher::CreateDirectory, - MakeTuple(GURL(path), exclusive, false /* recursive */, - base::Bind(&StatusCallbackAdapter, - CurrentWorkerId(), callbacks_id))); +void WebFileSystemImpl::createDirectory(const WebURL& path, + bool exclusive, + WebFileSystemCallbacks* callbacks) { + FileSystemDispatcher* dispatcher = + ChildThread::current()->file_system_dispatcher(); + dispatcher->CreateDirectory( + GURL(path), exclusive, false /* recursive */, + base::Bind(&FileStatusCallbackAdapter, callbacks)); } -void WebFileSystemImpl::fileExists( - const WebKit::WebURL& path, - WebKit::WebFileSystemCallbacks* callbacks) { - int callbacks_id = CallbacksMap::GetOrCreate()->RegisterCallbacks(callbacks); - CallDispatcherOnMainThread( - main_thread_loop_.get(), - &FileSystemDispatcher::Exists, - MakeTuple(GURL(path), false /* directory */, - base::Bind(&StatusCallbackAdapter, - CurrentWorkerId(), callbacks_id))); +void WebFileSystemImpl::fileExists(const WebURL& path, + WebFileSystemCallbacks* callbacks) { + FileSystemDispatcher* dispatcher = + ChildThread::current()->file_system_dispatcher(); + dispatcher->Exists( + GURL(path), false /* directory */, + base::Bind(&FileStatusCallbackAdapter, callbacks)); } -void WebFileSystemImpl::directoryExists( - const WebKit::WebURL& path, - WebKit::WebFileSystemCallbacks* callbacks) { - int callbacks_id = CallbacksMap::GetOrCreate()->RegisterCallbacks(callbacks); - CallDispatcherOnMainThread( - main_thread_loop_.get(), - &FileSystemDispatcher::Exists, - MakeTuple(GURL(path), true /* directory */, - base::Bind(&StatusCallbackAdapter, - CurrentWorkerId(), callbacks_id))); +void WebFileSystemImpl::directoryExists(const WebURL& path, + WebFileSystemCallbacks* callbacks) { + FileSystemDispatcher* dispatcher = + ChildThread::current()->file_system_dispatcher(); + dispatcher->Exists( + GURL(path), true /* directory */, + base::Bind(&FileStatusCallbackAdapter, callbacks)); } -void WebFileSystemImpl::readDirectory( - const WebKit::WebURL& path, - WebKit::WebFileSystemCallbacks* callbacks) { - int callbacks_id = CallbacksMap::GetOrCreate()->RegisterCallbacks(callbacks); - CallDispatcherOnMainThread( - main_thread_loop_.get(), - &FileSystemDispatcher::ReadDirectory, - MakeTuple(GURL(path), - base::Bind(&ReadDirectoryCallbackAdapater, - CurrentWorkerId(), callbacks_id), - base::Bind(&StatusCallbackAdapter, - CurrentWorkerId(), callbacks_id))); +void WebFileSystemImpl::readDirectory(const WebURL& path, + WebFileSystemCallbacks* callbacks) { + FileSystemDispatcher* dispatcher = + ChildThread::current()->file_system_dispatcher(); + dispatcher->ReadDirectory( + GURL(path), + base::Bind(&ReadDirectoryCallbackAdapater, callbacks), + base::Bind(&FileStatusCallbackAdapter, callbacks)); } WebKit::WebFileWriter* WebFileSystemImpl::createFileWriter( @@ -375,8 +151,6 @@ void WebFileSystemImpl::createFileWriter( const WebURL& path, WebKit::WebFileWriterClient* client, WebKit::WebFileSystemCallbacks* callbacks) { - // TODO(kinuko): Convert this method to use bridge model. (crbug.com/257349) - DCHECK(main_thread_loop_->RunsTasksOnCurrentThread()); FileSystemDispatcher* dispatcher = ChildThread::current()->file_system_dispatcher(); dispatcher->ReadMetadata( @@ -389,16 +163,12 @@ void WebFileSystemImpl::createFileWriter( void WebFileSystemImpl::createSnapshotFileAndReadMetadata( const WebKit::WebURL& path, WebKit::WebFileSystemCallbacks* callbacks) { - int callbacks_id = CallbacksMap::GetOrCreate()->RegisterCallbacks(callbacks); - CallDispatcherOnMainThread( - main_thread_loop_.get(), - &FileSystemDispatcher::CreateSnapshotFile, - MakeTuple(GURL(path), - base::Bind(&CreateSnapshotFileCallbackAdapter, - CurrentWorkerId(), callbacks_id, - main_thread_loop_), - base::Bind(&StatusCallbackAdapter, - CurrentWorkerId(), callbacks_id))); + FileSystemDispatcher* dispatcher = + ChildThread::current()->file_system_dispatcher(); + dispatcher->CreateSnapshotFile( + GURL(path), + base::Bind(&CreateSnapshotFileCallbackAdapter, callbacks), + base::Bind(&FileStatusCallbackAdapter, callbacks)); } } // namespace content diff --git a/content/child/fileapi/webfilesystem_impl.h b/content/child/fileapi/webfilesystem_impl.h index d9a2584..6ca0c5b 100644 --- a/content/child/fileapi/webfilesystem_impl.h +++ b/content/child/fileapi/webfilesystem_impl.h @@ -7,13 +7,8 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" -#include "base/memory/ref_counted.h" #include "third_party/WebKit/public/platform/WebFileSystem.h" -namespace base { -class MessageLoopProxy; -} - namespace WebKit { class WebURL; class WebFileWriter; @@ -24,8 +19,8 @@ namespace content { class WebFileSystemImpl : public WebKit::WebFileSystem { public: - explicit WebFileSystemImpl(base::MessageLoopProxy* main_thread_loop); - virtual ~WebFileSystemImpl(); + WebFileSystemImpl(); + virtual ~WebFileSystemImpl() { } // WebFileSystem implementation. virtual void move( @@ -71,9 +66,6 @@ class WebFileSystemImpl : public WebKit::WebFileSystem { virtual void createSnapshotFileAndReadMetadata( const WebKit::WebURL& path, WebKit::WebFileSystemCallbacks*); - - private: - scoped_refptr<base::MessageLoopProxy> main_thread_loop_; }; } // namespace content diff --git a/content/renderer/renderer_webkitplatformsupport_impl.cc b/content/renderer/renderer_webkitplatformsupport_impl.cc index 007e145..3e30e1d 100644 --- a/content/renderer/renderer_webkitplatformsupport_impl.cc +++ b/content/renderer/renderer_webkitplatformsupport_impl.cc @@ -407,7 +407,7 @@ WebIDBFactory* RendererWebKitPlatformSupportImpl::idbFactory() { WebFileSystem* RendererWebKitPlatformSupportImpl::fileSystem() { if (!web_file_system_) - web_file_system_.reset(new WebFileSystemImpl(child_thread_loop_.get())); + web_file_system_.reset(new WebFileSystemImpl()); return web_file_system_.get(); } diff --git a/content/worker/worker_webkitplatformsupport_impl.cc b/content/worker/worker_webkitplatformsupport_impl.cc index c9042f0..50328c4 100644 --- a/content/worker/worker_webkitplatformsupport_impl.cc +++ b/content/worker/worker_webkitplatformsupport_impl.cc @@ -99,7 +99,7 @@ WebMimeRegistry* WorkerWebKitPlatformSupportImpl::mimeRegistry() { WebFileSystem* WorkerWebKitPlatformSupportImpl::fileSystem() { if (!web_file_system_) - web_file_system_.reset(new WebFileSystemImpl(child_thread_loop_.get())); + web_file_system_.reset(new WebFileSystemImpl()); return web_file_system_.get(); } |