[content shell] hook up testRunner.dumpEditingCallbacks
[chromium-blink-merge.git] / content / common / fileapi / webfilesystem_callback_dispatcher.cc
blob8dd129ed447e308c553cb6fec47f0efa9fd44f06
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
3 // found in the LICENSE file.
5 #include "content/common/fileapi/webfilesystem_callback_dispatcher.h"
7 #include <string>
8 #include <vector>
10 #include "base/file_util_proxy.h"
11 #include "base/logging.h"
12 #include "base/utf_string_conversions.h"
13 #include "googleurl/src/gurl.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileInfo.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSystem.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallbacks.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
18 #include "webkit/base/file_path_string_conversions.h"
19 #include "webkit/fileapi/file_system_util.h"
20 #include "webkit/glue/webkit_glue.h"
22 using WebKit::WebFileInfo;
23 using WebKit::WebFileSystemCallbacks;
24 using WebKit::WebFileSystemEntry;
25 using WebKit::WebString;
26 using WebKit::WebVector;
28 namespace content {
30 WebFileSystemCallbackDispatcher::WebFileSystemCallbackDispatcher(
31 WebFileSystemCallbacks* callbacks)
32 : callbacks_(callbacks) {
33 DCHECK(callbacks_);
36 void WebFileSystemCallbackDispatcher::DidSucceed() {
37 callbacks_->didSucceed();
40 void WebFileSystemCallbackDispatcher::DidReadMetadata(
41 const base::PlatformFileInfo& file_info, const FilePath& platform_path) {
42 WebFileInfo web_file_info;
43 webkit_glue::PlatformFileInfoToWebFileInfo(file_info, &web_file_info);
44 web_file_info.platformPath = webkit_base::FilePathToWebString(platform_path);
45 callbacks_->didReadMetadata(web_file_info);
48 void WebFileSystemCallbackDispatcher::DidReadDirectory(
49 const std::vector<base::FileUtilProxy::Entry>& entries, bool has_more) {
50 WebVector<WebFileSystemEntry> file_system_entries(entries.size());
51 for (size_t i = 0; i < entries.size(); i++) {
52 file_system_entries[i].name =
53 webkit_base::FilePathStringToWebString(entries[i].name);
54 file_system_entries[i].isDirectory = entries[i].is_directory;
56 callbacks_->didReadDirectory(file_system_entries, has_more);
59 void WebFileSystemCallbackDispatcher::DidOpenFileSystem(
60 const std::string& name, const GURL& root) {
61 callbacks_->didOpenFileSystem(UTF8ToUTF16(name), root);
64 void WebFileSystemCallbackDispatcher::DidFail(
65 base::PlatformFileError error_code) {
66 callbacks_->didFail(
67 fileapi::PlatformFileErrorToWebFileError(error_code));
70 void WebFileSystemCallbackDispatcher::DidWrite(int64 bytes, bool complete) {
71 NOTREACHED();
74 } // namespace content