OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_system/webfilesystem_impl.h" | 5 #include "content/common/file_system/webfilesystem_impl.h" |
6 | 6 |
7 #include "content/common/child_thread.h" | 7 #include "content/common/child_thread.h" |
8 #include "content/common/file_system/file_system_dispatcher.h" | 8 #include "content/common/file_system/file_system_dispatcher.h" |
9 #include "content/common/file_system/webfilesystem_callback_dispatcher.h" | 9 #include "content/common/file_system/webfilesystem_callback_dispatcher.h" |
10 #include "content/common/file_system/webfilewriter_impl.h" | 10 #include "content/common/file_system/webfilewriter_impl.h" |
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileInfo.h" | 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileInfo.h" |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback s.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback s.h" |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" | |
14 #include "webkit/glue/webkit_glue.h" | 15 #include "webkit/glue/webkit_glue.h" |
15 | 16 |
16 using WebKit::WebFileInfo; | 17 using WebKit::WebFileInfo; |
17 using WebKit::WebFileSystemCallbacks; | 18 using WebKit::WebFileSystemCallbacks; |
18 using WebKit::WebFileSystemEntry; | 19 using WebKit::WebFileSystemEntry; |
19 using WebKit::WebString; | 20 using WebKit::WebString; |
21 using WebKit::WebURL; | |
20 using WebKit::WebVector; | 22 using WebKit::WebVector; |
21 | 23 |
22 WebFileSystemImpl::WebFileSystemImpl() { | 24 WebFileSystemImpl::WebFileSystemImpl() { |
23 } | 25 } |
24 | 26 |
25 void WebFileSystemImpl::move(const WebString& src_path, | 27 void WebFileSystemImpl::move(const WebURL& src_path, |
26 const WebString& dest_path, | 28 const WebURL& dest_path, |
27 WebFileSystemCallbacks* callbacks) { | 29 WebFileSystemCallbacks* callbacks) { |
28 FileSystemDispatcher* dispatcher = | 30 FileSystemDispatcher* dispatcher = |
29 ChildThread::current()->file_system_dispatcher(); | 31 ChildThread::current()->file_system_dispatcher(); |
30 dispatcher->Move(GURL(src_path), | 32 dispatcher->Move(GURL(src_path), |
31 GURL(dest_path), | 33 GURL(dest_path), |
32 new WebFileSystemCallbackDispatcher(callbacks)); | 34 new WebFileSystemCallbackDispatcher(callbacks)); |
33 } | 35 } |
34 | 36 |
35 void WebFileSystemImpl::copy(const WebString& src_path, | 37 void WebFileSystemImpl::copy(const WebURL& src_path, |
36 const WebString& dest_path, | 38 const WebURL& dest_path, |
37 WebFileSystemCallbacks* callbacks) { | 39 WebFileSystemCallbacks* callbacks) { |
38 FileSystemDispatcher* dispatcher = | 40 FileSystemDispatcher* dispatcher = |
39 ChildThread::current()->file_system_dispatcher(); | 41 ChildThread::current()->file_system_dispatcher(); |
40 dispatcher->Copy(GURL(src_path), | 42 dispatcher->Copy(GURL(src_path), |
41 GURL(dest_path), | 43 GURL(dest_path), |
42 new WebFileSystemCallbackDispatcher(callbacks)); | 44 new WebFileSystemCallbackDispatcher(callbacks)); |
43 } | 45 } |
44 | 46 |
45 void WebFileSystemImpl::remove(const WebString& path, | 47 void WebFileSystemImpl::remove(const WebURL& path, |
46 WebFileSystemCallbacks* callbacks) { | 48 WebFileSystemCallbacks* callbacks) { |
47 FileSystemDispatcher* dispatcher = | 49 FileSystemDispatcher* dispatcher = |
48 ChildThread::current()->file_system_dispatcher(); | 50 ChildThread::current()->file_system_dispatcher(); |
49 dispatcher->Remove(GURL(path), | 51 dispatcher->Remove(GURL(path), |
50 false /* recursive */, | 52 false /* recursive */, |
51 new WebFileSystemCallbackDispatcher(callbacks)); | 53 new WebFileSystemCallbackDispatcher(callbacks)); |
52 } | 54 } |
53 | 55 |
54 void WebFileSystemImpl::removeRecursively(const WebString& path, | 56 void WebFileSystemImpl::removeRecursively(const WebURL& path, |
55 WebFileSystemCallbacks* callbacks) { | 57 WebFileSystemCallbacks* callbacks) { |
56 FileSystemDispatcher* dispatcher = | 58 FileSystemDispatcher* dispatcher = |
57 ChildThread::current()->file_system_dispatcher(); | 59 ChildThread::current()->file_system_dispatcher(); |
58 dispatcher->Remove(GURL(path), | 60 dispatcher->Remove(GURL(path), |
59 true /* recursive */, | 61 true /* recursive */, |
60 new WebFileSystemCallbackDispatcher(callbacks)); | 62 new WebFileSystemCallbackDispatcher(callbacks)); |
61 } | 63 } |
62 | 64 |
63 void WebFileSystemImpl::readMetadata(const WebString& path, | 65 void WebFileSystemImpl::readMetadata(const WebURL& path, |
64 WebFileSystemCallbacks* callbacks) { | 66 WebFileSystemCallbacks* callbacks) { |
65 FileSystemDispatcher* dispatcher = | 67 FileSystemDispatcher* dispatcher = |
66 ChildThread::current()->file_system_dispatcher(); | 68 ChildThread::current()->file_system_dispatcher(); |
67 dispatcher->ReadMetadata(GURL(path), | 69 dispatcher->ReadMetadata(GURL(path), |
68 new WebFileSystemCallbackDispatcher(callbacks)); | 70 new WebFileSystemCallbackDispatcher(callbacks)); |
69 } | 71 } |
70 | 72 |
71 void WebFileSystemImpl::createFile(const WebString& path, | 73 void WebFileSystemImpl::createFile(const WebURL& path, |
72 bool exclusive, | 74 bool exclusive, |
73 WebFileSystemCallbacks* callbacks) { | 75 WebFileSystemCallbacks* callbacks) { |
74 FileSystemDispatcher* dispatcher = | 76 FileSystemDispatcher* dispatcher = |
75 ChildThread::current()->file_system_dispatcher(); | 77 ChildThread::current()->file_system_dispatcher(); |
76 dispatcher->Create(GURL(path), exclusive, false, | 78 dispatcher->Create(GURL(path), exclusive, false, |
77 false, new WebFileSystemCallbackDispatcher(callbacks)); | 79 false, new WebFileSystemCallbackDispatcher(callbacks)); |
78 } | 80 } |
79 | 81 |
80 void WebFileSystemImpl::createDirectory(const WebString& path, | 82 void WebFileSystemImpl::createDirectory(const WebURL& path, |
81 bool exclusive, | 83 bool exclusive, |
82 WebFileSystemCallbacks* callbacks) { | 84 WebFileSystemCallbacks* callbacks) { |
83 FileSystemDispatcher* dispatcher = | 85 FileSystemDispatcher* dispatcher = |
84 ChildThread::current()->file_system_dispatcher(); | 86 ChildThread::current()->file_system_dispatcher(); |
85 dispatcher->Create(GURL(path), exclusive, true, | 87 dispatcher->Create(GURL(path), exclusive, true, |
86 false, new WebFileSystemCallbackDispatcher(callbacks)); | 88 false, new WebFileSystemCallbackDispatcher(callbacks)); |
87 } | 89 } |
88 | 90 |
89 void WebFileSystemImpl::fileExists(const WebString& path, | 91 void WebFileSystemImpl::fileExists(const WebURL& path, |
90 WebFileSystemCallbacks* callbacks) { | 92 WebFileSystemCallbacks* callbacks) { |
91 FileSystemDispatcher* dispatcher = | 93 FileSystemDispatcher* dispatcher = |
92 ChildThread::current()->file_system_dispatcher(); | 94 ChildThread::current()->file_system_dispatcher(); |
93 dispatcher->Exists(GURL(path), false, | 95 dispatcher->Exists(GURL(path), false, |
94 new WebFileSystemCallbackDispatcher(callbacks)); | 96 new WebFileSystemCallbackDispatcher(callbacks)); |
95 } | 97 } |
96 | 98 |
97 void WebFileSystemImpl::directoryExists(const WebString& path, | 99 void WebFileSystemImpl::directoryExists(const WebURL& path, |
98 WebFileSystemCallbacks* callbacks) { | 100 WebFileSystemCallbacks* callbacks) { |
99 FileSystemDispatcher* dispatcher = | 101 FileSystemDispatcher* dispatcher = |
100 ChildThread::current()->file_system_dispatcher(); | 102 ChildThread::current()->file_system_dispatcher(); |
101 dispatcher->Exists(GURL(path), true, | 103 dispatcher->Exists(GURL(path), true, |
102 new WebFileSystemCallbackDispatcher(callbacks)); | 104 new WebFileSystemCallbackDispatcher(callbacks)); |
103 } | 105 } |
104 | 106 |
105 void WebFileSystemImpl::readDirectory(const WebString& path, | 107 void WebFileSystemImpl::readDirectory(const WebURL& path, |
106 WebFileSystemCallbacks* callbacks) { | 108 WebFileSystemCallbacks* callbacks) { |
107 FileSystemDispatcher* dispatcher = | 109 FileSystemDispatcher* dispatcher = |
108 ChildThread::current()->file_system_dispatcher(); | 110 ChildThread::current()->file_system_dispatcher(); |
109 dispatcher->ReadDirectory(GURL(path), | 111 dispatcher->ReadDirectory(GURL(path), |
110 new WebFileSystemCallbackDispatcher(callbacks)); | 112 new WebFileSystemCallbackDispatcher(callbacks)); |
111 } | 113 } |
112 | 114 |
113 WebKit::WebFileWriter* WebFileSystemImpl::createFileWriter( | 115 WebKit::WebFileWriter* WebFileSystemImpl::createFileWriter( |
116 const WebURL& path, WebKit::WebFileWriterClient* client) { | |
117 return new WebFileWriterImpl(GURL(path), client); | |
118 } | |
119 | |
120 // These are temporary shims to link up the old calls to the new implementation. | |
121 // They'll go away as soon as the webkit side gets updated. | |
122 void WebFileSystemImpl::move(const WebString& src_path, | |
123 const WebString& dest_path, | |
124 WebFileSystemCallbacks* callbacks) { | |
125 move(WebURL(GURL(src_path)), WebURL(GURL(dest_path)), callbacks); | |
darin (slow to review)
2011/05/20 22:40:31
you shouldn't need to explicitly call the WebURL c
ericu
2011/06/02 00:25:46
Removed unnecessary WebURL constructors throughout
| |
126 } | |
127 | |
128 void WebFileSystemImpl::copy(const WebString& src_path, | |
129 const WebString& dest_path, | |
130 WebFileSystemCallbacks* callbacks) { | |
131 copy(WebURL(GURL(src_path)), WebURL(GURL(dest_path)), callbacks); | |
132 } | |
133 | |
134 void WebFileSystemImpl::remove(const WebString& path, | |
135 WebFileSystemCallbacks* callbacks) { | |
136 remove(WebURL(GURL(path)), callbacks); | |
137 } | |
138 | |
139 void WebFileSystemImpl::removeRecursively(const WebString& path, | |
140 WebFileSystemCallbacks* callbacks) { | |
141 removeRecursively(WebURL(GURL(path)), callbacks); | |
142 } | |
143 | |
144 void WebFileSystemImpl::readMetadata(const WebString& path, | |
145 WebFileSystemCallbacks* callbacks) { | |
146 readMetadata(WebURL(GURL(path)), callbacks); | |
147 } | |
148 | |
149 void WebFileSystemImpl::createFile(const WebString& path, | |
150 bool exclusive, | |
151 WebFileSystemCallbacks* callbacks) { | |
152 createFile(WebURL(GURL(path)), exclusive, callbacks); | |
153 } | |
154 | |
155 void WebFileSystemImpl::createDirectory(const WebString& path, | |
156 bool exclusive, | |
157 WebFileSystemCallbacks* callbacks) { | |
158 createDirectory(WebURL(GURL(path)), exclusive, callbacks); | |
159 } | |
160 | |
161 void WebFileSystemImpl::fileExists(const WebString& path, | |
162 WebFileSystemCallbacks* callbacks) { | |
163 fileExists(WebURL(GURL(path)), callbacks); | |
164 } | |
165 | |
166 void WebFileSystemImpl::directoryExists(const WebString& path, | |
167 WebFileSystemCallbacks* callbacks) { | |
168 directoryExists(WebURL(GURL(path)), callbacks); | |
169 } | |
170 | |
171 void WebFileSystemImpl::readDirectory(const WebString& path, | |
172 WebFileSystemCallbacks* callbacks) { | |
173 readDirectory(WebURL(GURL(path)), callbacks); | |
174 } | |
175 | |
176 WebKit::WebFileWriter* WebFileSystemImpl::createFileWriter( | |
114 const WebString& path, WebKit::WebFileWriterClient* client) { | 177 const WebString& path, WebKit::WebFileWriterClient* client) { |
115 return new WebFileWriterImpl(GURL(path), client); | 178 return createFileWriter(WebURL(GURL(path)), client); |
116 } | 179 } |
OLD | NEW |