blob: 6903f4c1512a97f1db847f29006087b043804131 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/common/file_system/webfilesystem_callback_dispatcher.h"
#include <string>
#include <vector>
#include "base/file_util_proxy.h"
#include "base/logging.h"
#include "base/utf_string_conversions.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFileInfo.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystem.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallbacks.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
#include "webkit/glue/webkit_glue.h"
using WebKit::WebFileInfo;
using WebKit::WebFileSystemCallbacks;
using WebKit::WebFileSystemEntry;
using WebKit::WebString;
using WebKit::WebVector;
WebFileSystemCallbackDispatcher::WebFileSystemCallbackDispatcher(
WebFileSystemCallbacks* callbacks)
: callbacks_(callbacks) {
DCHECK(callbacks_);
}
void WebFileSystemCallbackDispatcher::DidSucceed() {
callbacks_->didSucceed();
}
void WebFileSystemCallbackDispatcher::DidReadMetadata(
const base::PlatformFileInfo& file_info, const FilePath& platform_path) {
WebFileInfo web_file_info;
web_file_info.modificationTime = file_info.last_modified.ToDoubleT();
web_file_info.length = file_info.size;
if (file_info.is_directory)
web_file_info.type = WebFileInfo::TypeDirectory;
else
web_file_info.type = WebFileInfo::TypeFile;
web_file_info.platformPath =
webkit_glue::FilePathToWebString(platform_path);
callbacks_->didReadMetadata(web_file_info);
}
void WebFileSystemCallbackDispatcher::DidReadDirectory(
const std::vector<base::FileUtilProxy::Entry>& entries, bool has_more) {
WebVector<WebFileSystemEntry> file_system_entries(entries.size());
for (size_t i = 0; i < entries.size(); i++) {
file_system_entries[i].name =
webkit_glue::FilePathStringToWebString(entries[i].name);
file_system_entries[i].isDirectory = entries[i].is_directory;
}
callbacks_->didReadDirectory(file_system_entries, has_more);
}
void WebFileSystemCallbackDispatcher::DidOpenFileSystem(
const std::string& name, const FilePath& root_path) {
callbacks_->didOpenFileSystem(UTF8ToUTF16(name),
webkit_glue::FilePathToWebString(root_path));
}
void WebFileSystemCallbackDispatcher::DidFail(
base::PlatformFileError error_code) {
callbacks_->didFail(
webkit_glue::PlatformFileErrorToWebFileError(error_code));
}
void WebFileSystemCallbackDispatcher::DidWrite(int64 bytes, bool complete) {
NOTREACHED();
}
|