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

Side by Side Diff: content/common/fileapi/webfilesystem_callback_dispatcher.cc

Issue 14796018: Cleanup: Deprecate FileSystemCallbackDispatcher (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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) 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_callback_dispatcher.h" 5 #include "content/common/fileapi/webfilesystem_callback_dispatcher.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/files/file_util_proxy.h" 10 #include "base/files/file_util_proxy.h"
(...skipping 15 matching lines...) Expand all
26 using WebKit::WebVector; 26 using WebKit::WebVector;
27 27
28 namespace content { 28 namespace content {
29 29
30 WebFileSystemCallbackDispatcher::WebFileSystemCallbackDispatcher( 30 WebFileSystemCallbackDispatcher::WebFileSystemCallbackDispatcher(
31 WebFileSystemCallbacks* callbacks) 31 WebFileSystemCallbacks* callbacks)
32 : callbacks_(callbacks) { 32 : callbacks_(callbacks) {
33 DCHECK(callbacks_); 33 DCHECK(callbacks_);
34 } 34 }
35 35
36 void WebFileSystemCallbackDispatcher::DidSucceed() { 36 void WebFileSystemCallbackDispatcher::DidFinish(base::PlatformFileError error) {
37 callbacks_->didSucceed(); 37 if (error == base::PLATFORM_FILE_OK)
38 callbacks_->didSucceed();
39 else
40 callbacks_->didFail(fileapi::PlatformFileErrorToWebFileError(error));
38 } 41 }
39 42
40 void WebFileSystemCallbackDispatcher::DidReadMetadata( 43 void WebFileSystemCallbackDispatcher::DidReadMetadata(
44 base::PlatformFileError error,
41 const base::PlatformFileInfo& file_info, 45 const base::PlatformFileInfo& file_info,
42 const base::FilePath& platform_path) { 46 const base::FilePath& platform_path) {
47 if (error != base::PLATFORM_FILE_OK) {
48 callbacks_->didFail(fileapi::PlatformFileErrorToWebFileError(error));
49 return;
50 }
43 WebFileInfo web_file_info; 51 WebFileInfo web_file_info;
44 webkit_glue::PlatformFileInfoToWebFileInfo(file_info, &web_file_info); 52 webkit_glue::PlatformFileInfoToWebFileInfo(file_info, &web_file_info);
45 web_file_info.platformPath = webkit_base::FilePathToWebString(platform_path); 53 web_file_info.platformPath = webkit_base::FilePathToWebString(platform_path);
46 callbacks_->didReadMetadata(web_file_info); 54 callbacks_->didReadMetadata(web_file_info);
47 } 55 }
48 56
49 void WebFileSystemCallbackDispatcher::DidCreateSnapshotFile( 57 void WebFileSystemCallbackDispatcher::DidCreateSnapshotFile(
58 base::PlatformFileError error,
50 const base::PlatformFileInfo& file_info, 59 const base::PlatformFileInfo& file_info,
51 const base::FilePath& platform_path) { 60 const base::FilePath& platform_path) {
61 if (error != base::PLATFORM_FILE_OK) {
62 callbacks_->didFail(fileapi::PlatformFileErrorToWebFileError(error));
63 return;
64 }
52 WebFileInfo web_file_info; 65 WebFileInfo web_file_info;
53 webkit_glue::PlatformFileInfoToWebFileInfo(file_info, &web_file_info); 66 webkit_glue::PlatformFileInfoToWebFileInfo(file_info, &web_file_info);
54 web_file_info.platformPath = webkit_base::FilePathToWebString(platform_path); 67 web_file_info.platformPath = webkit_base::FilePathToWebString(platform_path);
55 callbacks_->didCreateSnapshotFile(web_file_info); 68 callbacks_->didCreateSnapshotFile(web_file_info);
56 } 69 }
57 70
58 void WebFileSystemCallbackDispatcher::DidReadDirectory( 71 void WebFileSystemCallbackDispatcher::DidReadDirectory(
59 const std::vector<base::FileUtilProxy::Entry>& entries, bool has_more) { 72 base::PlatformFileError error,
73 const std::vector<base::FileUtilProxy::Entry>& entries,
74 bool has_more) {
75 if (error != base::PLATFORM_FILE_OK) {
76 callbacks_->didFail(fileapi::PlatformFileErrorToWebFileError(error));
77 return;
78 }
60 WebVector<WebFileSystemEntry> file_system_entries(entries.size()); 79 WebVector<WebFileSystemEntry> file_system_entries(entries.size());
61 for (size_t i = 0; i < entries.size(); i++) { 80 for (size_t i = 0; i < entries.size(); i++) {
62 file_system_entries[i].name = 81 file_system_entries[i].name =
63 webkit_base::FilePathStringToWebString(entries[i].name); 82 webkit_base::FilePathStringToWebString(entries[i].name);
64 file_system_entries[i].isDirectory = entries[i].is_directory; 83 file_system_entries[i].isDirectory = entries[i].is_directory;
65 } 84 }
66 callbacks_->didReadDirectory(file_system_entries, has_more); 85 callbacks_->didReadDirectory(file_system_entries, has_more);
67 } 86 }
68 87
69 void WebFileSystemCallbackDispatcher::DidOpenFileSystem( 88 void WebFileSystemCallbackDispatcher::DidOpenFileSystem(
89 base::PlatformFileError error,
70 const std::string& name, const GURL& root) { 90 const std::string& name, const GURL& root) {
91 if (error != base::PLATFORM_FILE_OK) {
92 callbacks_->didFail(fileapi::PlatformFileErrorToWebFileError(error));
93 return;
94 }
71 callbacks_->didOpenFileSystem(UTF8ToUTF16(name), root); 95 callbacks_->didOpenFileSystem(UTF8ToUTF16(name), root);
72 } 96 }
73 97
74 void WebFileSystemCallbackDispatcher::DidFail(
75 base::PlatformFileError error_code) {
76 callbacks_->didFail(
77 fileapi::PlatformFileErrorToWebFileError(error_code));
78 }
79
80 void WebFileSystemCallbackDispatcher::DidWrite(int64 bytes, bool complete) {
81 NOTREACHED();
82 }
83
84 } // namespace content 98 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698