OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "content/common_child/fileapi/webfilesystem_impl.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "content/common/child_thread.h" | |
9 #include "content/common/fileapi/file_system_dispatcher.h" | |
10 #include "content/common_child/fileapi/webfilesystem_callback_adapters.h" | |
11 #include "content/common_child/fileapi/webfilewriter_impl.h" | |
12 #include "third_party/WebKit/public/platform/WebFileInfo.h" | |
13 #include "third_party/WebKit/public/platform/WebString.h" | |
14 #include "third_party/WebKit/public/platform/WebURL.h" | |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback
s.h" | |
16 #include "webkit/glue/webkit_glue.h" | |
17 | |
18 using WebKit::WebFileInfo; | |
19 using WebKit::WebFileSystemCallbacks; | |
20 using WebKit::WebFileSystemEntry; | |
21 using WebKit::WebString; | |
22 using WebKit::WebURL; | |
23 using WebKit::WebVector; | |
24 | |
25 namespace content { | |
26 | |
27 WebFileSystemImpl::WebFileSystemImpl() { | |
28 } | |
29 | |
30 void WebFileSystemImpl::move(const WebURL& src_path, | |
31 const WebURL& dest_path, | |
32 WebFileSystemCallbacks* callbacks) { | |
33 FileSystemDispatcher* dispatcher = | |
34 ChildThread::current()->file_system_dispatcher(); | |
35 dispatcher->Move(GURL(src_path), | |
36 GURL(dest_path), | |
37 base::Bind(&FileStatusCallbackAdapter, callbacks)); | |
38 } | |
39 | |
40 void WebFileSystemImpl::copy(const WebURL& src_path, | |
41 const WebURL& dest_path, | |
42 WebFileSystemCallbacks* callbacks) { | |
43 FileSystemDispatcher* dispatcher = | |
44 ChildThread::current()->file_system_dispatcher(); | |
45 dispatcher->Copy(GURL(src_path), | |
46 GURL(dest_path), | |
47 base::Bind(&FileStatusCallbackAdapter, callbacks)); | |
48 } | |
49 | |
50 void WebFileSystemImpl::remove(const WebURL& path, | |
51 WebFileSystemCallbacks* callbacks) { | |
52 FileSystemDispatcher* dispatcher = | |
53 ChildThread::current()->file_system_dispatcher(); | |
54 dispatcher->Remove( | |
55 GURL(path), | |
56 false /* recursive */, | |
57 base::Bind(&FileStatusCallbackAdapter, callbacks)); | |
58 } | |
59 | |
60 void WebFileSystemImpl::removeRecursively(const WebURL& path, | |
61 WebFileSystemCallbacks* callbacks) { | |
62 FileSystemDispatcher* dispatcher = | |
63 ChildThread::current()->file_system_dispatcher(); | |
64 dispatcher->Remove( | |
65 GURL(path), | |
66 true /* recursive */, | |
67 base::Bind(&FileStatusCallbackAdapter, callbacks)); | |
68 } | |
69 | |
70 void WebFileSystemImpl::readMetadata(const WebURL& path, | |
71 WebFileSystemCallbacks* callbacks) { | |
72 FileSystemDispatcher* dispatcher = | |
73 ChildThread::current()->file_system_dispatcher(); | |
74 dispatcher->ReadMetadata( | |
75 GURL(path), | |
76 base::Bind(&ReadMetadataCallbackAdapter, callbacks), | |
77 base::Bind(&FileStatusCallbackAdapter, callbacks)); | |
78 } | |
79 | |
80 void WebFileSystemImpl::createFile(const WebURL& path, | |
81 bool exclusive, | |
82 WebFileSystemCallbacks* callbacks) { | |
83 FileSystemDispatcher* dispatcher = | |
84 ChildThread::current()->file_system_dispatcher(); | |
85 dispatcher->Create( | |
86 GURL(path), exclusive, false /* directory */, false /* recursive */, | |
87 base::Bind(&FileStatusCallbackAdapter, callbacks)); | |
88 } | |
89 | |
90 void WebFileSystemImpl::createDirectory(const WebURL& path, | |
91 bool exclusive, | |
92 WebFileSystemCallbacks* callbacks) { | |
93 FileSystemDispatcher* dispatcher = | |
94 ChildThread::current()->file_system_dispatcher(); | |
95 dispatcher->Create( | |
96 GURL(path), exclusive, true /* directory */, false /* recursive */, | |
97 base::Bind(&FileStatusCallbackAdapter, callbacks)); | |
98 } | |
99 | |
100 void WebFileSystemImpl::fileExists(const WebURL& path, | |
101 WebFileSystemCallbacks* callbacks) { | |
102 FileSystemDispatcher* dispatcher = | |
103 ChildThread::current()->file_system_dispatcher(); | |
104 dispatcher->Exists( | |
105 GURL(path), false /* directory */, | |
106 base::Bind(&FileStatusCallbackAdapter, callbacks)); | |
107 } | |
108 | |
109 void WebFileSystemImpl::directoryExists(const WebURL& path, | |
110 WebFileSystemCallbacks* callbacks) { | |
111 FileSystemDispatcher* dispatcher = | |
112 ChildThread::current()->file_system_dispatcher(); | |
113 dispatcher->Exists( | |
114 GURL(path), true /* directory */, | |
115 base::Bind(&FileStatusCallbackAdapter, callbacks)); | |
116 } | |
117 | |
118 void WebFileSystemImpl::readDirectory(const WebURL& path, | |
119 WebFileSystemCallbacks* callbacks) { | |
120 FileSystemDispatcher* dispatcher = | |
121 ChildThread::current()->file_system_dispatcher(); | |
122 dispatcher->ReadDirectory( | |
123 GURL(path), | |
124 base::Bind(&ReadDirectoryCallbackAdapater, callbacks), | |
125 base::Bind(&FileStatusCallbackAdapter, callbacks)); | |
126 } | |
127 | |
128 WebKit::WebFileWriter* WebFileSystemImpl::createFileWriter( | |
129 const WebURL& path, WebKit::WebFileWriterClient* client) { | |
130 return new WebFileWriterImpl(GURL(path), client); | |
131 } | |
132 | |
133 void WebFileSystemImpl::createSnapshotFileAndReadMetadata( | |
134 const WebKit::WebURL& path, | |
135 WebKit::WebFileSystemCallbacks* callbacks) { | |
136 FileSystemDispatcher* dispatcher = | |
137 ChildThread::current()->file_system_dispatcher(); | |
138 dispatcher->CreateSnapshotFile( | |
139 GURL(path), | |
140 base::Bind(&CreateSnapshotFileCallbackAdapter, callbacks), | |
141 base::Bind(&FileStatusCallbackAdapter, callbacks)); | |
142 } | |
143 | |
144 } // namespace content | |
OLD | NEW |