diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-10 17:43:45 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-10 17:43:45 +0000 |
commit | 085b1a3ad86fd100e166e36059a85c6e6f69ac18 (patch) | |
tree | af9e5ea4183682e404f73700d5060cbae18d8049 /content/child/fileapi | |
parent | d26e799d9ef35c7479d9d9dfbc6ebd994f57107a (diff) | |
download | chromium_src-085b1a3ad86fd100e166e36059a85c6e6f69ac18.zip chromium_src-085b1a3ad86fd100e166e36059a85c6e6f69ac18.tar.gz chromium_src-085b1a3ad86fd100e166e36059a85c6e6f69ac18.tar.bz2 |
Post-cleanup after WebFileSystemCallbacks switch
BUG=257349
Review URL: https://chromiumcodereview.appspot.com/24068002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222301 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/child/fileapi')
-rw-r--r-- | content/child/fileapi/webfilesystem_impl.cc | 77 | ||||
-rw-r--r-- | content/child/fileapi/webfilesystem_impl.h | 44 |
2 files changed, 45 insertions, 76 deletions
diff --git a/content/child/fileapi/webfilesystem_impl.cc b/content/child/fileapi/webfilesystem_impl.cc index 2c3de4d..ac91214 100644 --- a/content/child/fileapi/webfilesystem_impl.cc +++ b/content/child/fileapi/webfilesystem_impl.cc @@ -37,23 +37,14 @@ namespace content { namespace { -// TODO(kinuko): Remove this hack after the two-sided patch lands. -WebFileSystemCallbacks* Wrapper(WebFileSystemCallbacksType& cb) { -#ifdef NON_SELFDESTRUCT_WEBFILESYSTEMCALLBACKS - return &cb; -#else - return cb; -#endif -} - base::LazyInstance<base::ThreadLocalPointer<WebFileSystemImpl> >::Leaky g_webfilesystem_tls = LAZY_INSTANCE_INITIALIZER; class WaitableCallbackResults { public: static WaitableCallbackResults* MaybeCreate( - WebFileSystemCallbacksType callbacks) { - if (Wrapper(callbacks)->shouldBlockUntilCompletion()) + const WebFileSystemCallbacks& callbacks) { + if (callbacks.shouldBlockUntilCompletion()) return new WaitableCallbackResults; return NULL; } @@ -119,9 +110,9 @@ void RunCallbacks(int callbacks_id, Method method, const Params& params) { WebFileSystemImpl::ThreadSpecificInstance(NULL); if (!filesystem) return; - WebFileSystemCallbacksType callbacks = + WebFileSystemCallbacks callbacks = filesystem->GetAndUnregisterCallbacks(callbacks_id); - DispatchToMethod(Wrapper(callbacks), method, params); + DispatchToMethod(&callbacks, method, params); } void DispatchResultsClosure(int thread_id, int callbacks_id, @@ -216,17 +207,17 @@ void DidCreateFileWriter( if (!filesystem) return; - WebFileSystemCallbacksType callbacks = + WebFileSystemCallbacks callbacks = filesystem->GetAndUnregisterCallbacks(callbacks_id); if (file_info.is_directory || file_info.size < 0) { - Wrapper(callbacks)->didFail(WebKit::WebFileErrorInvalidState); + callbacks.didFail(WebKit::WebFileErrorInvalidState); return; } WebFileWriterImpl::Type type = - Wrapper(callbacks)->shouldBlockUntilCompletion() ? + callbacks.shouldBlockUntilCompletion() ? WebFileWriterImpl::TYPE_SYNC : WebFileWriterImpl::TYPE_ASYNC; - Wrapper(callbacks)->didCreateFileWriter( + callbacks.didCreateFileWriter( new WebFileWriterImpl(path, client, type, main_thread_loop), file_info.size); } @@ -255,13 +246,13 @@ void DidCreateSnapshotFile( if (!filesystem) return; - WebFileSystemCallbacksType callbacks = + WebFileSystemCallbacks callbacks = filesystem->GetAndUnregisterCallbacks(callbacks_id); WebFileInfo web_file_info; webkit_glue::PlatformFileInfoToWebFileInfo(file_info, &web_file_info); web_file_info.platformPath = platform_path.AsUTF16Unsafe(); - Wrapper(callbacks)->didCreateSnapshotFile(web_file_info); + callbacks.didCreateSnapshotFile(web_file_info); // TODO(michaeln,kinuko): Use ThreadSafeSender when Blob becomes // non-bridge model. @@ -311,12 +302,6 @@ WebFileSystemImpl::WebFileSystemImpl(base::MessageLoopProxy* main_thread_loop) } WebFileSystemImpl::~WebFileSystemImpl() { -#if !defined(NON_SELFDESTRUCT_WEBFILESYSTEMCALLBACKS) - for (CallbacksMap::iterator iter = callbacks_.begin(); - iter != callbacks_.end(); ++iter) { - iter->second->didFail(WebKit::WebFileErrorAbort); - } -#endif g_webfilesystem_tls.Pointer()->Set(NULL); } @@ -328,7 +313,7 @@ void WebFileSystemImpl::openFileSystem( const WebKit::WebURL& storage_partition, WebKit::WebFileSystemType type, bool create, - WebFileSystemCallbacksType callbacks) { + WebFileSystemCallbacks callbacks) { int callbacks_id = RegisterCallbacks(callbacks); WaitableCallbackResults* waitable_results = WaitableCallbackResults::MaybeCreate(callbacks); @@ -350,7 +335,7 @@ void WebFileSystemImpl::openFileSystem( void WebFileSystemImpl::deleteFileSystem( const WebKit::WebURL& storage_partition, WebKit::WebFileSystemType type, - WebFileSystemCallbacksType callbacks) { + WebFileSystemCallbacks callbacks) { int callbacks_id = RegisterCallbacks(callbacks); WaitableCallbackResults* waitable_results = WaitableCallbackResults::MaybeCreate(callbacks); @@ -368,7 +353,7 @@ void WebFileSystemImpl::deleteFileSystem( void WebFileSystemImpl::move( const WebKit::WebURL& src_path, const WebKit::WebURL& dest_path, - WebFileSystemCallbacksType callbacks) { + WebFileSystemCallbacks callbacks) { int callbacks_id = RegisterCallbacks(callbacks); WaitableCallbackResults* waitable_results = WaitableCallbackResults::MaybeCreate(callbacks); @@ -385,7 +370,7 @@ void WebFileSystemImpl::move( void WebFileSystemImpl::copy( const WebKit::WebURL& src_path, const WebKit::WebURL& dest_path, - WebFileSystemCallbacksType callbacks) { + WebFileSystemCallbacks callbacks) { int callbacks_id = RegisterCallbacks(callbacks); WaitableCallbackResults* waitable_results = WaitableCallbackResults::MaybeCreate(callbacks); @@ -401,7 +386,7 @@ void WebFileSystemImpl::copy( void WebFileSystemImpl::remove( const WebKit::WebURL& path, - WebFileSystemCallbacksType callbacks) { + WebFileSystemCallbacks callbacks) { int callbacks_id = RegisterCallbacks(callbacks); WaitableCallbackResults* waitable_results = WaitableCallbackResults::MaybeCreate(callbacks); @@ -417,7 +402,7 @@ void WebFileSystemImpl::remove( void WebFileSystemImpl::removeRecursively( const WebKit::WebURL& path, - WebFileSystemCallbacksType callbacks) { + WebFileSystemCallbacks callbacks) { int callbacks_id = RegisterCallbacks(callbacks); WaitableCallbackResults* waitable_results = WaitableCallbackResults::MaybeCreate(callbacks); @@ -433,7 +418,7 @@ void WebFileSystemImpl::removeRecursively( void WebFileSystemImpl::readMetadata( const WebKit::WebURL& path, - WebFileSystemCallbacksType callbacks) { + WebFileSystemCallbacks callbacks) { int callbacks_id = RegisterCallbacks(callbacks); WaitableCallbackResults* waitable_results = WaitableCallbackResults::MaybeCreate(callbacks); @@ -453,7 +438,7 @@ void WebFileSystemImpl::readMetadata( void WebFileSystemImpl::createFile( const WebKit::WebURL& path, bool exclusive, - WebFileSystemCallbacksType callbacks) { + WebFileSystemCallbacks callbacks) { int callbacks_id = RegisterCallbacks(callbacks); WaitableCallbackResults* waitable_results = WaitableCallbackResults::MaybeCreate(callbacks); @@ -470,7 +455,7 @@ void WebFileSystemImpl::createFile( void WebFileSystemImpl::createDirectory( const WebKit::WebURL& path, bool exclusive, - WebFileSystemCallbacksType callbacks) { + WebFileSystemCallbacks callbacks) { int callbacks_id = RegisterCallbacks(callbacks); WaitableCallbackResults* waitable_results = WaitableCallbackResults::MaybeCreate(callbacks); @@ -486,7 +471,7 @@ void WebFileSystemImpl::createDirectory( void WebFileSystemImpl::fileExists( const WebKit::WebURL& path, - WebFileSystemCallbacksType callbacks) { + WebFileSystemCallbacks callbacks) { int callbacks_id = RegisterCallbacks(callbacks); WaitableCallbackResults* waitable_results = WaitableCallbackResults::MaybeCreate(callbacks); @@ -502,7 +487,7 @@ base::Unretained(waitable_results))), void WebFileSystemImpl::directoryExists( const WebKit::WebURL& path, - WebFileSystemCallbacksType callbacks) { + WebFileSystemCallbacks callbacks) { int callbacks_id = RegisterCallbacks(callbacks); WaitableCallbackResults* waitable_results = WaitableCallbackResults::MaybeCreate(callbacks); @@ -518,7 +503,7 @@ void WebFileSystemImpl::directoryExists( void WebFileSystemImpl::readDirectory( const WebKit::WebURL& path, - WebFileSystemCallbacksType callbacks) { + WebFileSystemCallbacks callbacks) { int callbacks_id = RegisterCallbacks(callbacks); WaitableCallbackResults* waitable_results = WaitableCallbackResults::MaybeCreate(callbacks); @@ -535,17 +520,10 @@ base::Unretained(waitable_results))), make_scoped_ptr(waitable_results)); } -WebKit::WebFileWriter* WebFileSystemImpl::createFileWriter( - const WebURL& path, WebKit::WebFileWriterClient* client) { - return new WebFileWriterImpl(GURL(path), client, - WebFileWriterImpl::TYPE_ASYNC, - main_thread_loop_.get()); -} - void WebFileSystemImpl::createFileWriter( const WebURL& path, WebKit::WebFileWriterClient* client, - WebFileSystemCallbacksType callbacks) { + WebFileSystemCallbacks callbacks) { int callbacks_id = RegisterCallbacks(callbacks); WaitableCallbackResults* waitable_results = WaitableCallbackResults::MaybeCreate(callbacks); @@ -565,7 +543,7 @@ void WebFileSystemImpl::createFileWriter( void WebFileSystemImpl::createSnapshotFileAndReadMetadata( const WebKit::WebURL& path, - WebFileSystemCallbacksType callbacks) { + WebFileSystemCallbacks callbacks) { int callbacks_id = RegisterCallbacks(callbacks); WaitableCallbackResults* waitable_results = WaitableCallbackResults::MaybeCreate(callbacks); @@ -583,19 +561,20 @@ void WebFileSystemImpl::createSnapshotFileAndReadMetadata( make_scoped_ptr(waitable_results)); } -int WebFileSystemImpl::RegisterCallbacks(WebFileSystemCallbacksType callbacks) { +int WebFileSystemImpl::RegisterCallbacks( + const WebFileSystemCallbacks& callbacks) { DCHECK(CalledOnValidThread()); int id = next_callbacks_id_++; callbacks_[id] = callbacks; return id; } -WebFileSystemCallbacksType WebFileSystemImpl::GetAndUnregisterCallbacks( +WebFileSystemCallbacks WebFileSystemImpl::GetAndUnregisterCallbacks( int callbacks_id) { DCHECK(CalledOnValidThread()); CallbacksMap::iterator found = callbacks_.find(callbacks_id); DCHECK(found != callbacks_.end()); - WebFileSystemCallbacksType callbacks = found->second; + WebFileSystemCallbacks callbacks = found->second; callbacks_.erase(found); return callbacks; } diff --git a/content/child/fileapi/webfilesystem_impl.h b/content/child/fileapi/webfilesystem_impl.h index f800ff9..7550545 100644 --- a/content/child/fileapi/webfilesystem_impl.h +++ b/content/child/fileapi/webfilesystem_impl.h @@ -24,13 +24,6 @@ class WebFileWriter; class WebFileWriterClient; } -// TODO(kinuko): Remove this hack after the two-sided patch lands. -#ifdef NON_SELFDESTRUCT_WEBFILESYSTEMCALLBACKS - typedef WebKit::WebFileSystemCallbacks WebFileSystemCallbacksType; -#else - typedef WebKit::WebFileSystemCallbacks* WebFileSystemCallbacksType; -#endif - namespace content { class WebFileSystemImpl @@ -60,62 +53,59 @@ class WebFileSystemImpl const WebKit::WebURL& storage_partition, const WebKit::WebFileSystemType type, bool create, - WebFileSystemCallbacksType); + WebKit::WebFileSystemCallbacks); virtual void deleteFileSystem( const WebKit::WebURL& storage_partition, const WebKit::WebFileSystemType type, - WebFileSystemCallbacksType); + WebKit::WebFileSystemCallbacks); virtual void move( const WebKit::WebURL& src_path, const WebKit::WebURL& dest_path, - WebFileSystemCallbacksType) OVERRIDE; + WebKit::WebFileSystemCallbacks) OVERRIDE; virtual void copy( const WebKit::WebURL& src_path, const WebKit::WebURL& dest_path, - WebFileSystemCallbacksType) OVERRIDE; + WebKit::WebFileSystemCallbacks) OVERRIDE; virtual void remove( const WebKit::WebURL& path, - WebFileSystemCallbacksType) OVERRIDE; + WebKit::WebFileSystemCallbacks) OVERRIDE; virtual void removeRecursively( const WebKit::WebURL& path, - WebFileSystemCallbacksType) OVERRIDE; + WebKit::WebFileSystemCallbacks) OVERRIDE; virtual void readMetadata( const WebKit::WebURL& path, - WebFileSystemCallbacksType) OVERRIDE; + WebKit::WebFileSystemCallbacks) OVERRIDE; virtual void createFile( const WebKit::WebURL& path, bool exclusive, - WebFileSystemCallbacksType) OVERRIDE; + WebKit::WebFileSystemCallbacks) OVERRIDE; virtual void createDirectory( const WebKit::WebURL& path, bool exclusive, - WebFileSystemCallbacksType) OVERRIDE; + WebKit::WebFileSystemCallbacks) OVERRIDE; virtual void fileExists( const WebKit::WebURL& path, - WebFileSystemCallbacksType) OVERRIDE; + WebKit::WebFileSystemCallbacks) OVERRIDE; virtual void directoryExists( const WebKit::WebURL& path, - WebFileSystemCallbacksType) OVERRIDE; + WebKit::WebFileSystemCallbacks) OVERRIDE; virtual void readDirectory( const WebKit::WebURL& path, - WebFileSystemCallbacksType) OVERRIDE; - virtual WebKit::WebFileWriter* createFileWriter( - const WebKit::WebURL& path, - WebKit::WebFileWriterClient*); + WebKit::WebFileSystemCallbacks) OVERRIDE; virtual void createFileWriter( const WebKit::WebURL& path, WebKit::WebFileWriterClient*, - WebFileSystemCallbacksType) OVERRIDE; + WebKit::WebFileSystemCallbacks) OVERRIDE; virtual void createSnapshotFileAndReadMetadata( const WebKit::WebURL& path, - WebFileSystemCallbacksType); + WebKit::WebFileSystemCallbacks); - int RegisterCallbacks(WebFileSystemCallbacksType callbacks); - WebFileSystemCallbacksType GetAndUnregisterCallbacks( + int RegisterCallbacks(const WebKit::WebFileSystemCallbacks& callbacks); + WebKit::WebFileSystemCallbacks GetAndUnregisterCallbacks( int callbacks_id); private: - typedef std::map<int, WebFileSystemCallbacksType> CallbacksMap; + typedef std::map<int, WebKit::WebFileSystemCallbacks> CallbacksMap; scoped_refptr<base::MessageLoopProxy> main_thread_loop_; |