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

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

Issue 6904063: String->URL cleanup, chromium-side. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rolled in code review feedback. Created 9 years, 7 months 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/WebFileInfo.h" 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileInfo.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback s.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback s.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemEntry.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemEntry.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h"
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h" 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h"
20 #include "webkit/fileapi/file_system_callback_dispatcher.h" 21 #include "webkit/fileapi/file_system_callback_dispatcher.h"
21 #include "webkit/fileapi/file_system_context.h" 22 #include "webkit/fileapi/file_system_context.h"
22 #include "webkit/fileapi/file_system_file_util.h" 23 #include "webkit/fileapi/file_system_file_util.h"
23 #include "webkit/fileapi/file_system_operation.h" 24 #include "webkit/fileapi/file_system_operation.h"
24 #include "webkit/fileapi/file_system_path_manager.h" 25 #include "webkit/fileapi/file_system_path_manager.h"
25 #include "webkit/fileapi/file_system_types.h" 26 #include "webkit/fileapi/file_system_types.h"
26 #include "webkit/glue/webkit_glue.h" 27 #include "webkit/glue/webkit_glue.h"
27 #include "webkit/tools/test_shell/simple_file_writer.h" 28 #include "webkit/tools/test_shell/simple_file_writer.h"
28 29
29 using base::WeakPtr; 30 using base::WeakPtr;
30 31
31 using WebKit::WebFileInfo; 32 using WebKit::WebFileInfo;
32 using WebKit::WebFileSystem; 33 using WebKit::WebFileSystem;
33 using WebKit::WebFileSystemCallbacks; 34 using WebKit::WebFileSystemCallbacks;
34 using WebKit::WebFileSystemEntry; 35 using WebKit::WebFileSystemEntry;
35 using WebKit::WebFileWriter; 36 using WebKit::WebFileWriter;
36 using WebKit::WebFileWriterClient; 37 using WebKit::WebFileWriterClient;
37 using WebKit::WebFrame; 38 using WebKit::WebFrame;
38 using WebKit::WebSecurityOrigin; 39 using WebKit::WebSecurityOrigin;
39 using WebKit::WebString; 40 using WebKit::WebString;
41 using WebKit::WebURL;
40 using WebKit::WebVector; 42 using WebKit::WebVector;
41 43
42 using fileapi::FileSystemCallbackDispatcher; 44 using fileapi::FileSystemCallbackDispatcher;
43 using fileapi::FileSystemContext; 45 using fileapi::FileSystemContext;
44 using fileapi::FileSystemFileUtil; 46 using fileapi::FileSystemFileUtil;
45 using fileapi::FileSystemOperation; 47 using fileapi::FileSystemOperation;
46 48
47 namespace { 49 namespace {
48 50
49 class SimpleFileSystemCallbackDispatcher 51 class SimpleFileSystemCallbackDispatcher
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 web_entries_vector; 100 web_entries_vector;
99 callbacks_->didReadDirectory(web_entries, has_more); 101 callbacks_->didReadDirectory(web_entries, has_more);
100 } 102 }
101 103
102 virtual void DidOpenFileSystem( 104 virtual void DidOpenFileSystem(
103 const std::string& name, const GURL& root) { 105 const std::string& name, const GURL& root) {
104 DCHECK(file_system_); 106 DCHECK(file_system_);
105 if (!root.is_valid()) 107 if (!root.is_valid())
106 callbacks_->didFail(WebKit::WebFileErrorSecurity); 108 callbacks_->didFail(WebKit::WebFileErrorSecurity);
107 else 109 else
110 // Temporary hack to ease a 4-phase Chromium/WebKit commit.
111 #ifdef WEBFILESYSTEMCALLBACKS_USE_URL_NOT_STRING
112 callbacks_->didOpenFileSystem(WebString::fromUTF8(name), WebURL(root));
113 #else
108 callbacks_->didOpenFileSystem( 114 callbacks_->didOpenFileSystem(
109 WebString::fromUTF8(name), WebString::fromUTF8(root.spec())); 115 WebString::fromUTF8(name), WebString::fromUTF8(root.spec()));
116 #endif
110 } 117 }
111 118
112 virtual void DidFail(base::PlatformFileError error_code) { 119 virtual void DidFail(base::PlatformFileError error_code) {
113 DCHECK(file_system_); 120 DCHECK(file_system_);
114 callbacks_->didFail( 121 callbacks_->didFail(
115 webkit_glue::PlatformFileErrorToWebFileError(error_code)); 122 webkit_glue::PlatformFileErrorToWebFileError(error_code));
116 } 123 }
117 124
118 virtual void DidWrite(int64, bool) { 125 virtual void DidWrite(int64, bool) {
119 NOTREACHED(); 126 NOTREACHED();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 else { 174 else {
168 // Unknown type filesystem is requested. 175 // Unknown type filesystem is requested.
169 callbacks->didFail(WebKit::WebFileErrorSecurity); 176 callbacks->didFail(WebKit::WebFileErrorSecurity);
170 return; 177 return;
171 } 178 }
172 179
173 GURL origin_url(frame->securityOrigin().toString()); 180 GURL origin_url(frame->securityOrigin().toString());
174 GetNewOperation(callbacks)->OpenFileSystem(origin_url, type, create); 181 GetNewOperation(callbacks)->OpenFileSystem(origin_url, type, create);
175 } 182 }
176 183
184 void SimpleFileSystem::move(const WebString& src_path,
185 const WebString& dest_path,
186 WebFileSystemCallbacks* callbacks) {
187 move(WebURL(GURL(src_path)), WebURL(GURL(dest_path)), callbacks);
188 }
189
190 void SimpleFileSystem::copy(const WebString& src_path,
191 const WebString& dest_path,
192 WebFileSystemCallbacks* callbacks) {
193 copy(WebURL(GURL(src_path)), WebURL(GURL(dest_path)), callbacks);
194 }
195
196 void SimpleFileSystem::remove(const WebString& path,
197 WebFileSystemCallbacks* callbacks) {
198 remove(WebURL(GURL(path)), callbacks);
199 }
200
201 void SimpleFileSystem::removeRecursively(const WebString& path,
202 WebFileSystemCallbacks* callbacks) {
203 removeRecursively(WebURL(GURL(path)), callbacks);
204 }
205
206 void SimpleFileSystem::readMetadata(const WebString& path,
207 WebFileSystemCallbacks* callbacks) {
208 readMetadata(WebURL(GURL(path)), callbacks);
209 }
210
211 void SimpleFileSystem::createFile(const WebString& path,
212 bool exclusive,
213 WebFileSystemCallbacks* callbacks) {
214 createFile(WebURL(GURL(path)), exclusive, callbacks);
215 }
216
217 void SimpleFileSystem::createDirectory(const WebString& path,
218 bool exclusive,
219 WebFileSystemCallbacks* callbacks) {
220 createDirectory(WebURL(GURL(path)), exclusive, callbacks);
221 }
222
223 void SimpleFileSystem::fileExists(const WebString& path,
224 WebFileSystemCallbacks* callbacks) {
225 fileExists(WebURL(GURL(path)), callbacks);
226 }
227
228 void SimpleFileSystem::directoryExists(const WebString& path,
229 WebFileSystemCallbacks* callbacks) {
230 directoryExists(WebURL(GURL(path)), callbacks);
231 }
232
233 void SimpleFileSystem::readDirectory(const WebString& path,
234 WebFileSystemCallbacks* callbacks) {
235 readDirectory(WebURL(GURL(path)), callbacks);
236 }
237
238 WebKit::WebFileWriter* SimpleFileSystem::createFileWriter(
239 const WebString& path, WebKit::WebFileWriterClient* client) {
240 return createFileWriter(WebURL(GURL(path)), client);
241 }
242
177 void SimpleFileSystem::move( 243 void SimpleFileSystem::move(
178 const WebString& src_path, 244 const WebURL& src_path,
179 const WebString& dest_path, WebFileSystemCallbacks* callbacks) { 245 const WebURL& dest_path, WebFileSystemCallbacks* callbacks) {
180 GetNewOperation(callbacks)->Move(GURL(src_path), GURL(dest_path)); 246 GetNewOperation(callbacks)->Move(GURL(src_path), GURL(dest_path));
181 } 247 }
182 248
183 void SimpleFileSystem::copy( 249 void SimpleFileSystem::copy(
184 const WebString& src_path, const WebString& dest_path, 250 const WebURL& src_path, const WebURL& dest_path,
185 WebFileSystemCallbacks* callbacks) { 251 WebFileSystemCallbacks* callbacks) {
186 GetNewOperation(callbacks)->Copy(GURL(src_path), GURL(dest_path)); 252 GetNewOperation(callbacks)->Copy(GURL(src_path), GURL(dest_path));
187 } 253 }
188 254
189 void SimpleFileSystem::remove( 255 void SimpleFileSystem::remove(
190 const WebString& path, WebFileSystemCallbacks* callbacks) { 256 const WebURL& path, WebFileSystemCallbacks* callbacks) {
191 GetNewOperation(callbacks)->Remove(GURL(path), false /* recursive */); 257 GetNewOperation(callbacks)->Remove(path, false /* recursive */);
192 } 258 }
193 259
194 void SimpleFileSystem::removeRecursively( 260 void SimpleFileSystem::removeRecursively(
195 const WebString& path, WebFileSystemCallbacks* callbacks) { 261 const WebURL& path, WebFileSystemCallbacks* callbacks) {
196 GetNewOperation(callbacks)->Remove(GURL(path), true /* recursive */); 262 GetNewOperation(callbacks)->Remove(path, true /* recursive */);
197 } 263 }
198 264
199 void SimpleFileSystem::readMetadata( 265 void SimpleFileSystem::readMetadata(
200 const WebString& path, WebFileSystemCallbacks* callbacks) { 266 const WebURL& path, WebFileSystemCallbacks* callbacks) {
201 GetNewOperation(callbacks)->GetMetadata(GURL(path)); 267 GetNewOperation(callbacks)->GetMetadata(path);
202 } 268 }
203 269
204 void SimpleFileSystem::createFile( 270 void SimpleFileSystem::createFile(
205 const WebString& path, bool exclusive, WebFileSystemCallbacks* callbacks) { 271 const WebURL& path, bool exclusive, WebFileSystemCallbacks* callbacks) {
206 GetNewOperation(callbacks)->CreateFile(GURL(path), exclusive); 272 GetNewOperation(callbacks)->CreateFile(path, exclusive);
207 } 273 }
208 274
209 void SimpleFileSystem::createDirectory( 275 void SimpleFileSystem::createDirectory(
210 const WebString& path, bool exclusive, WebFileSystemCallbacks* callbacks) { 276 const WebURL& path, bool exclusive, WebFileSystemCallbacks* callbacks) {
211 GetNewOperation(callbacks)->CreateDirectory(GURL(path), exclusive, false); 277 GetNewOperation(callbacks)->CreateDirectory(path, exclusive, false);
212 } 278 }
213 279
214 void SimpleFileSystem::fileExists( 280 void SimpleFileSystem::fileExists(
215 const WebString& path, WebFileSystemCallbacks* callbacks) { 281 const WebURL& path, WebFileSystemCallbacks* callbacks) {
216 GetNewOperation(callbacks)->FileExists(GURL(path)); 282 GetNewOperation(callbacks)->FileExists(path);
217 } 283 }
218 284
219 void SimpleFileSystem::directoryExists( 285 void SimpleFileSystem::directoryExists(
220 const WebString& path, WebFileSystemCallbacks* callbacks) { 286 const WebURL& path, WebFileSystemCallbacks* callbacks) {
221 GetNewOperation(callbacks)->DirectoryExists(GURL(path)); 287 GetNewOperation(callbacks)->DirectoryExists(path);
222 } 288 }
223 289
224 void SimpleFileSystem::readDirectory( 290 void SimpleFileSystem::readDirectory(
225 const WebString& path, WebFileSystemCallbacks* callbacks) { 291 const WebURL& path, WebFileSystemCallbacks* callbacks) {
226 GetNewOperation(callbacks)->ReadDirectory(GURL(path)); 292 GetNewOperation(callbacks)->ReadDirectory(path);
227 } 293 }
228 294
229 WebFileWriter* SimpleFileSystem::createFileWriter( 295 WebFileWriter* SimpleFileSystem::createFileWriter(
230 const WebString& path, WebFileWriterClient* client) { 296 const WebURL& path, WebFileWriterClient* client) {
231 return new SimpleFileWriter(GURL(path), client, file_system_context_.get()); 297 return new SimpleFileWriter(path, client, file_system_context_.get());
232 } 298 }
233 299
234 FileSystemOperation* SimpleFileSystem::GetNewOperation( 300 FileSystemOperation* SimpleFileSystem::GetNewOperation(
235 WebFileSystemCallbacks* callbacks) { 301 WebFileSystemCallbacks* callbacks) {
236 SimpleFileSystemCallbackDispatcher* dispatcher = 302 SimpleFileSystemCallbackDispatcher* dispatcher =
237 new SimpleFileSystemCallbackDispatcher(AsWeakPtr(), callbacks); 303 new SimpleFileSystemCallbackDispatcher(AsWeakPtr(), callbacks);
238 FileSystemOperation* operation = new FileSystemOperation( 304 FileSystemOperation* operation = new FileSystemOperation(
239 dispatcher, base::MessageLoopProxy::CreateForCurrentThread(), 305 dispatcher, base::MessageLoopProxy::CreateForCurrentThread(),
240 file_system_context_.get(), NULL); 306 file_system_context_.get(), NULL);
241 return operation; 307 return operation;
242 } 308 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698