Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(477)

Side by Side Diff: webkit/tools/test_shell/simple_file_system.cc

Issue 8999017: Add CreateFileSystemOperation() method to FileSystemContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased from patch 9016020 Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "webkit/tools/test_shell/simple_file_system.h" 5 #include "webkit/tools/test_shell/simple_file_system.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/memory/scoped_callback_factory.h" 8 #include "base/memory/scoped_callback_factory.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
11 #include "base/time.h" 11 #include "base/time.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "googleurl/src/gurl.h" 13 #include "googleurl/src/gurl.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileInfo.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileInfo.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback s.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback s.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemEntry.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemEntry.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
20 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" 20 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h"
21 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" 21 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h"
22 #include "webkit/fileapi/file_system_callback_dispatcher.h" 22 #include "webkit/fileapi/file_system_callback_dispatcher.h"
23 #include "webkit/fileapi/file_system_context.h" 23 #include "webkit/fileapi/file_system_context.h"
24 #include "webkit/fileapi/file_system_operation.h" 24 #include "webkit/fileapi/file_system_operation_interface.h"
25 #include "webkit/fileapi/file_system_types.h" 25 #include "webkit/fileapi/file_system_types.h"
26 #include "webkit/fileapi/mock_file_system_options.h" 26 #include "webkit/fileapi/mock_file_system_options.h"
27 #include "webkit/glue/webkit_glue.h" 27 #include "webkit/glue/webkit_glue.h"
28 #include "webkit/tools/test_shell/simple_file_writer.h" 28 #include "webkit/tools/test_shell/simple_file_writer.h"
29 29
30 using base::WeakPtr; 30 using base::WeakPtr;
31 31
32 using WebKit::WebFileInfo; 32 using WebKit::WebFileInfo;
33 using WebKit::WebFileSystem; 33 using WebKit::WebFileSystem;
34 using WebKit::WebFileSystemCallbacks; 34 using WebKit::WebFileSystemCallbacks;
35 using WebKit::WebFileSystemEntry; 35 using WebKit::WebFileSystemEntry;
36 using WebKit::WebFileWriter; 36 using WebKit::WebFileWriter;
37 using WebKit::WebFileWriterClient; 37 using WebKit::WebFileWriterClient;
38 using WebKit::WebFrame; 38 using WebKit::WebFrame;
39 using WebKit::WebSecurityOrigin; 39 using WebKit::WebSecurityOrigin;
40 using WebKit::WebString; 40 using WebKit::WebString;
41 using WebKit::WebURL; 41 using WebKit::WebURL;
42 using WebKit::WebVector; 42 using WebKit::WebVector;
43 43
44 using fileapi::FileSystemCallbackDispatcher; 44 using fileapi::FileSystemCallbackDispatcher;
45 using fileapi::FileSystemContext; 45 using fileapi::FileSystemContext;
46 using fileapi::FileSystemOperation; 46 using fileapi::FileSystemOperationInterface;
47 47
48 namespace { 48 namespace {
49 49
50 class SimpleFileSystemCallbackDispatcher 50 class SimpleFileSystemCallbackDispatcher
51 : public FileSystemCallbackDispatcher { 51 : public FileSystemCallbackDispatcher {
52 public: 52 public:
53 SimpleFileSystemCallbackDispatcher( 53 SimpleFileSystemCallbackDispatcher(
54 const WeakPtr<SimpleFileSystem>& file_system, 54 const WeakPtr<SimpleFileSystem>& file_system,
55 WebFileSystemCallbacks* callbacks) 55 WebFileSystemCallbacks* callbacks)
56 : file_system_(file_system), 56 : file_system_(file_system),
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 164
165 GURL origin_url(frame->document().securityOrigin().toString()); 165 GURL origin_url(frame->document().securityOrigin().toString());
166 file_system_context_->OpenFileSystem( 166 file_system_context_->OpenFileSystem(
167 origin_url, type, create, 167 origin_url, type, create,
168 new SimpleFileSystemCallbackDispatcher(AsWeakPtr(), callbacks)); 168 new SimpleFileSystemCallbackDispatcher(AsWeakPtr(), callbacks));
169 } 169 }
170 170
171 void SimpleFileSystem::move( 171 void SimpleFileSystem::move(
172 const WebURL& src_path, 172 const WebURL& src_path,
173 const WebURL& dest_path, WebFileSystemCallbacks* callbacks) { 173 const WebURL& dest_path, WebFileSystemCallbacks* callbacks) {
174 GetNewOperation(callbacks)->Move(GURL(src_path), GURL(dest_path)); 174 GetNewOperation(src_path, callbacks)->Move(GURL(src_path), GURL(dest_path));
175 } 175 }
176 176
177 void SimpleFileSystem::copy( 177 void SimpleFileSystem::copy(
178 const WebURL& src_path, const WebURL& dest_path, 178 const WebURL& src_path, const WebURL& dest_path,
179 WebFileSystemCallbacks* callbacks) { 179 WebFileSystemCallbacks* callbacks) {
180 GetNewOperation(callbacks)->Copy(GURL(src_path), GURL(dest_path)); 180 GetNewOperation(src_path, callbacks)->Copy(GURL(src_path), GURL(dest_path));
181 } 181 }
182 182
183 void SimpleFileSystem::remove( 183 void SimpleFileSystem::remove(
184 const WebURL& path, WebFileSystemCallbacks* callbacks) { 184 const WebURL& path, WebFileSystemCallbacks* callbacks) {
185 GetNewOperation(callbacks)->Remove(path, false /* recursive */); 185 GetNewOperation(path, callbacks)->Remove(path, false /* recursive */);
186 } 186 }
187 187
188 void SimpleFileSystem::removeRecursively( 188 void SimpleFileSystem::removeRecursively(
189 const WebURL& path, WebFileSystemCallbacks* callbacks) { 189 const WebURL& path, WebFileSystemCallbacks* callbacks) {
190 GetNewOperation(callbacks)->Remove(path, true /* recursive */); 190 GetNewOperation(path, callbacks)->Remove(path, true /* recursive */);
191 } 191 }
192 192
193 void SimpleFileSystem::readMetadata( 193 void SimpleFileSystem::readMetadata(
194 const WebURL& path, WebFileSystemCallbacks* callbacks) { 194 const WebURL& path, WebFileSystemCallbacks* callbacks) {
195 GetNewOperation(callbacks)->GetMetadata(path); 195 GetNewOperation(path, callbacks)->GetMetadata(path);
196 } 196 }
197 197
198 void SimpleFileSystem::createFile( 198 void SimpleFileSystem::createFile(
199 const WebURL& path, bool exclusive, WebFileSystemCallbacks* callbacks) { 199 const WebURL& path, bool exclusive, WebFileSystemCallbacks* callbacks) {
200 GetNewOperation(callbacks)->CreateFile(path, exclusive); 200 GetNewOperation(path, callbacks)->CreateFile(path, exclusive);
201 } 201 }
202 202
203 void SimpleFileSystem::createDirectory( 203 void SimpleFileSystem::createDirectory(
204 const WebURL& path, bool exclusive, WebFileSystemCallbacks* callbacks) { 204 const WebURL& path, bool exclusive, WebFileSystemCallbacks* callbacks) {
205 GetNewOperation(callbacks)->CreateDirectory(path, exclusive, false); 205 GetNewOperation(path, callbacks)->CreateDirectory(path, exclusive, false);
206 } 206 }
207 207
208 void SimpleFileSystem::fileExists( 208 void SimpleFileSystem::fileExists(
209 const WebURL& path, WebFileSystemCallbacks* callbacks) { 209 const WebURL& path, WebFileSystemCallbacks* callbacks) {
210 GetNewOperation(callbacks)->FileExists(path); 210 GetNewOperation(path, callbacks)->FileExists(path);
211 } 211 }
212 212
213 void SimpleFileSystem::directoryExists( 213 void SimpleFileSystem::directoryExists(
214 const WebURL& path, WebFileSystemCallbacks* callbacks) { 214 const WebURL& path, WebFileSystemCallbacks* callbacks) {
215 GetNewOperation(callbacks)->DirectoryExists(path); 215 GetNewOperation(path, callbacks)->DirectoryExists(path);
216 } 216 }
217 217
218 void SimpleFileSystem::readDirectory( 218 void SimpleFileSystem::readDirectory(
219 const WebURL& path, WebFileSystemCallbacks* callbacks) { 219 const WebURL& path, WebFileSystemCallbacks* callbacks) {
220 GetNewOperation(callbacks)->ReadDirectory(path); 220 GetNewOperation(path, callbacks)->ReadDirectory(path);
221 } 221 }
222 222
223 WebFileWriter* SimpleFileSystem::createFileWriter( 223 WebFileWriter* SimpleFileSystem::createFileWriter(
224 const WebURL& path, WebFileWriterClient* client) { 224 const WebURL& path, WebFileWriterClient* client) {
225 return new SimpleFileWriter(path, client, file_system_context_.get()); 225 return new SimpleFileWriter(path, client, file_system_context_.get());
226 } 226 }
227 227
228 FileSystemOperation* SimpleFileSystem::GetNewOperation( 228 FileSystemOperationInterface* SimpleFileSystem::GetNewOperation(
229 WebFileSystemCallbacks* callbacks) { 229 const WebURL& url, WebFileSystemCallbacks* callbacks) {
230 SimpleFileSystemCallbackDispatcher* dispatcher = 230 SimpleFileSystemCallbackDispatcher* dispatcher =
231 new SimpleFileSystemCallbackDispatcher(AsWeakPtr(), callbacks); 231 new SimpleFileSystemCallbackDispatcher(AsWeakPtr(), callbacks);
232 FileSystemOperation* operation = new FileSystemOperation( 232 return file_system_context_->CreateFileSystemOperation(
233 dispatcher, base::MessageLoopProxy::current(), 233 GURL(url), dispatcher, base::MessageLoopProxy::current());
234 file_system_context_.get());
235 return operation;
236 } 234 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698