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" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 void OpenFileSystemCallbackAdapter( | 148 void OpenFileSystemCallbackAdapter( |
149 int thread_id, int callbacks_id, | 149 int thread_id, int callbacks_id, |
150 WaitableCallbackResults* waitable_results, | 150 WaitableCallbackResults* waitable_results, |
151 const std::string& name, const GURL& root) { | 151 const std::string& name, const GURL& root) { |
152 CallbackFileSystemCallbacks( | 152 CallbackFileSystemCallbacks( |
153 thread_id, callbacks_id, waitable_results, | 153 thread_id, callbacks_id, waitable_results, |
154 &WebFileSystemCallbacks::didOpenFileSystem, | 154 &WebFileSystemCallbacks::didOpenFileSystem, |
155 MakeTuple(UTF8ToUTF16(name), root)); | 155 MakeTuple(UTF8ToUTF16(name), root)); |
156 } | 156 } |
157 | 157 |
| 158 void ResolveURLCallbackAdapter( |
| 159 int thread_id, int callbacks_id, |
| 160 WaitableCallbackResults* waitable_results, |
| 161 const std::string& name, const GURL& root, |
| 162 const base::FilePath& file_path, bool is_directory) { |
| 163 CallbackFileSystemCallbacks( |
| 164 thread_id, callbacks_id, waitable_results, |
| 165 &WebFileSystemCallbacks::didResolveURL, |
| 166 MakeTuple(UTF8ToUTF16(name), root, |
| 167 file_path.AsUTF16Unsafe(), is_directory)); |
| 168 } |
| 169 |
158 void StatusCallbackAdapter(int thread_id, int callbacks_id, | 170 void StatusCallbackAdapter(int thread_id, int callbacks_id, |
159 WaitableCallbackResults* waitable_results, | 171 WaitableCallbackResults* waitable_results, |
160 base::PlatformFileError error) { | 172 base::PlatformFileError error) { |
161 if (error == base::PLATFORM_FILE_OK) { | 173 if (error == base::PLATFORM_FILE_OK) { |
162 CallbackFileSystemCallbacks( | 174 CallbackFileSystemCallbacks( |
163 thread_id, callbacks_id, waitable_results, | 175 thread_id, callbacks_id, waitable_results, |
164 &WebFileSystemCallbacks::didSucceed, MakeTuple()); | 176 &WebFileSystemCallbacks::didSucceed, MakeTuple()); |
165 } else { | 177 } else { |
166 CallbackFileSystemCallbacks( | 178 CallbackFileSystemCallbacks( |
167 thread_id, callbacks_id, waitable_results, | 179 thread_id, callbacks_id, waitable_results, |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 0 /* size (not used) */, create, | 343 0 /* size (not used) */, create, |
332 base::Bind(&OpenFileSystemCallbackAdapter, | 344 base::Bind(&OpenFileSystemCallbackAdapter, |
333 CurrentWorkerId(), callbacks_id, | 345 CurrentWorkerId(), callbacks_id, |
334 base::Unretained(waitable_results)), | 346 base::Unretained(waitable_results)), |
335 base::Bind(&StatusCallbackAdapter, | 347 base::Bind(&StatusCallbackAdapter, |
336 CurrentWorkerId(), callbacks_id, | 348 CurrentWorkerId(), callbacks_id, |
337 base::Unretained(waitable_results))), | 349 base::Unretained(waitable_results))), |
338 make_scoped_ptr(waitable_results)); | 350 make_scoped_ptr(waitable_results)); |
339 } | 351 } |
340 | 352 |
| 353 void WebFileSystemImpl::resolveURL( |
| 354 const WebKit::WebURL& storage_partition, |
| 355 WebKit::WebFileSystemCallbacks* callbacks) { |
| 356 int callbacks_id = RegisterCallbacks(callbacks); |
| 357 WaitableCallbackResults* waitable_results = |
| 358 WaitableCallbackResults::MaybeCreate(callbacks); |
| 359 CallDispatcherOnMainThread( |
| 360 main_thread_loop_.get(), |
| 361 &FileSystemDispatcher::ResolveURL, |
| 362 MakeTuple(GURL(storage_partition), |
| 363 base::Bind(&ResolveURLCallbackAdapter, |
| 364 CurrentWorkerId(), callbacks_id, |
| 365 base::Unretained(waitable_results)), |
| 366 base::Bind(&StatusCallbackAdapter, |
| 367 CurrentWorkerId(), callbacks_id, |
| 368 base::Unretained(waitable_results))), |
| 369 make_scoped_ptr(waitable_results)); |
| 370 } |
| 371 |
341 void WebFileSystemImpl::deleteFileSystem( | 372 void WebFileSystemImpl::deleteFileSystem( |
342 const WebKit::WebURL& storage_partition, | 373 const WebKit::WebURL& storage_partition, |
343 WebKit::WebFileSystemType type, | 374 WebKit::WebFileSystemType type, |
344 WebKit::WebFileSystemCallbacks* callbacks) { | 375 WebKit::WebFileSystemCallbacks* callbacks) { |
345 int callbacks_id = RegisterCallbacks(callbacks); | 376 int callbacks_id = RegisterCallbacks(callbacks); |
346 WaitableCallbackResults* waitable_results = | 377 WaitableCallbackResults* waitable_results = |
347 WaitableCallbackResults::MaybeCreate(callbacks); | 378 WaitableCallbackResults::MaybeCreate(callbacks); |
348 CallDispatcherOnMainThread( | 379 CallDispatcherOnMainThread( |
349 main_thread_loop_.get(), | 380 main_thread_loop_.get(), |
350 &FileSystemDispatcher::DeleteFileSystem, | 381 &FileSystemDispatcher::DeleteFileSystem, |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 WebKit::WebFileSystemCallbacks* callbacks) { | 511 WebKit::WebFileSystemCallbacks* callbacks) { |
481 int callbacks_id = RegisterCallbacks(callbacks); | 512 int callbacks_id = RegisterCallbacks(callbacks); |
482 WaitableCallbackResults* waitable_results = | 513 WaitableCallbackResults* waitable_results = |
483 WaitableCallbackResults::MaybeCreate(callbacks); | 514 WaitableCallbackResults::MaybeCreate(callbacks); |
484 CallDispatcherOnMainThread( | 515 CallDispatcherOnMainThread( |
485 main_thread_loop_.get(), | 516 main_thread_loop_.get(), |
486 &FileSystemDispatcher::Exists, | 517 &FileSystemDispatcher::Exists, |
487 MakeTuple(GURL(path), false /* directory */, | 518 MakeTuple(GURL(path), false /* directory */, |
488 base::Bind(&StatusCallbackAdapter, | 519 base::Bind(&StatusCallbackAdapter, |
489 CurrentWorkerId(), callbacks_id, | 520 CurrentWorkerId(), callbacks_id, |
490 base::Unretained(waitable_results))), | 521 base::Unretained(waitable_results))), |
491 make_scoped_ptr(waitable_results)); | 522 make_scoped_ptr(waitable_results)); |
492 } | 523 } |
493 | 524 |
494 void WebFileSystemImpl::directoryExists( | 525 void WebFileSystemImpl::directoryExists( |
495 const WebKit::WebURL& path, | 526 const WebKit::WebURL& path, |
496 WebKit::WebFileSystemCallbacks* callbacks) { | 527 WebKit::WebFileSystemCallbacks* callbacks) { |
497 int callbacks_id = RegisterCallbacks(callbacks); | 528 int callbacks_id = RegisterCallbacks(callbacks); |
498 WaitableCallbackResults* waitable_results = | 529 WaitableCallbackResults* waitable_results = |
499 WaitableCallbackResults::MaybeCreate(callbacks); | 530 WaitableCallbackResults::MaybeCreate(callbacks); |
500 CallDispatcherOnMainThread( | 531 CallDispatcherOnMainThread( |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 } | 610 } |
580 | 611 |
581 WebFileSystemCallbacks* WebFileSystemImpl::GetAndUnregisterCallbacks( | 612 WebFileSystemCallbacks* WebFileSystemImpl::GetAndUnregisterCallbacks( |
582 int callbacks_id) { | 613 int callbacks_id) { |
583 WebFileSystemCallbacks* callbacks = callbacks_.Lookup(callbacks_id); | 614 WebFileSystemCallbacks* callbacks = callbacks_.Lookup(callbacks_id); |
584 callbacks_.Remove(callbacks_id); | 615 callbacks_.Remove(callbacks_id); |
585 return callbacks; | 616 return callbacks; |
586 } | 617 } |
587 | 618 |
588 } // namespace content | 619 } // namespace content |
OLD | NEW |