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/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
13 #include "base/threading/thread_local.h" | 13 #include "base/threading/thread_local.h" |
14 #include "content/child/child_thread.h" | 14 #include "content/child/child_thread.h" |
15 #include "content/child/fileapi/file_system_dispatcher.h" | 15 #include "content/child/fileapi/file_system_dispatcher.h" |
16 #include "content/child/fileapi/webfilewriter_impl.h" | 16 #include "content/child/fileapi/webfilewriter_impl.h" |
17 #include "content/common/fileapi/file_system_messages.h" | 17 #include "content/common/fileapi/file_system_messages.h" |
18 #include "third_party/WebKit/public/platform/WebFileInfo.h" | 18 #include "third_party/WebKit/public/platform/WebFileInfo.h" |
19 #include "third_party/WebKit/public/platform/WebFileSystemCallbacks.h" | 19 #include "third_party/WebKit/public/platform/WebFileSystemCallbacks.h" |
20 #include "third_party/WebKit/public/platform/WebString.h" | 20 #include "third_party/WebKit/public/platform/WebString.h" |
21 #include "third_party/WebKit/public/platform/WebURL.h" | 21 #include "third_party/WebKit/public/platform/WebURL.h" |
22 #include "url/gurl.h" | 22 #include "url/gurl.h" |
23 #include "webkit/child/worker_task_runner.h" | 23 #include "webkit/child/worker_task_runner.h" |
24 #include "webkit/common/fileapi/directory_entry.h" | 24 #include "webkit/common/fileapi/directory_entry.h" |
25 #include "webkit/common/fileapi/file_system_util.h" | 25 #include "webkit/common/fileapi/file_system_util.h" |
26 #include "webkit/glue/webkit_glue.h" | 26 #include "webkit/glue/webkit_glue.h" |
27 | 27 |
28 using WebKit::WebFileInfo; | 28 using blink::WebFileInfo; |
29 using WebKit::WebFileSystemCallbacks; | 29 using blink::WebFileSystemCallbacks; |
30 using WebKit::WebFileSystemEntry; | 30 using blink::WebFileSystemEntry; |
31 using WebKit::WebString; | 31 using blink::WebString; |
32 using WebKit::WebURL; | 32 using blink::WebURL; |
33 using WebKit::WebVector; | 33 using blink::WebVector; |
34 using webkit_glue::WorkerTaskRunner; | 34 using webkit_glue::WorkerTaskRunner; |
35 | 35 |
36 namespace content { | 36 namespace content { |
37 | 37 |
38 namespace { | 38 namespace { |
39 | 39 |
40 base::LazyInstance<base::ThreadLocalPointer<WebFileSystemImpl> >::Leaky | 40 base::LazyInstance<base::ThreadLocalPointer<WebFileSystemImpl> >::Leaky |
41 g_webfilesystem_tls = LAZY_INSTANCE_INITIALIZER; | 41 g_webfilesystem_tls = LAZY_INSTANCE_INITIALIZER; |
42 | 42 |
43 class WaitableCallbackResults { | 43 class WaitableCallbackResults { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 int thread_id, int callbacks_id, | 158 int thread_id, int callbacks_id, |
159 WaitableCallbackResults* waitable_results, | 159 WaitableCallbackResults* waitable_results, |
160 const fileapi::FileSystemInfo& info, | 160 const fileapi::FileSystemInfo& info, |
161 const base::FilePath& file_path, bool is_directory) { | 161 const base::FilePath& file_path, bool is_directory) { |
162 base::FilePath normalized_path( | 162 base::FilePath normalized_path( |
163 fileapi::VirtualPath::GetNormalizedFilePath(file_path)); | 163 fileapi::VirtualPath::GetNormalizedFilePath(file_path)); |
164 CallbackFileSystemCallbacks( | 164 CallbackFileSystemCallbacks( |
165 thread_id, callbacks_id, waitable_results, | 165 thread_id, callbacks_id, waitable_results, |
166 &WebFileSystemCallbacks::didResolveURL, | 166 &WebFileSystemCallbacks::didResolveURL, |
167 MakeTuple(UTF8ToUTF16(info.name), info.root_url, | 167 MakeTuple(UTF8ToUTF16(info.name), info.root_url, |
168 static_cast<WebKit::WebFileSystemType>(info.mount_type), | 168 static_cast<blink::WebFileSystemType>(info.mount_type), |
169 normalized_path.AsUTF16Unsafe(), is_directory)); | 169 normalized_path.AsUTF16Unsafe(), is_directory)); |
170 } | 170 } |
171 | 171 |
172 void StatusCallbackAdapter(int thread_id, int callbacks_id, | 172 void StatusCallbackAdapter(int thread_id, int callbacks_id, |
173 WaitableCallbackResults* waitable_results, | 173 WaitableCallbackResults* waitable_results, |
174 base::PlatformFileError error) { | 174 base::PlatformFileError error) { |
175 if (error == base::PLATFORM_FILE_OK) { | 175 if (error == base::PLATFORM_FILE_OK) { |
176 CallbackFileSystemCallbacks( | 176 CallbackFileSystemCallbacks( |
177 thread_id, callbacks_id, waitable_results, | 177 thread_id, callbacks_id, waitable_results, |
178 &WebFileSystemCallbacks::didSucceed, MakeTuple()); | 178 &WebFileSystemCallbacks::didSucceed, MakeTuple()); |
(...skipping 28 matching lines...) Expand all Loading... |
207 } | 207 } |
208 CallbackFileSystemCallbacks( | 208 CallbackFileSystemCallbacks( |
209 thread_id, callbacks_id, waitable_results, | 209 thread_id, callbacks_id, waitable_results, |
210 &WebFileSystemCallbacks::didReadDirectory, | 210 &WebFileSystemCallbacks::didReadDirectory, |
211 MakeTuple(file_system_entries, has_more)); | 211 MakeTuple(file_system_entries, has_more)); |
212 } | 212 } |
213 | 213 |
214 void DidCreateFileWriter( | 214 void DidCreateFileWriter( |
215 int callbacks_id, | 215 int callbacks_id, |
216 const GURL& path, | 216 const GURL& path, |
217 WebKit::WebFileWriterClient* client, | 217 blink::WebFileWriterClient* client, |
218 base::MessageLoopProxy* main_thread_loop, | 218 base::MessageLoopProxy* main_thread_loop, |
219 const base::PlatformFileInfo& file_info) { | 219 const base::PlatformFileInfo& file_info) { |
220 WebFileSystemImpl* filesystem = | 220 WebFileSystemImpl* filesystem = |
221 WebFileSystemImpl::ThreadSpecificInstance(NULL); | 221 WebFileSystemImpl::ThreadSpecificInstance(NULL); |
222 if (!filesystem) | 222 if (!filesystem) |
223 return; | 223 return; |
224 | 224 |
225 WebFileSystemCallbacks callbacks = | 225 WebFileSystemCallbacks callbacks = |
226 filesystem->GetAndUnregisterCallbacks(callbacks_id); | 226 filesystem->GetAndUnregisterCallbacks(callbacks_id); |
227 | 227 |
228 if (file_info.is_directory || file_info.size < 0) { | 228 if (file_info.is_directory || file_info.size < 0) { |
229 callbacks.didFail(WebKit::WebFileErrorInvalidState); | 229 callbacks.didFail(blink::WebFileErrorInvalidState); |
230 return; | 230 return; |
231 } | 231 } |
232 WebFileWriterImpl::Type type = | 232 WebFileWriterImpl::Type type = |
233 callbacks.shouldBlockUntilCompletion() ? | 233 callbacks.shouldBlockUntilCompletion() ? |
234 WebFileWriterImpl::TYPE_SYNC : WebFileWriterImpl::TYPE_ASYNC; | 234 WebFileWriterImpl::TYPE_SYNC : WebFileWriterImpl::TYPE_ASYNC; |
235 callbacks.didCreateFileWriter( | 235 callbacks.didCreateFileWriter( |
236 new WebFileWriterImpl(path, client, type, main_thread_loop), | 236 new WebFileWriterImpl(path, client, type, main_thread_loop), |
237 file_info.size); | 237 file_info.size); |
238 } | 238 } |
239 | 239 |
240 void CreateFileWriterCallbackAdapter( | 240 void CreateFileWriterCallbackAdapter( |
241 int thread_id, int callbacks_id, | 241 int thread_id, int callbacks_id, |
242 WaitableCallbackResults* waitable_results, | 242 WaitableCallbackResults* waitable_results, |
243 base::MessageLoopProxy* main_thread_loop, | 243 base::MessageLoopProxy* main_thread_loop, |
244 const GURL& path, | 244 const GURL& path, |
245 WebKit::WebFileWriterClient* client, | 245 blink::WebFileWriterClient* client, |
246 const base::PlatformFileInfo& file_info) { | 246 const base::PlatformFileInfo& file_info) { |
247 DispatchResultsClosure( | 247 DispatchResultsClosure( |
248 thread_id, callbacks_id, waitable_results, | 248 thread_id, callbacks_id, waitable_results, |
249 base::Bind(&DidCreateFileWriter, callbacks_id, path, client, | 249 base::Bind(&DidCreateFileWriter, callbacks_id, path, client, |
250 make_scoped_refptr(main_thread_loop), file_info)); | 250 make_scoped_refptr(main_thread_loop), file_info)); |
251 } | 251 } |
252 | 252 |
253 void DidCreateSnapshotFile( | 253 void DidCreateSnapshotFile( |
254 int callbacks_id, | 254 int callbacks_id, |
255 base::MessageLoopProxy* main_thread_loop, | 255 base::MessageLoopProxy* main_thread_loop, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 | 318 |
319 WebFileSystemImpl::~WebFileSystemImpl() { | 319 WebFileSystemImpl::~WebFileSystemImpl() { |
320 g_webfilesystem_tls.Pointer()->Set(NULL); | 320 g_webfilesystem_tls.Pointer()->Set(NULL); |
321 } | 321 } |
322 | 322 |
323 void WebFileSystemImpl::OnWorkerRunLoopStopped() { | 323 void WebFileSystemImpl::OnWorkerRunLoopStopped() { |
324 delete this; | 324 delete this; |
325 } | 325 } |
326 | 326 |
327 void WebFileSystemImpl::openFileSystem( | 327 void WebFileSystemImpl::openFileSystem( |
328 const WebKit::WebURL& storage_partition, | 328 const blink::WebURL& storage_partition, |
329 WebKit::WebFileSystemType type, | 329 blink::WebFileSystemType type, |
330 WebFileSystemCallbacks callbacks) { | 330 WebFileSystemCallbacks callbacks) { |
331 int callbacks_id = RegisterCallbacks(callbacks); | 331 int callbacks_id = RegisterCallbacks(callbacks); |
332 WaitableCallbackResults* waitable_results = | 332 WaitableCallbackResults* waitable_results = |
333 WaitableCallbackResults::MaybeCreate(callbacks); | 333 WaitableCallbackResults::MaybeCreate(callbacks); |
334 CallDispatcherOnMainThread( | 334 CallDispatcherOnMainThread( |
335 main_thread_loop_.get(), | 335 main_thread_loop_.get(), |
336 &FileSystemDispatcher::OpenFileSystem, | 336 &FileSystemDispatcher::OpenFileSystem, |
337 MakeTuple(GURL(storage_partition), | 337 MakeTuple(GURL(storage_partition), |
338 static_cast<fileapi::FileSystemType>(type), | 338 static_cast<fileapi::FileSystemType>(type), |
339 base::Bind(&OpenFileSystemCallbackAdapter, | 339 base::Bind(&OpenFileSystemCallbackAdapter, |
340 CurrentWorkerId(), callbacks_id, | 340 CurrentWorkerId(), callbacks_id, |
341 base::Unretained(waitable_results)), | 341 base::Unretained(waitable_results)), |
342 base::Bind(&StatusCallbackAdapter, | 342 base::Bind(&StatusCallbackAdapter, |
343 CurrentWorkerId(), callbacks_id, | 343 CurrentWorkerId(), callbacks_id, |
344 base::Unretained(waitable_results))), | 344 base::Unretained(waitable_results))), |
345 make_scoped_ptr(waitable_results)); | 345 make_scoped_ptr(waitable_results)); |
346 } | 346 } |
347 | 347 |
348 void WebFileSystemImpl::resolveURL( | 348 void WebFileSystemImpl::resolveURL( |
349 const WebKit::WebURL& filesystem_url, | 349 const blink::WebURL& filesystem_url, |
350 WebFileSystemCallbacks callbacks) { | 350 WebFileSystemCallbacks callbacks) { |
351 int callbacks_id = RegisterCallbacks(callbacks); | 351 int callbacks_id = RegisterCallbacks(callbacks); |
352 WaitableCallbackResults* waitable_results = | 352 WaitableCallbackResults* waitable_results = |
353 WaitableCallbackResults::MaybeCreate(callbacks); | 353 WaitableCallbackResults::MaybeCreate(callbacks); |
354 CallDispatcherOnMainThread( | 354 CallDispatcherOnMainThread( |
355 main_thread_loop_.get(), | 355 main_thread_loop_.get(), |
356 &FileSystemDispatcher::ResolveURL, | 356 &FileSystemDispatcher::ResolveURL, |
357 MakeTuple(GURL(filesystem_url), | 357 MakeTuple(GURL(filesystem_url), |
358 base::Bind(&ResolveURLCallbackAdapter, | 358 base::Bind(&ResolveURLCallbackAdapter, |
359 CurrentWorkerId(), callbacks_id, | 359 CurrentWorkerId(), callbacks_id, |
360 base::Unretained(waitable_results)), | 360 base::Unretained(waitable_results)), |
361 base::Bind(&StatusCallbackAdapter, | 361 base::Bind(&StatusCallbackAdapter, |
362 CurrentWorkerId(), callbacks_id, | 362 CurrentWorkerId(), callbacks_id, |
363 base::Unretained(waitable_results))), | 363 base::Unretained(waitable_results))), |
364 make_scoped_ptr(waitable_results)); | 364 make_scoped_ptr(waitable_results)); |
365 } | 365 } |
366 | 366 |
367 void WebFileSystemImpl::deleteFileSystem( | 367 void WebFileSystemImpl::deleteFileSystem( |
368 const WebKit::WebURL& storage_partition, | 368 const blink::WebURL& storage_partition, |
369 WebKit::WebFileSystemType type, | 369 blink::WebFileSystemType type, |
370 WebFileSystemCallbacks callbacks) { | 370 WebFileSystemCallbacks callbacks) { |
371 int callbacks_id = RegisterCallbacks(callbacks); | 371 int callbacks_id = RegisterCallbacks(callbacks); |
372 WaitableCallbackResults* waitable_results = | 372 WaitableCallbackResults* waitable_results = |
373 WaitableCallbackResults::MaybeCreate(callbacks); | 373 WaitableCallbackResults::MaybeCreate(callbacks); |
374 CallDispatcherOnMainThread( | 374 CallDispatcherOnMainThread( |
375 main_thread_loop_.get(), | 375 main_thread_loop_.get(), |
376 &FileSystemDispatcher::DeleteFileSystem, | 376 &FileSystemDispatcher::DeleteFileSystem, |
377 MakeTuple(GURL(storage_partition), | 377 MakeTuple(GURL(storage_partition), |
378 static_cast<fileapi::FileSystemType>(type), | 378 static_cast<fileapi::FileSystemType>(type), |
379 base::Bind(&StatusCallbackAdapter, | 379 base::Bind(&StatusCallbackAdapter, |
380 CurrentWorkerId(), callbacks_id, | 380 CurrentWorkerId(), callbacks_id, |
381 base::Unretained(waitable_results))), | 381 base::Unretained(waitable_results))), |
382 make_scoped_ptr(waitable_results)); | 382 make_scoped_ptr(waitable_results)); |
383 } | 383 } |
384 | 384 |
385 void WebFileSystemImpl::move( | 385 void WebFileSystemImpl::move( |
386 const WebKit::WebURL& src_path, | 386 const blink::WebURL& src_path, |
387 const WebKit::WebURL& dest_path, | 387 const blink::WebURL& dest_path, |
388 WebFileSystemCallbacks callbacks) { | 388 WebFileSystemCallbacks callbacks) { |
389 int callbacks_id = RegisterCallbacks(callbacks); | 389 int callbacks_id = RegisterCallbacks(callbacks); |
390 WaitableCallbackResults* waitable_results = | 390 WaitableCallbackResults* waitable_results = |
391 WaitableCallbackResults::MaybeCreate(callbacks); | 391 WaitableCallbackResults::MaybeCreate(callbacks); |
392 CallDispatcherOnMainThread( | 392 CallDispatcherOnMainThread( |
393 main_thread_loop_.get(), | 393 main_thread_loop_.get(), |
394 &FileSystemDispatcher::Move, | 394 &FileSystemDispatcher::Move, |
395 MakeTuple(GURL(src_path), GURL(dest_path), | 395 MakeTuple(GURL(src_path), GURL(dest_path), |
396 base::Bind(&StatusCallbackAdapter, | 396 base::Bind(&StatusCallbackAdapter, |
397 CurrentWorkerId(), callbacks_id, | 397 CurrentWorkerId(), callbacks_id, |
398 base::Unretained(waitable_results))), | 398 base::Unretained(waitable_results))), |
399 make_scoped_ptr(waitable_results)); | 399 make_scoped_ptr(waitable_results)); |
400 } | 400 } |
401 | 401 |
402 void WebFileSystemImpl::copy( | 402 void WebFileSystemImpl::copy( |
403 const WebKit::WebURL& src_path, | 403 const blink::WebURL& src_path, |
404 const WebKit::WebURL& dest_path, | 404 const blink::WebURL& dest_path, |
405 WebFileSystemCallbacks callbacks) { | 405 WebFileSystemCallbacks callbacks) { |
406 int callbacks_id = RegisterCallbacks(callbacks); | 406 int callbacks_id = RegisterCallbacks(callbacks); |
407 WaitableCallbackResults* waitable_results = | 407 WaitableCallbackResults* waitable_results = |
408 WaitableCallbackResults::MaybeCreate(callbacks); | 408 WaitableCallbackResults::MaybeCreate(callbacks); |
409 CallDispatcherOnMainThread( | 409 CallDispatcherOnMainThread( |
410 main_thread_loop_.get(), | 410 main_thread_loop_.get(), |
411 &FileSystemDispatcher::Copy, | 411 &FileSystemDispatcher::Copy, |
412 MakeTuple(GURL(src_path), GURL(dest_path), | 412 MakeTuple(GURL(src_path), GURL(dest_path), |
413 base::Bind(&StatusCallbackAdapter, | 413 base::Bind(&StatusCallbackAdapter, |
414 CurrentWorkerId(), callbacks_id, | 414 CurrentWorkerId(), callbacks_id, |
415 base::Unretained(waitable_results))), | 415 base::Unretained(waitable_results))), |
416 make_scoped_ptr(waitable_results)); | 416 make_scoped_ptr(waitable_results)); |
417 } | 417 } |
418 | 418 |
419 void WebFileSystemImpl::remove( | 419 void WebFileSystemImpl::remove( |
420 const WebKit::WebURL& path, | 420 const blink::WebURL& path, |
421 WebFileSystemCallbacks callbacks) { | 421 WebFileSystemCallbacks callbacks) { |
422 int callbacks_id = RegisterCallbacks(callbacks); | 422 int callbacks_id = RegisterCallbacks(callbacks); |
423 WaitableCallbackResults* waitable_results = | 423 WaitableCallbackResults* waitable_results = |
424 WaitableCallbackResults::MaybeCreate(callbacks); | 424 WaitableCallbackResults::MaybeCreate(callbacks); |
425 CallDispatcherOnMainThread( | 425 CallDispatcherOnMainThread( |
426 main_thread_loop_.get(), | 426 main_thread_loop_.get(), |
427 &FileSystemDispatcher::Remove, | 427 &FileSystemDispatcher::Remove, |
428 MakeTuple(GURL(path), false /* recursive */, | 428 MakeTuple(GURL(path), false /* recursive */, |
429 base::Bind(&StatusCallbackAdapter, | 429 base::Bind(&StatusCallbackAdapter, |
430 CurrentWorkerId(), callbacks_id, | 430 CurrentWorkerId(), callbacks_id, |
431 base::Unretained(waitable_results))), | 431 base::Unretained(waitable_results))), |
432 make_scoped_ptr(waitable_results)); | 432 make_scoped_ptr(waitable_results)); |
433 } | 433 } |
434 | 434 |
435 void WebFileSystemImpl::removeRecursively( | 435 void WebFileSystemImpl::removeRecursively( |
436 const WebKit::WebURL& path, | 436 const blink::WebURL& path, |
437 WebFileSystemCallbacks callbacks) { | 437 WebFileSystemCallbacks callbacks) { |
438 int callbacks_id = RegisterCallbacks(callbacks); | 438 int callbacks_id = RegisterCallbacks(callbacks); |
439 WaitableCallbackResults* waitable_results = | 439 WaitableCallbackResults* waitable_results = |
440 WaitableCallbackResults::MaybeCreate(callbacks); | 440 WaitableCallbackResults::MaybeCreate(callbacks); |
441 CallDispatcherOnMainThread( | 441 CallDispatcherOnMainThread( |
442 main_thread_loop_.get(), | 442 main_thread_loop_.get(), |
443 &FileSystemDispatcher::Remove, | 443 &FileSystemDispatcher::Remove, |
444 MakeTuple(GURL(path), true /* recursive */, | 444 MakeTuple(GURL(path), true /* recursive */, |
445 base::Bind(&StatusCallbackAdapter, | 445 base::Bind(&StatusCallbackAdapter, |
446 CurrentWorkerId(), callbacks_id, | 446 CurrentWorkerId(), callbacks_id, |
447 base::Unretained(waitable_results))), | 447 base::Unretained(waitable_results))), |
448 make_scoped_ptr(waitable_results)); | 448 make_scoped_ptr(waitable_results)); |
449 } | 449 } |
450 | 450 |
451 void WebFileSystemImpl::readMetadata( | 451 void WebFileSystemImpl::readMetadata( |
452 const WebKit::WebURL& path, | 452 const blink::WebURL& path, |
453 WebFileSystemCallbacks callbacks) { | 453 WebFileSystemCallbacks callbacks) { |
454 int callbacks_id = RegisterCallbacks(callbacks); | 454 int callbacks_id = RegisterCallbacks(callbacks); |
455 WaitableCallbackResults* waitable_results = | 455 WaitableCallbackResults* waitable_results = |
456 WaitableCallbackResults::MaybeCreate(callbacks); | 456 WaitableCallbackResults::MaybeCreate(callbacks); |
457 CallDispatcherOnMainThread( | 457 CallDispatcherOnMainThread( |
458 main_thread_loop_.get(), | 458 main_thread_loop_.get(), |
459 &FileSystemDispatcher::ReadMetadata, | 459 &FileSystemDispatcher::ReadMetadata, |
460 MakeTuple(GURL(path), | 460 MakeTuple(GURL(path), |
461 base::Bind(&ReadMetadataCallbackAdapter, | 461 base::Bind(&ReadMetadataCallbackAdapter, |
462 CurrentWorkerId(), callbacks_id, | 462 CurrentWorkerId(), callbacks_id, |
463 base::Unretained(waitable_results)), | 463 base::Unretained(waitable_results)), |
464 base::Bind(&StatusCallbackAdapter, | 464 base::Bind(&StatusCallbackAdapter, |
465 CurrentWorkerId(), callbacks_id, | 465 CurrentWorkerId(), callbacks_id, |
466 base::Unretained(waitable_results))), | 466 base::Unretained(waitable_results))), |
467 make_scoped_ptr(waitable_results)); | 467 make_scoped_ptr(waitable_results)); |
468 } | 468 } |
469 | 469 |
470 void WebFileSystemImpl::createFile( | 470 void WebFileSystemImpl::createFile( |
471 const WebKit::WebURL& path, | 471 const blink::WebURL& path, |
472 bool exclusive, | 472 bool exclusive, |
473 WebFileSystemCallbacks callbacks) { | 473 WebFileSystemCallbacks callbacks) { |
474 int callbacks_id = RegisterCallbacks(callbacks); | 474 int callbacks_id = RegisterCallbacks(callbacks); |
475 WaitableCallbackResults* waitable_results = | 475 WaitableCallbackResults* waitable_results = |
476 WaitableCallbackResults::MaybeCreate(callbacks); | 476 WaitableCallbackResults::MaybeCreate(callbacks); |
477 CallDispatcherOnMainThread( | 477 CallDispatcherOnMainThread( |
478 main_thread_loop_.get(), | 478 main_thread_loop_.get(), |
479 &FileSystemDispatcher::CreateFile, | 479 &FileSystemDispatcher::CreateFile, |
480 MakeTuple(GURL(path), exclusive, | 480 MakeTuple(GURL(path), exclusive, |
481 base::Bind(&StatusCallbackAdapter, | 481 base::Bind(&StatusCallbackAdapter, |
482 CurrentWorkerId(), callbacks_id, | 482 CurrentWorkerId(), callbacks_id, |
483 base::Unretained(waitable_results))), | 483 base::Unretained(waitable_results))), |
484 make_scoped_ptr(waitable_results)); | 484 make_scoped_ptr(waitable_results)); |
485 } | 485 } |
486 | 486 |
487 void WebFileSystemImpl::createDirectory( | 487 void WebFileSystemImpl::createDirectory( |
488 const WebKit::WebURL& path, | 488 const blink::WebURL& path, |
489 bool exclusive, | 489 bool exclusive, |
490 WebFileSystemCallbacks callbacks) { | 490 WebFileSystemCallbacks callbacks) { |
491 int callbacks_id = RegisterCallbacks(callbacks); | 491 int callbacks_id = RegisterCallbacks(callbacks); |
492 WaitableCallbackResults* waitable_results = | 492 WaitableCallbackResults* waitable_results = |
493 WaitableCallbackResults::MaybeCreate(callbacks); | 493 WaitableCallbackResults::MaybeCreate(callbacks); |
494 CallDispatcherOnMainThread( | 494 CallDispatcherOnMainThread( |
495 main_thread_loop_.get(), | 495 main_thread_loop_.get(), |
496 &FileSystemDispatcher::CreateDirectory, | 496 &FileSystemDispatcher::CreateDirectory, |
497 MakeTuple(GURL(path), exclusive, false /* recursive */, | 497 MakeTuple(GURL(path), exclusive, false /* recursive */, |
498 base::Bind(&StatusCallbackAdapter, | 498 base::Bind(&StatusCallbackAdapter, |
499 CurrentWorkerId(), callbacks_id, | 499 CurrentWorkerId(), callbacks_id, |
500 base::Unretained(waitable_results))), | 500 base::Unretained(waitable_results))), |
501 make_scoped_ptr(waitable_results)); | 501 make_scoped_ptr(waitable_results)); |
502 } | 502 } |
503 | 503 |
504 void WebFileSystemImpl::fileExists( | 504 void WebFileSystemImpl::fileExists( |
505 const WebKit::WebURL& path, | 505 const blink::WebURL& path, |
506 WebFileSystemCallbacks callbacks) { | 506 WebFileSystemCallbacks callbacks) { |
507 int callbacks_id = RegisterCallbacks(callbacks); | 507 int callbacks_id = RegisterCallbacks(callbacks); |
508 WaitableCallbackResults* waitable_results = | 508 WaitableCallbackResults* waitable_results = |
509 WaitableCallbackResults::MaybeCreate(callbacks); | 509 WaitableCallbackResults::MaybeCreate(callbacks); |
510 CallDispatcherOnMainThread( | 510 CallDispatcherOnMainThread( |
511 main_thread_loop_.get(), | 511 main_thread_loop_.get(), |
512 &FileSystemDispatcher::Exists, | 512 &FileSystemDispatcher::Exists, |
513 MakeTuple(GURL(path), false /* directory */, | 513 MakeTuple(GURL(path), false /* directory */, |
514 base::Bind(&StatusCallbackAdapter, | 514 base::Bind(&StatusCallbackAdapter, |
515 CurrentWorkerId(), callbacks_id, | 515 CurrentWorkerId(), callbacks_id, |
516 base::Unretained(waitable_results))), | 516 base::Unretained(waitable_results))), |
517 make_scoped_ptr(waitable_results)); | 517 make_scoped_ptr(waitable_results)); |
518 } | 518 } |
519 | 519 |
520 void WebFileSystemImpl::directoryExists( | 520 void WebFileSystemImpl::directoryExists( |
521 const WebKit::WebURL& path, | 521 const blink::WebURL& path, |
522 WebFileSystemCallbacks callbacks) { | 522 WebFileSystemCallbacks callbacks) { |
523 int callbacks_id = RegisterCallbacks(callbacks); | 523 int callbacks_id = RegisterCallbacks(callbacks); |
524 WaitableCallbackResults* waitable_results = | 524 WaitableCallbackResults* waitable_results = |
525 WaitableCallbackResults::MaybeCreate(callbacks); | 525 WaitableCallbackResults::MaybeCreate(callbacks); |
526 CallDispatcherOnMainThread( | 526 CallDispatcherOnMainThread( |
527 main_thread_loop_.get(), | 527 main_thread_loop_.get(), |
528 &FileSystemDispatcher::Exists, | 528 &FileSystemDispatcher::Exists, |
529 MakeTuple(GURL(path), true /* directory */, | 529 MakeTuple(GURL(path), true /* directory */, |
530 base::Bind(&StatusCallbackAdapter, | 530 base::Bind(&StatusCallbackAdapter, |
531 CurrentWorkerId(), callbacks_id, | 531 CurrentWorkerId(), callbacks_id, |
532 base::Unretained(waitable_results))), | 532 base::Unretained(waitable_results))), |
533 make_scoped_ptr(waitable_results)); | 533 make_scoped_ptr(waitable_results)); |
534 } | 534 } |
535 | 535 |
536 void WebFileSystemImpl::readDirectory( | 536 void WebFileSystemImpl::readDirectory( |
537 const WebKit::WebURL& path, | 537 const blink::WebURL& path, |
538 WebFileSystemCallbacks callbacks) { | 538 WebFileSystemCallbacks callbacks) { |
539 int callbacks_id = RegisterCallbacks(callbacks); | 539 int callbacks_id = RegisterCallbacks(callbacks); |
540 WaitableCallbackResults* waitable_results = | 540 WaitableCallbackResults* waitable_results = |
541 WaitableCallbackResults::MaybeCreate(callbacks); | 541 WaitableCallbackResults::MaybeCreate(callbacks); |
542 CallDispatcherOnMainThread( | 542 CallDispatcherOnMainThread( |
543 main_thread_loop_.get(), | 543 main_thread_loop_.get(), |
544 &FileSystemDispatcher::ReadDirectory, | 544 &FileSystemDispatcher::ReadDirectory, |
545 MakeTuple(GURL(path), | 545 MakeTuple(GURL(path), |
546 base::Bind(&ReadDirectoryCallbackAdapater, | 546 base::Bind(&ReadDirectoryCallbackAdapater, |
547 CurrentWorkerId(), callbacks_id, | 547 CurrentWorkerId(), callbacks_id, |
548 base::Unretained(waitable_results)), | 548 base::Unretained(waitable_results)), |
549 base::Bind(&StatusCallbackAdapter, | 549 base::Bind(&StatusCallbackAdapter, |
550 CurrentWorkerId(), callbacks_id, | 550 CurrentWorkerId(), callbacks_id, |
551 base::Unretained(waitable_results))), | 551 base::Unretained(waitable_results))), |
552 make_scoped_ptr(waitable_results)); | 552 make_scoped_ptr(waitable_results)); |
553 } | 553 } |
554 | 554 |
555 void WebFileSystemImpl::createFileWriter( | 555 void WebFileSystemImpl::createFileWriter( |
556 const WebURL& path, | 556 const WebURL& path, |
557 WebKit::WebFileWriterClient* client, | 557 blink::WebFileWriterClient* client, |
558 WebFileSystemCallbacks callbacks) { | 558 WebFileSystemCallbacks callbacks) { |
559 int callbacks_id = RegisterCallbacks(callbacks); | 559 int callbacks_id = RegisterCallbacks(callbacks); |
560 WaitableCallbackResults* waitable_results = | 560 WaitableCallbackResults* waitable_results = |
561 WaitableCallbackResults::MaybeCreate(callbacks); | 561 WaitableCallbackResults::MaybeCreate(callbacks); |
562 CallDispatcherOnMainThread( | 562 CallDispatcherOnMainThread( |
563 main_thread_loop_.get(), | 563 main_thread_loop_.get(), |
564 &FileSystemDispatcher::ReadMetadata, | 564 &FileSystemDispatcher::ReadMetadata, |
565 MakeTuple(GURL(path), | 565 MakeTuple(GURL(path), |
566 base::Bind(&CreateFileWriterCallbackAdapter, | 566 base::Bind(&CreateFileWriterCallbackAdapter, |
567 CurrentWorkerId(), callbacks_id, | 567 CurrentWorkerId(), callbacks_id, |
568 base::Unretained(waitable_results), | 568 base::Unretained(waitable_results), |
569 main_thread_loop_, GURL(path), client), | 569 main_thread_loop_, GURL(path), client), |
570 base::Bind(&StatusCallbackAdapter, | 570 base::Bind(&StatusCallbackAdapter, |
571 CurrentWorkerId(), callbacks_id, | 571 CurrentWorkerId(), callbacks_id, |
572 base::Unretained(waitable_results))), | 572 base::Unretained(waitable_results))), |
573 make_scoped_ptr(waitable_results)); | 573 make_scoped_ptr(waitable_results)); |
574 } | 574 } |
575 | 575 |
576 void WebFileSystemImpl::createSnapshotFileAndReadMetadata( | 576 void WebFileSystemImpl::createSnapshotFileAndReadMetadata( |
577 const WebKit::WebURL& path, | 577 const blink::WebURL& path, |
578 WebFileSystemCallbacks callbacks) { | 578 WebFileSystemCallbacks callbacks) { |
579 int callbacks_id = RegisterCallbacks(callbacks); | 579 int callbacks_id = RegisterCallbacks(callbacks); |
580 WaitableCallbackResults* waitable_results = | 580 WaitableCallbackResults* waitable_results = |
581 WaitableCallbackResults::MaybeCreate(callbacks); | 581 WaitableCallbackResults::MaybeCreate(callbacks); |
582 CallDispatcherOnMainThread( | 582 CallDispatcherOnMainThread( |
583 main_thread_loop_.get(), | 583 main_thread_loop_.get(), |
584 &FileSystemDispatcher::CreateSnapshotFile, | 584 &FileSystemDispatcher::CreateSnapshotFile, |
585 MakeTuple(GURL(path), | 585 MakeTuple(GURL(path), |
586 base::Bind(&CreateSnapshotFileCallbackAdapter, | 586 base::Bind(&CreateSnapshotFileCallbackAdapter, |
587 CurrentWorkerId(), callbacks_id, | 587 CurrentWorkerId(), callbacks_id, |
(...skipping 17 matching lines...) Expand all Loading... |
605 int callbacks_id) { | 605 int callbacks_id) { |
606 DCHECK(CalledOnValidThread()); | 606 DCHECK(CalledOnValidThread()); |
607 CallbacksMap::iterator found = callbacks_.find(callbacks_id); | 607 CallbacksMap::iterator found = callbacks_.find(callbacks_id); |
608 DCHECK(found != callbacks_.end()); | 608 DCHECK(found != callbacks_.end()); |
609 WebFileSystemCallbacks callbacks = found->second; | 609 WebFileSystemCallbacks callbacks = found->second; |
610 callbacks_.erase(found); | 610 callbacks_.erase(found); |
611 return callbacks; | 611 return callbacks; |
612 } | 612 } |
613 | 613 |
614 } // namespace content | 614 } // namespace content |
OLD | NEW |