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

Side by Side Diff: chrome/common/file_system/webfilesystem_callback_dispatcher.cc

Issue 3604006: Revert 61462 - Add truncate and cancel for FileWriter; write and more tests w... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 2 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/common/file_system/webfilesystem_callback_dispatcher.h" 5 #include "chrome/common/file_system/webfilesystem_callback_dispatcher.h"
6 6
7 #include "base/file_util_proxy.h" 7 #include "base/file_util_proxy.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "third_party/WebKit/WebKit/chromium/public/WebFileInfo.h" 9 #include "third_party/WebKit/WebKit/chromium/public/WebFileInfo.h"
10 #include "third_party/WebKit/WebKit/chromium/public/WebFileSystem.h" 10 #include "third_party/WebKit/WebKit/chromium/public/WebFileSystem.h"
11 #include "third_party/WebKit/WebKit/chromium/public/WebFileSystemCallbacks.h" 11 #include "third_party/WebKit/WebKit/chromium/public/WebFileSystemCallbacks.h"
12 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" 12 #include "third_party/WebKit/WebKit/chromium/public/WebString.h"
13 #include "webkit/glue/webkit_glue.h" 13 #include "webkit/glue/webkit_glue.h"
14 14
15 using WebKit::WebFileInfo; 15 using WebKit::WebFileInfo;
16 using WebKit::WebFileSystemCallbacks; 16 using WebKit::WebFileSystemCallbacks;
17 using WebKit::WebFileSystemEntry; 17 using WebKit::WebFileSystemEntry;
18 using WebKit::WebString; 18 using WebKit::WebString;
19 using WebKit::WebVector; 19 using WebKit::WebVector;
20 20
21 namespace {
22
23 WebKit::WebFileError PlatformFileErrorToWebFileError(
24 base::PlatformFileError error_code) {
25 switch (error_code) {
26 case base::PLATFORM_FILE_ERROR_NOT_FOUND:
27 return WebKit::WebFileErrorNotFound;
28 case base::PLATFORM_FILE_ERROR_INVALID_OPERATION:
29 case base::PLATFORM_FILE_ERROR_EXISTS:
30 case base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY:
31 return WebKit::WebFileErrorInvalidModification;
32 case base::PLATFORM_FILE_ERROR_ACCESS_DENIED:
33 return WebKit::WebFileErrorNoModificationAllowed;
34 case base::PLATFORM_FILE_ERROR_FAILED:
35 return WebKit::WebFileErrorInvalidState;
36 case base::PLATFORM_FILE_ERROR_ABORT:
37 return WebKit::WebFileErrorAbort;
38 default:
39 return WebKit::WebFileErrorInvalidModification;
40 }
41 }
42
43 }
44
21 WebFileSystemCallbackDispatcher::WebFileSystemCallbackDispatcher( 45 WebFileSystemCallbackDispatcher::WebFileSystemCallbackDispatcher(
22 WebFileSystemCallbacks* callbacks) 46 WebFileSystemCallbacks* callbacks)
23 : callbacks_(callbacks) { 47 : callbacks_(callbacks) {
24 DCHECK(callbacks_); 48 DCHECK(callbacks_);
25 } 49 }
26 50
27 void WebFileSystemCallbackDispatcher::DidSucceed() { 51 void WebFileSystemCallbackDispatcher::DidSucceed() {
28 callbacks_->didSucceed(); 52 callbacks_->didSucceed();
29 } 53 }
30 54
31 void WebFileSystemCallbackDispatcher::DidReadMetadata( 55 void WebFileSystemCallbackDispatcher::DidReadMetadata(
32 const base::PlatformFileInfo& file_info) { 56 const base::PlatformFileInfo& file_info) {
33 WebFileInfo web_file_info; 57 WebFileInfo web_file_info;
34 web_file_info.modificationTime = file_info.last_modified.ToDoubleT(); 58 web_file_info.modificationTime = file_info.last_modified.ToDoubleT();
35 web_file_info.length = file_info.size;
36 if (file_info.is_directory)
37 web_file_info.type = WebFileInfo::TypeDirectory;
38 else
39 web_file_info.type = WebFileInfo::TypeFile;
40 callbacks_->didReadMetadata(web_file_info); 59 callbacks_->didReadMetadata(web_file_info);
41 } 60 }
42 61
43 void WebFileSystemCallbackDispatcher::DidReadDirectory( 62 void WebFileSystemCallbackDispatcher::DidReadDirectory(
44 const std::vector<base::file_util_proxy::Entry>& entries, bool has_more) { 63 const std::vector<base::file_util_proxy::Entry>& entries, bool has_more) {
45 WebVector<WebFileSystemEntry> file_system_entries(entries.size()); 64 WebVector<WebFileSystemEntry> file_system_entries(entries.size());
46 for (size_t i = 0; i < entries.size(); i++) { 65 for (size_t i = 0; i < entries.size(); i++) {
47 file_system_entries[i].name = 66 file_system_entries[i].name =
48 webkit_glue::FilePathStringToWebString(entries[i].name); 67 webkit_glue::FilePathStringToWebString(entries[i].name);
49 file_system_entries[i].isDirectory = entries[i].is_directory; 68 file_system_entries[i].isDirectory = entries[i].is_directory;
50 } 69 }
51 callbacks_->didReadDirectory(file_system_entries, has_more); 70 callbacks_->didReadDirectory(file_system_entries, has_more);
52 } 71 }
53 72
54 void WebFileSystemCallbackDispatcher::DidOpenFileSystem( 73 void WebFileSystemCallbackDispatcher::DidOpenFileSystem(
55 const std::string& name, const FilePath& root_path) { 74 const std::string& name, const FilePath& root_path) {
56 callbacks_->didOpenFileSystem(UTF8ToUTF16(name), 75 callbacks_->didOpenFileSystem(UTF8ToUTF16(name),
57 webkit_glue::FilePathToWebString(root_path)); 76 webkit_glue::FilePathToWebString(root_path));
58 } 77 }
59 78
60 void WebFileSystemCallbackDispatcher::DidFail( 79 void WebFileSystemCallbackDispatcher::DidFail(
61 base::PlatformFileError error_code) { 80 base::PlatformFileError error_code) {
62 callbacks_->didFail( 81 callbacks_->didFail(PlatformFileErrorToWebFileError(error_code));
63 webkit_glue::PlatformFileErrorToWebFileError(error_code));
64 } 82 }
65
66 void WebFileSystemCallbackDispatcher::DidWrite(int64 bytes, bool complete) {
67 NOTREACHED();
68 }
69
OLDNEW
« no previous file with comments | « chrome/common/file_system/webfilesystem_callback_dispatcher.h ('k') | webkit/fileapi/file_system_callback_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698