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

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

Issue 10447055: Move fileapi into its own component (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup Created 8 years, 6 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
« no previous file with comments | « webkit/glue/webkit_glue.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "webkit/tools/test_shell/simple_file_system.h" 5 #include "webkit/tools/test_shell/simple_file_system.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_path.h" 8 #include "base/file_path.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 "net/base/mime_util.h" 14 #include "net/base/mime_util.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileInfo.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileInfo.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback s.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback s.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemEntry.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemEntry.h"
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
21 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" 21 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h"
22 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" 22 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h"
23 #include "webkit/blob/blob_storage_controller.h" 23 #include "webkit/blob/blob_storage_controller.h"
24 #include "webkit/fileapi/file_system_util.h"
24 #include "webkit/fileapi/mock_file_system_options.h" 25 #include "webkit/fileapi/mock_file_system_options.h"
25 #include "webkit/glue/webkit_glue.h" 26 #include "webkit/glue/webkit_glue.h"
26 #include "webkit/tools/test_shell/simple_file_writer.h" 27 #include "webkit/tools/test_shell/simple_file_writer.h"
27 28
28 using base::WeakPtr; 29 using base::WeakPtr;
29 30
30 using WebKit::WebFileInfo; 31 using WebKit::WebFileInfo;
31 using WebKit::WebFileSystem; 32 using WebKit::WebFileSystem;
32 using WebKit::WebFileSystemCallbacks; 33 using WebKit::WebFileSystemCallbacks;
33 using WebKit::WebFileSystemEntry; 34 using WebKit::WebFileSystemEntry;
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 WebFileSystemCallbacks* callbacks) { 232 WebFileSystemCallbacks* callbacks) {
232 return base::Bind(&SimpleFileSystem::DidCreateSnapshotFile, 233 return base::Bind(&SimpleFileSystem::DidCreateSnapshotFile,
233 AsWeakPtr(), blob_url, base::Unretained(callbacks)); 234 AsWeakPtr(), blob_url, base::Unretained(callbacks));
234 } 235 }
235 236
236 void SimpleFileSystem::DidFinish(WebFileSystemCallbacks* callbacks, 237 void SimpleFileSystem::DidFinish(WebFileSystemCallbacks* callbacks,
237 base::PlatformFileError result) { 238 base::PlatformFileError result) {
238 if (result == base::PLATFORM_FILE_OK) 239 if (result == base::PLATFORM_FILE_OK)
239 callbacks->didSucceed(); 240 callbacks->didSucceed();
240 else 241 else
241 callbacks->didFail(webkit_glue::PlatformFileErrorToWebFileError(result)); 242 callbacks->didFail(fileapi::PlatformFileErrorToWebFileError(result));
242 } 243 }
243 244
244 void SimpleFileSystem::DidGetMetadata(WebFileSystemCallbacks* callbacks, 245 void SimpleFileSystem::DidGetMetadata(WebFileSystemCallbacks* callbacks,
245 base::PlatformFileError result, 246 base::PlatformFileError result,
246 const base::PlatformFileInfo& info, 247 const base::PlatformFileInfo& info,
247 const FilePath& platform_path) { 248 const FilePath& platform_path) {
248 if (result == base::PLATFORM_FILE_OK) { 249 if (result == base::PLATFORM_FILE_OK) {
249 WebFileInfo web_file_info; 250 WebFileInfo web_file_info;
250 web_file_info.length = info.size; 251 web_file_info.length = info.size;
251 web_file_info.modificationTime = info.last_modified.ToDoubleT(); 252 web_file_info.modificationTime = info.last_modified.ToDoubleT();
252 web_file_info.type = info.is_directory ? 253 web_file_info.type = info.is_directory ?
253 WebFileInfo::TypeDirectory : WebFileInfo::TypeFile; 254 WebFileInfo::TypeDirectory : WebFileInfo::TypeFile;
254 web_file_info.platformPath = 255 web_file_info.platformPath =
255 webkit_glue::FilePathToWebString(platform_path); 256 webkit_glue::FilePathToWebString(platform_path);
256 callbacks->didReadMetadata(web_file_info); 257 callbacks->didReadMetadata(web_file_info);
257 } else { 258 } else {
258 callbacks->didFail(webkit_glue::PlatformFileErrorToWebFileError(result)); 259 callbacks->didFail(fileapi::PlatformFileErrorToWebFileError(result));
259 } 260 }
260 } 261 }
261 262
262 void SimpleFileSystem::DidReadDirectory( 263 void SimpleFileSystem::DidReadDirectory(
263 WebFileSystemCallbacks* callbacks, 264 WebFileSystemCallbacks* callbacks,
264 base::PlatformFileError result, 265 base::PlatformFileError result,
265 const std::vector<base::FileUtilProxy::Entry>& entries, 266 const std::vector<base::FileUtilProxy::Entry>& entries,
266 bool has_more) { 267 bool has_more) {
267 if (result == base::PLATFORM_FILE_OK) { 268 if (result == base::PLATFORM_FILE_OK) {
268 std::vector<WebFileSystemEntry> web_entries_vector; 269 std::vector<WebFileSystemEntry> web_entries_vector;
269 for (std::vector<base::FileUtilProxy::Entry>::const_iterator it = 270 for (std::vector<base::FileUtilProxy::Entry>::const_iterator it =
270 entries.begin(); it != entries.end(); ++it) { 271 entries.begin(); it != entries.end(); ++it) {
271 WebFileSystemEntry entry; 272 WebFileSystemEntry entry;
272 entry.name = webkit_glue::FilePathStringToWebString(it->name); 273 entry.name = webkit_glue::FilePathStringToWebString(it->name);
273 entry.isDirectory = it->is_directory; 274 entry.isDirectory = it->is_directory;
274 web_entries_vector.push_back(entry); 275 web_entries_vector.push_back(entry);
275 } 276 }
276 WebVector<WebKit::WebFileSystemEntry> web_entries = web_entries_vector; 277 WebVector<WebKit::WebFileSystemEntry> web_entries = web_entries_vector;
277 callbacks->didReadDirectory(web_entries, has_more); 278 callbacks->didReadDirectory(web_entries, has_more);
278 } else { 279 } else {
279 callbacks->didFail(webkit_glue::PlatformFileErrorToWebFileError(result)); 280 callbacks->didFail(fileapi::PlatformFileErrorToWebFileError(result));
280 } 281 }
281 } 282 }
282 283
283 void SimpleFileSystem::DidOpenFileSystem( 284 void SimpleFileSystem::DidOpenFileSystem(
284 WebFileSystemCallbacks* callbacks, 285 WebFileSystemCallbacks* callbacks,
285 base::PlatformFileError result, 286 base::PlatformFileError result,
286 const std::string& name, const GURL& root) { 287 const std::string& name, const GURL& root) {
287 if (result == base::PLATFORM_FILE_OK) { 288 if (result == base::PLATFORM_FILE_OK) {
288 if (!root.is_valid()) 289 if (!root.is_valid())
289 callbacks->didFail(WebKit::WebFileErrorSecurity); 290 callbacks->didFail(WebKit::WebFileErrorSecurity);
290 else 291 else
291 callbacks->didOpenFileSystem(WebString::fromUTF8(name), root); 292 callbacks->didOpenFileSystem(WebString::fromUTF8(name), root);
292 } else { 293 } else {
293 callbacks->didFail(webkit_glue::PlatformFileErrorToWebFileError(result)); 294 callbacks->didFail(fileapi::PlatformFileErrorToWebFileError(result));
294 } 295 }
295 } 296 }
296 297
297 void SimpleFileSystem::DidCreateSnapshotFile( 298 void SimpleFileSystem::DidCreateSnapshotFile(
298 const GURL& blob_url, 299 const GURL& blob_url,
299 WebFileSystemCallbacks* callbacks, 300 WebFileSystemCallbacks* callbacks,
300 base::PlatformFileError result, 301 base::PlatformFileError result,
301 const base::PlatformFileInfo& info, 302 const base::PlatformFileInfo& info,
302 const FilePath& platform_path, 303 const FilePath& platform_path,
303 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) { 304 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) {
304 DCHECK(g_io_thread); 305 DCHECK(g_io_thread);
305 if (result == base::PLATFORM_FILE_OK) { 306 if (result == base::PLATFORM_FILE_OK) {
306 g_io_thread->PostTask( 307 g_io_thread->PostTask(
307 FROM_HERE, 308 FROM_HERE,
308 base::Bind(&RegisterBlob, blob_url, platform_path)); 309 base::Bind(&RegisterBlob, blob_url, platform_path));
309 } 310 }
310 DidGetMetadata(callbacks, result, info, platform_path); 311 DidGetMetadata(callbacks, result, info, platform_path);
311 } 312 }
OLDNEW
« no previous file with comments | « webkit/glue/webkit_glue.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698