| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/common/fileapi/webfilesystem_impl.h" | 5 #include "content/common/fileapi/webfilesystem_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" |
| 7 #include "content/common/child_thread.h" | 8 #include "content/common/child_thread.h" |
| 8 #include "content/common/fileapi/file_system_dispatcher.h" | 9 #include "content/common/fileapi/file_system_dispatcher.h" |
| 9 #include "content/common/fileapi/webfilesystem_callback_dispatcher.h" | 10 #include "content/common/fileapi/webfilesystem_callback_adapters.h" |
| 10 #include "content/common/fileapi/webfilewriter_impl.h" | 11 #include "content/common/fileapi/webfilewriter_impl.h" |
| 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebFileInfo.h" | 12 #include "third_party/WebKit/Source/Platform/chromium/public/WebFileInfo.h" |
| 12 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" | 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" |
| 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" | 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" |
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback
s.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback
s.h" |
| 15 #include "webkit/glue/webkit_glue.h" | 16 #include "webkit/glue/webkit_glue.h" |
| 16 | 17 |
| 17 using WebKit::WebFileInfo; | 18 using WebKit::WebFileInfo; |
| 18 using WebKit::WebFileSystemCallbacks; | 19 using WebKit::WebFileSystemCallbacks; |
| 19 using WebKit::WebFileSystemEntry; | 20 using WebKit::WebFileSystemEntry; |
| 20 using WebKit::WebString; | 21 using WebKit::WebString; |
| 21 using WebKit::WebURL; | 22 using WebKit::WebURL; |
| 22 using WebKit::WebVector; | 23 using WebKit::WebVector; |
| 23 | 24 |
| 24 namespace content { | 25 namespace content { |
| 25 | 26 |
| 26 WebFileSystemImpl::WebFileSystemImpl() { | 27 WebFileSystemImpl::WebFileSystemImpl() { |
| 27 } | 28 } |
| 28 | 29 |
| 29 void WebFileSystemImpl::move(const WebURL& src_path, | 30 void WebFileSystemImpl::move(const WebURL& src_path, |
| 30 const WebURL& dest_path, | 31 const WebURL& dest_path, |
| 31 WebFileSystemCallbacks* callbacks) { | 32 WebFileSystemCallbacks* callbacks) { |
| 32 FileSystemDispatcher* dispatcher = | 33 FileSystemDispatcher* dispatcher = |
| 33 ChildThread::current()->file_system_dispatcher(); | 34 ChildThread::current()->file_system_dispatcher(); |
| 34 dispatcher->Move(GURL(src_path), | 35 dispatcher->Move(GURL(src_path), |
| 35 GURL(dest_path), | 36 GURL(dest_path), |
| 36 new WebFileSystemCallbackDispatcher(callbacks)); | 37 base::Bind(&FileStatusCallbackAdapter, callbacks)); |
| 37 } | 38 } |
| 38 | 39 |
| 39 void WebFileSystemImpl::copy(const WebURL& src_path, | 40 void WebFileSystemImpl::copy(const WebURL& src_path, |
| 40 const WebURL& dest_path, | 41 const WebURL& dest_path, |
| 41 WebFileSystemCallbacks* callbacks) { | 42 WebFileSystemCallbacks* callbacks) { |
| 42 FileSystemDispatcher* dispatcher = | 43 FileSystemDispatcher* dispatcher = |
| 43 ChildThread::current()->file_system_dispatcher(); | 44 ChildThread::current()->file_system_dispatcher(); |
| 44 dispatcher->Copy(GURL(src_path), | 45 dispatcher->Copy(GURL(src_path), |
| 45 GURL(dest_path), | 46 GURL(dest_path), |
| 46 new WebFileSystemCallbackDispatcher(callbacks)); | 47 base::Bind(&FileStatusCallbackAdapter, callbacks)); |
| 47 } | 48 } |
| 48 | 49 |
| 49 void WebFileSystemImpl::remove(const WebURL& path, | 50 void WebFileSystemImpl::remove(const WebURL& path, |
| 50 WebFileSystemCallbacks* callbacks) { | 51 WebFileSystemCallbacks* callbacks) { |
| 51 FileSystemDispatcher* dispatcher = | 52 FileSystemDispatcher* dispatcher = |
| 52 ChildThread::current()->file_system_dispatcher(); | 53 ChildThread::current()->file_system_dispatcher(); |
| 53 dispatcher->Remove(GURL(path), | 54 dispatcher->Remove( |
| 54 false /* recursive */, | 55 GURL(path), |
| 55 new WebFileSystemCallbackDispatcher(callbacks)); | 56 false /* recursive */, |
| 57 base::Bind(&FileStatusCallbackAdapter, callbacks)); |
| 56 } | 58 } |
| 57 | 59 |
| 58 void WebFileSystemImpl::removeRecursively(const WebURL& path, | 60 void WebFileSystemImpl::removeRecursively(const WebURL& path, |
| 59 WebFileSystemCallbacks* callbacks) { | 61 WebFileSystemCallbacks* callbacks) { |
| 60 FileSystemDispatcher* dispatcher = | 62 FileSystemDispatcher* dispatcher = |
| 61 ChildThread::current()->file_system_dispatcher(); | 63 ChildThread::current()->file_system_dispatcher(); |
| 62 dispatcher->Remove(GURL(path), | 64 dispatcher->Remove( |
| 63 true /* recursive */, | 65 GURL(path), |
| 64 new WebFileSystemCallbackDispatcher(callbacks)); | 66 true /* recursive */, |
| 67 base::Bind(&FileStatusCallbackAdapter, callbacks)); |
| 65 } | 68 } |
| 66 | 69 |
| 67 void WebFileSystemImpl::readMetadata(const WebURL& path, | 70 void WebFileSystemImpl::readMetadata(const WebURL& path, |
| 68 WebFileSystemCallbacks* callbacks) { | 71 WebFileSystemCallbacks* callbacks) { |
| 69 FileSystemDispatcher* dispatcher = | 72 FileSystemDispatcher* dispatcher = |
| 70 ChildThread::current()->file_system_dispatcher(); | 73 ChildThread::current()->file_system_dispatcher(); |
| 71 dispatcher->ReadMetadata(GURL(path), | 74 dispatcher->ReadMetadata( |
| 72 new WebFileSystemCallbackDispatcher(callbacks)); | 75 GURL(path), |
| 76 base::Bind(&ReadMetadataCallbackAdapter, callbacks), |
| 77 base::Bind(&FileStatusCallbackAdapter, callbacks)); |
| 73 } | 78 } |
| 74 | 79 |
| 75 void WebFileSystemImpl::createFile(const WebURL& path, | 80 void WebFileSystemImpl::createFile(const WebURL& path, |
| 76 bool exclusive, | 81 bool exclusive, |
| 77 WebFileSystemCallbacks* callbacks) { | 82 WebFileSystemCallbacks* callbacks) { |
| 78 FileSystemDispatcher* dispatcher = | 83 FileSystemDispatcher* dispatcher = |
| 79 ChildThread::current()->file_system_dispatcher(); | 84 ChildThread::current()->file_system_dispatcher(); |
| 80 dispatcher->Create(GURL(path), exclusive, false, | 85 dispatcher->Create( |
| 81 false, new WebFileSystemCallbackDispatcher(callbacks)); | 86 GURL(path), exclusive, false /* directory */, false /* recursive */, |
| 87 base::Bind(&FileStatusCallbackAdapter, callbacks)); |
| 82 } | 88 } |
| 83 | 89 |
| 84 void WebFileSystemImpl::createDirectory(const WebURL& path, | 90 void WebFileSystemImpl::createDirectory(const WebURL& path, |
| 85 bool exclusive, | 91 bool exclusive, |
| 86 WebFileSystemCallbacks* callbacks) { | 92 WebFileSystemCallbacks* callbacks) { |
| 87 FileSystemDispatcher* dispatcher = | 93 FileSystemDispatcher* dispatcher = |
| 88 ChildThread::current()->file_system_dispatcher(); | 94 ChildThread::current()->file_system_dispatcher(); |
| 89 dispatcher->Create(GURL(path), exclusive, true, | 95 dispatcher->Create( |
| 90 false, new WebFileSystemCallbackDispatcher(callbacks)); | 96 GURL(path), exclusive, true /* directory */, false /* recursive */, |
| 97 base::Bind(&FileStatusCallbackAdapter, callbacks)); |
| 91 } | 98 } |
| 92 | 99 |
| 93 void WebFileSystemImpl::fileExists(const WebURL& path, | 100 void WebFileSystemImpl::fileExists(const WebURL& path, |
| 94 WebFileSystemCallbacks* callbacks) { | 101 WebFileSystemCallbacks* callbacks) { |
| 95 FileSystemDispatcher* dispatcher = | 102 FileSystemDispatcher* dispatcher = |
| 96 ChildThread::current()->file_system_dispatcher(); | 103 ChildThread::current()->file_system_dispatcher(); |
| 97 dispatcher->Exists(GURL(path), false, | 104 dispatcher->Exists( |
| 98 new WebFileSystemCallbackDispatcher(callbacks)); | 105 GURL(path), false /* directory */, |
| 106 base::Bind(&FileStatusCallbackAdapter, callbacks)); |
| 99 } | 107 } |
| 100 | 108 |
| 101 void WebFileSystemImpl::directoryExists(const WebURL& path, | 109 void WebFileSystemImpl::directoryExists(const WebURL& path, |
| 102 WebFileSystemCallbacks* callbacks) { | 110 WebFileSystemCallbacks* callbacks) { |
| 103 FileSystemDispatcher* dispatcher = | 111 FileSystemDispatcher* dispatcher = |
| 104 ChildThread::current()->file_system_dispatcher(); | 112 ChildThread::current()->file_system_dispatcher(); |
| 105 dispatcher->Exists(GURL(path), true, | 113 dispatcher->Exists( |
| 106 new WebFileSystemCallbackDispatcher(callbacks)); | 114 GURL(path), true /* directory */, |
| 115 base::Bind(&FileStatusCallbackAdapter, callbacks)); |
| 107 } | 116 } |
| 108 | 117 |
| 109 void WebFileSystemImpl::readDirectory(const WebURL& path, | 118 void WebFileSystemImpl::readDirectory(const WebURL& path, |
| 110 WebFileSystemCallbacks* callbacks) { | 119 WebFileSystemCallbacks* callbacks) { |
| 111 FileSystemDispatcher* dispatcher = | 120 FileSystemDispatcher* dispatcher = |
| 112 ChildThread::current()->file_system_dispatcher(); | 121 ChildThread::current()->file_system_dispatcher(); |
| 113 dispatcher->ReadDirectory(GURL(path), | 122 dispatcher->ReadDirectory( |
| 114 new WebFileSystemCallbackDispatcher(callbacks)); | 123 GURL(path), |
| 124 base::Bind(&ReadDirectoryCallbackAdapater, callbacks), |
| 125 base::Bind(&FileStatusCallbackAdapter, callbacks)); |
| 115 } | 126 } |
| 116 | 127 |
| 117 WebKit::WebFileWriter* WebFileSystemImpl::createFileWriter( | 128 WebKit::WebFileWriter* WebFileSystemImpl::createFileWriter( |
| 118 const WebURL& path, WebKit::WebFileWriterClient* client) { | 129 const WebURL& path, WebKit::WebFileWriterClient* client) { |
| 119 return new WebFileWriterImpl(GURL(path), client); | 130 return new WebFileWriterImpl(GURL(path), client); |
| 120 } | 131 } |
| 121 | 132 |
| 122 void WebFileSystemImpl::createSnapshotFileAndReadMetadata( | 133 void WebFileSystemImpl::createSnapshotFileAndReadMetadata( |
| 123 const WebKit::WebURL& path, | 134 const WebKit::WebURL& path, |
| 124 WebKit::WebFileSystemCallbacks* callbacks) { | 135 WebKit::WebFileSystemCallbacks* callbacks) { |
| 125 FileSystemDispatcher* dispatcher = | 136 FileSystemDispatcher* dispatcher = |
| 126 ChildThread::current()->file_system_dispatcher(); | 137 ChildThread::current()->file_system_dispatcher(); |
| 127 dispatcher->CreateSnapshotFile( | 138 dispatcher->CreateSnapshotFile( |
| 128 GURL(path), new WebFileSystemCallbackDispatcher(callbacks)); | 139 GURL(path), |
| 140 base::Bind(&CreateSnapshotFileCallbackAdapter, callbacks), |
| 141 base::Bind(&FileStatusCallbackAdapter, callbacks)); |
| 129 } | 142 } |
| 130 | 143 |
| 131 } // namespace content | 144 } // namespace content |
| OLD | NEW |