OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/child/fileapi/webfilesystem_impl.h" | 5 #include "content/child/fileapi/webfilesystem_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/id_map.h" | |
9 #include "base/lazy_instance.h" | |
10 #include "base/logging.h" | |
11 #include "base/message_loop/message_loop_proxy.h" | |
12 #include "base/threading/thread_local.h" | |
13 #include "content/child/child_thread.h" | 8 #include "content/child/child_thread.h" |
14 #include "content/child/fileapi/file_system_dispatcher.h" | 9 #include "content/child/fileapi/file_system_dispatcher.h" |
15 #include "content/child/fileapi/webfilesystem_callback_adapters.h" | 10 #include "content/child/fileapi/webfilesystem_callback_adapters.h" |
16 #include "content/child/fileapi/webfilewriter_impl.h" | 11 #include "content/child/fileapi/webfilewriter_impl.h" |
17 #include "content/common/fileapi/file_system_messages.h" | 12 #include "third_party/WebKit/public/web/WebFileSystemCallbacks.h" |
18 #include "third_party/WebKit/public/platform/WebFileInfo.h" | 13 #include "third_party/WebKit/public/platform/WebFileInfo.h" |
19 #include "third_party/WebKit/public/platform/WebString.h" | 14 #include "third_party/WebKit/public/platform/WebString.h" |
20 #include "third_party/WebKit/public/platform/WebURL.h" | 15 #include "third_party/WebKit/public/platform/WebURL.h" |
21 #include "third_party/WebKit/public/web/WebFileSystemCallbacks.h" | |
22 #include "url/gurl.h" | |
23 #include "webkit/child/worker_task_runner.h" | |
24 #include "webkit/common/fileapi/directory_entry.h" | |
25 #include "webkit/common/fileapi/file_system_util.h" | |
26 #include "webkit/glue/webkit_glue.h" | 16 #include "webkit/glue/webkit_glue.h" |
27 | 17 |
28 using WebKit::WebFileInfo; | 18 using WebKit::WebFileInfo; |
29 using WebKit::WebFileSystemCallbacks; | 19 using WebKit::WebFileSystemCallbacks; |
30 using WebKit::WebFileSystemEntry; | 20 using WebKit::WebFileSystemEntry; |
31 using WebKit::WebString; | 21 using WebKit::WebString; |
32 using WebKit::WebURL; | 22 using WebKit::WebURL; |
33 using WebKit::WebVector; | 23 using WebKit::WebVector; |
34 using webkit_glue::WorkerTaskRunner; | |
35 | 24 |
36 namespace content { | 25 namespace content { |
37 | 26 |
38 namespace { | 27 namespace { |
39 | 28 |
40 class CallbacksMap; | |
41 | |
42 base::LazyInstance<base::ThreadLocalPointer<CallbacksMap> >::Leaky | |
43 g_callbacks_map_tls = LAZY_INSTANCE_INITIALIZER; | |
44 | |
45 // TODO(kinuko): Integrate this into WebFileSystemImpl when blink side | |
46 // becomes ready to make WebFileSystemImpl thread-local. | |
47 class CallbacksMap : public WorkerTaskRunner::Observer { | |
48 public: | |
49 static CallbacksMap* Get() { | |
50 return g_callbacks_map_tls.Pointer()->Get(); | |
51 } | |
52 | |
53 static CallbacksMap* GetOrCreate() { | |
54 if (g_callbacks_map_tls.Pointer()->Get()) | |
55 return g_callbacks_map_tls.Pointer()->Get(); | |
56 CallbacksMap* map = new CallbacksMap; | |
57 if (WorkerTaskRunner::Instance()->CurrentWorkerId()) | |
58 WorkerTaskRunner::Instance()->AddStopObserver(map); | |
59 return map; | |
60 } | |
61 | |
62 virtual ~CallbacksMap() { | |
63 IDMap<WebFileSystemCallbacks>::iterator iter(&callbacks_); | |
64 while (!iter.IsAtEnd()) { | |
65 iter.GetCurrentValue()->didFail(WebKit::WebFileErrorAbort); | |
66 iter.Advance(); | |
67 } | |
68 g_callbacks_map_tls.Pointer()->Set(NULL); | |
69 } | |
70 | |
71 // webkit_glue::WorkerTaskRunner::Observer implementation. | |
72 virtual void OnWorkerRunLoopStopped() OVERRIDE { | |
73 delete this; | |
74 } | |
75 | |
76 int RegisterCallbacks(WebFileSystemCallbacks* callbacks) { | |
77 return callbacks_.Add(callbacks); | |
78 } | |
79 | |
80 WebFileSystemCallbacks* GetAndUnregisterCallbacks( | |
81 int callbacks_id) { | |
82 WebFileSystemCallbacks* callbacks = callbacks_.Lookup(callbacks_id); | |
83 callbacks_.Remove(callbacks_id); | |
84 return callbacks; | |
85 } | |
86 | |
87 private: | |
88 CallbacksMap() { | |
89 g_callbacks_map_tls.Pointer()->Set(this); | |
90 } | |
91 | |
92 IDMap<WebFileSystemCallbacks> callbacks_; | |
93 | |
94 DISALLOW_COPY_AND_ASSIGN(CallbacksMap); | |
95 }; | |
96 | |
97 void DidReadMetadataForCreateFileWriter( | 29 void DidReadMetadataForCreateFileWriter( |
98 const GURL& path, | 30 const GURL& path, |
99 WebKit::WebFileWriterClient* client, | 31 WebKit::WebFileWriterClient* client, |
100 WebKit::WebFileSystemCallbacks* callbacks, | 32 WebKit::WebFileSystemCallbacks* callbacks, |
101 const base::PlatformFileInfo& file_info) { | 33 const base::PlatformFileInfo& file_info) { |
102 if (file_info.is_directory || file_info.size < 0) { | 34 if (file_info.is_directory || file_info.size < 0) { |
103 callbacks->didFail(WebKit::WebFileErrorInvalidState); | 35 callbacks->didFail(WebKit::WebFileErrorInvalidState); |
104 return; | 36 return; |
105 } | 37 } |
106 callbacks->didCreateFileWriter(new WebFileWriterImpl(path, client), | 38 callbacks->didCreateFileWriter(new WebFileWriterImpl(path, client), |
107 file_info.size); | 39 file_info.size); |
108 } | 40 } |
109 | 41 |
110 void DidReceiveSnapshotFile(int request_id) { | |
111 if (ChildThread::current()) | |
112 ChildThread::current()->Send( | |
113 new FileSystemHostMsg_DidReceiveSnapshotFile(request_id)); | |
114 } | |
115 | |
116 int CurrentWorkerId() { | |
117 return WorkerTaskRunner::Instance()->CurrentWorkerId(); | |
118 } | |
119 | |
120 template <typename Method, typename Params> | |
121 void CallDispatcherOnMainThread( | |
122 base::MessageLoopProxy* loop, | |
123 Method method, const Params& params) { | |
124 if (!loop->RunsTasksOnCurrentThread()) { | |
125 loop->PostTask(FROM_HERE, | |
126 base::Bind(&CallDispatcherOnMainThread<Method, Params>, | |
127 make_scoped_refptr(loop), method, params)); | |
128 return; | |
129 } | |
130 if (!ChildThread::current() || | |
131 !ChildThread::current()->file_system_dispatcher()) | |
132 return; | |
133 | |
134 DispatchToMethod(ChildThread::current()->file_system_dispatcher(), | |
135 method, params); | |
136 } | |
137 | |
138 template <typename Method, typename Params> | |
139 void CallbackFileSystemCallbacks( | |
140 int thread_id, int callbacks_id, | |
141 Method method, const Params& params) { | |
142 if (thread_id != CurrentWorkerId()) { | |
143 WorkerTaskRunner::Instance()->PostTask( | |
144 thread_id, | |
145 base::Bind(&CallbackFileSystemCallbacks<Method, Params>, | |
146 thread_id, callbacks_id, method, params)); | |
147 return; | |
148 } | |
149 if (!CallbacksMap::Get()) | |
150 return; | |
151 | |
152 WebFileSystemCallbacks* callbacks = | |
153 CallbacksMap::Get()->GetAndUnregisterCallbacks(callbacks_id); | |
154 DCHECK(callbacks); | |
155 DispatchToMethod(callbacks, method, params); | |
156 } | |
157 | |
158 void StatusCallbackAdapter(int thread_id, int callbacks_id, | |
159 base::PlatformFileError error) { | |
160 if (error == base::PLATFORM_FILE_OK) { | |
161 CallbackFileSystemCallbacks( | |
162 thread_id, callbacks_id, | |
163 &WebFileSystemCallbacks::didSucceed, MakeTuple()); | |
164 } else { | |
165 CallbackFileSystemCallbacks( | |
166 thread_id, callbacks_id, | |
167 &WebFileSystemCallbacks::didFail, | |
168 MakeTuple(fileapi::PlatformFileErrorToWebFileError(error))); | |
169 } | |
170 } | |
171 | |
172 void ReadMetadataCallbackAdapter(int thread_id, int callbacks_id, | |
173 const base::PlatformFileInfo& file_info) { | |
174 WebFileInfo web_file_info; | |
175 webkit_glue::PlatformFileInfoToWebFileInfo(file_info, &web_file_info); | |
176 CallbackFileSystemCallbacks( | |
177 thread_id, callbacks_id, | |
178 &WebFileSystemCallbacks::didReadMetadata, | |
179 MakeTuple(web_file_info)); | |
180 } | |
181 | |
182 void ReadDirectoryCallbackAdapater( | |
183 int thread_id, int callbacks_id, | |
184 const std::vector<fileapi::DirectoryEntry>& entries, | |
185 bool has_more) { | |
186 WebVector<WebFileSystemEntry> file_system_entries(entries.size()); | |
187 for (size_t i = 0; i < entries.size(); i++) { | |
188 file_system_entries[i].name = | |
189 base::FilePath(entries[i].name).AsUTF16Unsafe(); | |
190 file_system_entries[i].isDirectory = entries[i].is_directory; | |
191 } | |
192 CallbackFileSystemCallbacks( | |
193 thread_id, callbacks_id, | |
194 &WebFileSystemCallbacks::didReadDirectory, | |
195 MakeTuple(file_system_entries, has_more)); | |
196 } | |
197 | |
198 void CreateSnapshotFileCallbackAdapter( | |
199 int thread_id, int callbacks_id, | |
200 base::MessageLoopProxy* main_thread_loop, | |
201 const base::PlatformFileInfo& file_info, | |
202 const base::FilePath& platform_path, | |
203 int request_id) { | |
204 if (thread_id != CurrentWorkerId()) { | |
205 WorkerTaskRunner::Instance()->PostTask( | |
206 thread_id, | |
207 base::Bind(&CreateSnapshotFileCallbackAdapter, | |
208 thread_id, callbacks_id, | |
209 make_scoped_refptr(main_thread_loop), | |
210 file_info, platform_path, request_id)); | |
211 return; | |
212 } | |
213 | |
214 if (!CallbacksMap::Get()) | |
215 return; | |
216 | |
217 WebFileSystemCallbacks* callbacks = | |
218 CallbacksMap::Get()->GetAndUnregisterCallbacks(callbacks_id); | |
219 DCHECK(callbacks); | |
220 | |
221 WebFileInfo web_file_info; | |
222 webkit_glue::PlatformFileInfoToWebFileInfo(file_info, &web_file_info); | |
223 web_file_info.platformPath = platform_path.AsUTF16Unsafe(); | |
224 callbacks->didCreateSnapshotFile(web_file_info); | |
225 | |
226 // TODO(michaeln,kinuko): Use ThreadSafeSender when Blob becomes | |
227 // non-bridge model. | |
228 main_thread_loop->PostTask( | |
229 FROM_HERE, base::Bind(&DidReceiveSnapshotFile, request_id)); | |
230 } | |
231 | |
232 } // namespace | 42 } // namespace |
233 | 43 |
234 WebFileSystemImpl::~WebFileSystemImpl() { | 44 WebFileSystemImpl::WebFileSystemImpl() { |
235 } | 45 } |
236 | 46 |
237 WebFileSystemImpl::WebFileSystemImpl(base::MessageLoopProxy* main_thread_loop) | 47 void WebFileSystemImpl::move(const WebURL& src_path, |
238 : main_thread_loop_(main_thread_loop) { | 48 const WebURL& dest_path, |
| 49 WebFileSystemCallbacks* callbacks) { |
| 50 FileSystemDispatcher* dispatcher = |
| 51 ChildThread::current()->file_system_dispatcher(); |
| 52 dispatcher->Move(GURL(src_path), |
| 53 GURL(dest_path), |
| 54 base::Bind(&FileStatusCallbackAdapter, callbacks)); |
239 } | 55 } |
240 | 56 |
241 void WebFileSystemImpl::move( | 57 void WebFileSystemImpl::copy(const WebURL& src_path, |
242 const WebKit::WebURL& src_path, | 58 const WebURL& dest_path, |
243 const WebKit::WebURL& dest_path, | 59 WebFileSystemCallbacks* callbacks) { |
244 WebKit::WebFileSystemCallbacks* callbacks) { | 60 FileSystemDispatcher* dispatcher = |
245 int callbacks_id = CallbacksMap::GetOrCreate()->RegisterCallbacks(callbacks); | 61 ChildThread::current()->file_system_dispatcher(); |
246 CallDispatcherOnMainThread( | 62 dispatcher->Copy(GURL(src_path), |
247 main_thread_loop_.get(), | 63 GURL(dest_path), |
248 &FileSystemDispatcher::Move, | 64 base::Bind(&FileStatusCallbackAdapter, callbacks)); |
249 MakeTuple(GURL(src_path), GURL(dest_path), | |
250 base::Bind(&StatusCallbackAdapter, | |
251 CurrentWorkerId(), callbacks_id))); | |
252 } | 65 } |
253 | 66 |
254 void WebFileSystemImpl::copy( | 67 void WebFileSystemImpl::remove(const WebURL& path, |
255 const WebKit::WebURL& src_path, | 68 WebFileSystemCallbacks* callbacks) { |
256 const WebKit::WebURL& dest_path, | 69 FileSystemDispatcher* dispatcher = |
257 WebKit::WebFileSystemCallbacks* callbacks) { | 70 ChildThread::current()->file_system_dispatcher(); |
258 int callbacks_id = CallbacksMap::GetOrCreate()->RegisterCallbacks(callbacks); | 71 dispatcher->Remove( |
259 CallDispatcherOnMainThread( | 72 GURL(path), |
260 main_thread_loop_.get(), | 73 false /* recursive */, |
261 &FileSystemDispatcher::Copy, | 74 base::Bind(&FileStatusCallbackAdapter, callbacks)); |
262 MakeTuple(GURL(src_path), GURL(dest_path), | |
263 base::Bind(&StatusCallbackAdapter, | |
264 CurrentWorkerId(), callbacks_id))); | |
265 } | 75 } |
266 | 76 |
267 void WebFileSystemImpl::remove( | 77 void WebFileSystemImpl::removeRecursively(const WebURL& path, |
268 const WebKit::WebURL& path, | 78 WebFileSystemCallbacks* callbacks) { |
269 WebKit::WebFileSystemCallbacks* callbacks) { | 79 FileSystemDispatcher* dispatcher = |
270 int callbacks_id = CallbacksMap::GetOrCreate()->RegisterCallbacks(callbacks); | 80 ChildThread::current()->file_system_dispatcher(); |
271 CallDispatcherOnMainThread( | 81 dispatcher->Remove( |
272 main_thread_loop_.get(), | 82 GURL(path), |
273 &FileSystemDispatcher::Remove, | 83 true /* recursive */, |
274 MakeTuple(GURL(path), false /* recursive */, | 84 base::Bind(&FileStatusCallbackAdapter, callbacks)); |
275 base::Bind(&StatusCallbackAdapter, | |
276 CurrentWorkerId(), callbacks_id))); | |
277 } | 85 } |
278 | 86 |
279 void WebFileSystemImpl::removeRecursively( | 87 void WebFileSystemImpl::readMetadata(const WebURL& path, |
280 const WebKit::WebURL& path, | 88 WebFileSystemCallbacks* callbacks) { |
281 WebKit::WebFileSystemCallbacks* callbacks) { | 89 FileSystemDispatcher* dispatcher = |
282 int callbacks_id = CallbacksMap::GetOrCreate()->RegisterCallbacks(callbacks); | 90 ChildThread::current()->file_system_dispatcher(); |
283 CallDispatcherOnMainThread( | 91 dispatcher->ReadMetadata( |
284 main_thread_loop_.get(), | 92 GURL(path), |
285 &FileSystemDispatcher::Remove, | 93 base::Bind(&ReadMetadataCallbackAdapter, callbacks), |
286 MakeTuple(GURL(path), true /* recursive */, | 94 base::Bind(&FileStatusCallbackAdapter, callbacks)); |
287 base::Bind(&StatusCallbackAdapter, | |
288 CurrentWorkerId(), callbacks_id))); | |
289 } | 95 } |
290 | 96 |
291 void WebFileSystemImpl::readMetadata( | 97 void WebFileSystemImpl::createFile(const WebURL& path, |
292 const WebKit::WebURL& path, | 98 bool exclusive, |
293 WebKit::WebFileSystemCallbacks* callbacks) { | 99 WebFileSystemCallbacks* callbacks) { |
294 int callbacks_id = CallbacksMap::GetOrCreate()->RegisterCallbacks(callbacks); | 100 FileSystemDispatcher* dispatcher = |
295 CallDispatcherOnMainThread( | 101 ChildThread::current()->file_system_dispatcher(); |
296 main_thread_loop_.get(), | 102 dispatcher->CreateFile( |
297 &FileSystemDispatcher::ReadMetadata, | 103 GURL(path), exclusive, |
298 MakeTuple(GURL(path), | 104 base::Bind(&FileStatusCallbackAdapter, callbacks)); |
299 base::Bind(&ReadMetadataCallbackAdapter, | |
300 CurrentWorkerId(), callbacks_id), | |
301 base::Bind(&StatusCallbackAdapter, | |
302 CurrentWorkerId(), callbacks_id))); | |
303 } | 105 } |
304 | 106 |
305 void WebFileSystemImpl::createFile( | 107 void WebFileSystemImpl::createDirectory(const WebURL& path, |
306 const WebKit::WebURL& path, | 108 bool exclusive, |
307 bool exclusive, | 109 WebFileSystemCallbacks* callbacks) { |
308 WebKit::WebFileSystemCallbacks* callbacks) { | 110 FileSystemDispatcher* dispatcher = |
309 int callbacks_id = CallbacksMap::GetOrCreate()->RegisterCallbacks(callbacks); | 111 ChildThread::current()->file_system_dispatcher(); |
310 CallDispatcherOnMainThread( | 112 dispatcher->CreateDirectory( |
311 main_thread_loop_.get(), | 113 GURL(path), exclusive, false /* recursive */, |
312 &FileSystemDispatcher::CreateFile, | 114 base::Bind(&FileStatusCallbackAdapter, callbacks)); |
313 MakeTuple(GURL(path), exclusive, | |
314 base::Bind(&StatusCallbackAdapter, | |
315 CurrentWorkerId(), callbacks_id))); | |
316 } | 115 } |
317 | 116 |
318 void WebFileSystemImpl::createDirectory( | 117 void WebFileSystemImpl::fileExists(const WebURL& path, |
319 const WebKit::WebURL& path, | 118 WebFileSystemCallbacks* callbacks) { |
320 bool exclusive, | 119 FileSystemDispatcher* dispatcher = |
321 WebKit::WebFileSystemCallbacks* callbacks) { | 120 ChildThread::current()->file_system_dispatcher(); |
322 int callbacks_id = CallbacksMap::GetOrCreate()->RegisterCallbacks(callbacks); | 121 dispatcher->Exists( |
323 CallDispatcherOnMainThread( | 122 GURL(path), false /* directory */, |
324 main_thread_loop_.get(), | 123 base::Bind(&FileStatusCallbackAdapter, callbacks)); |
325 &FileSystemDispatcher::CreateDirectory, | |
326 MakeTuple(GURL(path), exclusive, false /* recursive */, | |
327 base::Bind(&StatusCallbackAdapter, | |
328 CurrentWorkerId(), callbacks_id))); | |
329 } | 124 } |
330 | 125 |
331 void WebFileSystemImpl::fileExists( | 126 void WebFileSystemImpl::directoryExists(const WebURL& path, |
332 const WebKit::WebURL& path, | 127 WebFileSystemCallbacks* callbacks) { |
333 WebKit::WebFileSystemCallbacks* callbacks) { | 128 FileSystemDispatcher* dispatcher = |
334 int callbacks_id = CallbacksMap::GetOrCreate()->RegisterCallbacks(callbacks); | 129 ChildThread::current()->file_system_dispatcher(); |
335 CallDispatcherOnMainThread( | 130 dispatcher->Exists( |
336 main_thread_loop_.get(), | 131 GURL(path), true /* directory */, |
337 &FileSystemDispatcher::Exists, | 132 base::Bind(&FileStatusCallbackAdapter, callbacks)); |
338 MakeTuple(GURL(path), false /* directory */, | |
339 base::Bind(&StatusCallbackAdapter, | |
340 CurrentWorkerId(), callbacks_id))); | |
341 } | 133 } |
342 | 134 |
343 void WebFileSystemImpl::directoryExists( | 135 void WebFileSystemImpl::readDirectory(const WebURL& path, |
344 const WebKit::WebURL& path, | 136 WebFileSystemCallbacks* callbacks) { |
345 WebKit::WebFileSystemCallbacks* callbacks) { | 137 FileSystemDispatcher* dispatcher = |
346 int callbacks_id = CallbacksMap::GetOrCreate()->RegisterCallbacks(callbacks); | 138 ChildThread::current()->file_system_dispatcher(); |
347 CallDispatcherOnMainThread( | 139 dispatcher->ReadDirectory( |
348 main_thread_loop_.get(), | 140 GURL(path), |
349 &FileSystemDispatcher::Exists, | 141 base::Bind(&ReadDirectoryCallbackAdapater, callbacks), |
350 MakeTuple(GURL(path), true /* directory */, | 142 base::Bind(&FileStatusCallbackAdapter, callbacks)); |
351 base::Bind(&StatusCallbackAdapter, | |
352 CurrentWorkerId(), callbacks_id))); | |
353 } | |
354 | |
355 void WebFileSystemImpl::readDirectory( | |
356 const WebKit::WebURL& path, | |
357 WebKit::WebFileSystemCallbacks* callbacks) { | |
358 int callbacks_id = CallbacksMap::GetOrCreate()->RegisterCallbacks(callbacks); | |
359 CallDispatcherOnMainThread( | |
360 main_thread_loop_.get(), | |
361 &FileSystemDispatcher::ReadDirectory, | |
362 MakeTuple(GURL(path), | |
363 base::Bind(&ReadDirectoryCallbackAdapater, | |
364 CurrentWorkerId(), callbacks_id), | |
365 base::Bind(&StatusCallbackAdapter, | |
366 CurrentWorkerId(), callbacks_id))); | |
367 } | 143 } |
368 | 144 |
369 WebKit::WebFileWriter* WebFileSystemImpl::createFileWriter( | 145 WebKit::WebFileWriter* WebFileSystemImpl::createFileWriter( |
370 const WebURL& path, WebKit::WebFileWriterClient* client) { | 146 const WebURL& path, WebKit::WebFileWriterClient* client) { |
371 return new WebFileWriterImpl(GURL(path), client); | 147 return new WebFileWriterImpl(GURL(path), client); |
372 } | 148 } |
373 | 149 |
374 void WebFileSystemImpl::createFileWriter( | 150 void WebFileSystemImpl::createFileWriter( |
375 const WebURL& path, | 151 const WebURL& path, |
376 WebKit::WebFileWriterClient* client, | 152 WebKit::WebFileWriterClient* client, |
377 WebKit::WebFileSystemCallbacks* callbacks) { | 153 WebKit::WebFileSystemCallbacks* callbacks) { |
378 // TODO(kinuko): Convert this method to use bridge model. (crbug.com/257349) | |
379 DCHECK(main_thread_loop_->RunsTasksOnCurrentThread()); | |
380 FileSystemDispatcher* dispatcher = | 154 FileSystemDispatcher* dispatcher = |
381 ChildThread::current()->file_system_dispatcher(); | 155 ChildThread::current()->file_system_dispatcher(); |
382 dispatcher->ReadMetadata( | 156 dispatcher->ReadMetadata( |
383 GURL(path), | 157 GURL(path), |
384 base::Bind(&DidReadMetadataForCreateFileWriter, | 158 base::Bind(&DidReadMetadataForCreateFileWriter, |
385 GURL(path), client, callbacks), | 159 GURL(path), client, callbacks), |
386 base::Bind(&FileStatusCallbackAdapter, callbacks)); | 160 base::Bind(&FileStatusCallbackAdapter, callbacks)); |
387 } | 161 } |
388 | 162 |
389 void WebFileSystemImpl::createSnapshotFileAndReadMetadata( | 163 void WebFileSystemImpl::createSnapshotFileAndReadMetadata( |
390 const WebKit::WebURL& path, | 164 const WebKit::WebURL& path, |
391 WebKit::WebFileSystemCallbacks* callbacks) { | 165 WebKit::WebFileSystemCallbacks* callbacks) { |
392 int callbacks_id = CallbacksMap::GetOrCreate()->RegisterCallbacks(callbacks); | 166 FileSystemDispatcher* dispatcher = |
393 CallDispatcherOnMainThread( | 167 ChildThread::current()->file_system_dispatcher(); |
394 main_thread_loop_.get(), | 168 dispatcher->CreateSnapshotFile( |
395 &FileSystemDispatcher::CreateSnapshotFile, | 169 GURL(path), |
396 MakeTuple(GURL(path), | 170 base::Bind(&CreateSnapshotFileCallbackAdapter, callbacks), |
397 base::Bind(&CreateSnapshotFileCallbackAdapter, | 171 base::Bind(&FileStatusCallbackAdapter, callbacks)); |
398 CurrentWorkerId(), callbacks_id, | |
399 main_thread_loop_), | |
400 base::Bind(&StatusCallbackAdapter, | |
401 CurrentWorkerId(), callbacks_id))); | |
402 } | 172 } |
403 | 173 |
404 } // namespace content | 174 } // namespace content |
OLD | NEW |