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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 void OpenFileSystemCallbackAdapter( | 156 void OpenFileSystemCallbackAdapter( |
157 int thread_id, int callbacks_id, | 157 int thread_id, int callbacks_id, |
158 WaitableCallbackResults* waitable_results, | 158 WaitableCallbackResults* waitable_results, |
159 const std::string& name, const GURL& root) { | 159 const std::string& name, const GURL& root) { |
160 CallbackFileSystemCallbacks( | 160 CallbackFileSystemCallbacks( |
161 thread_id, callbacks_id, waitable_results, | 161 thread_id, callbacks_id, waitable_results, |
162 &WebFileSystemCallbacks::didOpenFileSystem, | 162 &WebFileSystemCallbacks::didOpenFileSystem, |
163 MakeTuple(UTF8ToUTF16(name), root)); | 163 MakeTuple(UTF8ToUTF16(name), root)); |
164 } | 164 } |
165 | 165 |
| 166 void ResolveURLCallbackAdapter( |
| 167 int thread_id, int callbacks_id, |
| 168 WaitableCallbackResults* waitable_results, |
| 169 const fileapi::FileSystemInfo& info, |
| 170 const base::FilePath& file_path, bool is_directory) { |
| 171 CallbackFileSystemCallbacks( |
| 172 thread_id, callbacks_id, waitable_results, |
| 173 &WebFileSystemCallbacks::didResolveURL, |
| 174 MakeTuple(UTF8ToUTF16(info.name), info.root_url, |
| 175 static_cast<WebKit::WebFileSystemType>(info.mount_type), |
| 176 file_path.AsUTF16Unsafe(), is_directory)); |
| 177 } |
| 178 |
166 void StatusCallbackAdapter(int thread_id, int callbacks_id, | 179 void StatusCallbackAdapter(int thread_id, int callbacks_id, |
167 WaitableCallbackResults* waitable_results, | 180 WaitableCallbackResults* waitable_results, |
168 base::PlatformFileError error) { | 181 base::PlatformFileError error) { |
169 if (error == base::PLATFORM_FILE_OK) { | 182 if (error == base::PLATFORM_FILE_OK) { |
170 CallbackFileSystemCallbacks( | 183 CallbackFileSystemCallbacks( |
171 thread_id, callbacks_id, waitable_results, | 184 thread_id, callbacks_id, waitable_results, |
172 &WebFileSystemCallbacks::didSucceed, MakeTuple()); | 185 &WebFileSystemCallbacks::didSucceed, MakeTuple()); |
173 } else { | 186 } else { |
174 CallbackFileSystemCallbacks( | 187 CallbackFileSystemCallbacks( |
175 thread_id, callbacks_id, waitable_results, | 188 thread_id, callbacks_id, waitable_results, |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 0 /* size (not used) */, create, | 353 0 /* size (not used) */, create, |
341 base::Bind(&OpenFileSystemCallbackAdapter, | 354 base::Bind(&OpenFileSystemCallbackAdapter, |
342 CurrentWorkerId(), callbacks_id, | 355 CurrentWorkerId(), callbacks_id, |
343 base::Unretained(waitable_results)), | 356 base::Unretained(waitable_results)), |
344 base::Bind(&StatusCallbackAdapter, | 357 base::Bind(&StatusCallbackAdapter, |
345 CurrentWorkerId(), callbacks_id, | 358 CurrentWorkerId(), callbacks_id, |
346 base::Unretained(waitable_results))), | 359 base::Unretained(waitable_results))), |
347 make_scoped_ptr(waitable_results)); | 360 make_scoped_ptr(waitable_results)); |
348 } | 361 } |
349 | 362 |
| 363 void WebFileSystemImpl::resolveURL( |
| 364 const WebKit::WebURL& filesystem_url, |
| 365 WebFileSystemCallbacksType callbacks) { |
| 366 int callbacks_id = RegisterCallbacks(callbacks); |
| 367 WaitableCallbackResults* waitable_results = |
| 368 WaitableCallbackResults::MaybeCreate(callbacks); |
| 369 CallDispatcherOnMainThread( |
| 370 main_thread_loop_.get(), |
| 371 &FileSystemDispatcher::ResolveURL, |
| 372 MakeTuple(GURL(filesystem_url), |
| 373 base::Bind(&ResolveURLCallbackAdapter, |
| 374 CurrentWorkerId(), callbacks_id, |
| 375 base::Unretained(waitable_results)), |
| 376 base::Bind(&StatusCallbackAdapter, |
| 377 CurrentWorkerId(), callbacks_id, |
| 378 base::Unretained(waitable_results))), |
| 379 make_scoped_ptr(waitable_results)); |
| 380 } |
| 381 |
350 void WebFileSystemImpl::deleteFileSystem( | 382 void WebFileSystemImpl::deleteFileSystem( |
351 const WebKit::WebURL& storage_partition, | 383 const WebKit::WebURL& storage_partition, |
352 WebKit::WebFileSystemType type, | 384 WebKit::WebFileSystemType type, |
353 WebFileSystemCallbacksType callbacks) { | 385 WebFileSystemCallbacksType callbacks) { |
354 int callbacks_id = RegisterCallbacks(callbacks); | 386 int callbacks_id = RegisterCallbacks(callbacks); |
355 WaitableCallbackResults* waitable_results = | 387 WaitableCallbackResults* waitable_results = |
356 WaitableCallbackResults::MaybeCreate(callbacks); | 388 WaitableCallbackResults::MaybeCreate(callbacks); |
357 CallDispatcherOnMainThread( | 389 CallDispatcherOnMainThread( |
358 main_thread_loop_.get(), | 390 main_thread_loop_.get(), |
359 &FileSystemDispatcher::DeleteFileSystem, | 391 &FileSystemDispatcher::DeleteFileSystem, |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 WebFileSystemCallbacksType callbacks) { | 521 WebFileSystemCallbacksType callbacks) { |
490 int callbacks_id = RegisterCallbacks(callbacks); | 522 int callbacks_id = RegisterCallbacks(callbacks); |
491 WaitableCallbackResults* waitable_results = | 523 WaitableCallbackResults* waitable_results = |
492 WaitableCallbackResults::MaybeCreate(callbacks); | 524 WaitableCallbackResults::MaybeCreate(callbacks); |
493 CallDispatcherOnMainThread( | 525 CallDispatcherOnMainThread( |
494 main_thread_loop_.get(), | 526 main_thread_loop_.get(), |
495 &FileSystemDispatcher::Exists, | 527 &FileSystemDispatcher::Exists, |
496 MakeTuple(GURL(path), false /* directory */, | 528 MakeTuple(GURL(path), false /* directory */, |
497 base::Bind(&StatusCallbackAdapter, | 529 base::Bind(&StatusCallbackAdapter, |
498 CurrentWorkerId(), callbacks_id, | 530 CurrentWorkerId(), callbacks_id, |
499 base::Unretained(waitable_results))), | 531 base::Unretained(waitable_results))), |
500 make_scoped_ptr(waitable_results)); | 532 make_scoped_ptr(waitable_results)); |
501 } | 533 } |
502 | 534 |
503 void WebFileSystemImpl::directoryExists( | 535 void WebFileSystemImpl::directoryExists( |
504 const WebKit::WebURL& path, | 536 const WebKit::WebURL& path, |
505 WebFileSystemCallbacksType callbacks) { | 537 WebFileSystemCallbacksType callbacks) { |
506 int callbacks_id = RegisterCallbacks(callbacks); | 538 int callbacks_id = RegisterCallbacks(callbacks); |
507 WaitableCallbackResults* waitable_results = | 539 WaitableCallbackResults* waitable_results = |
508 WaitableCallbackResults::MaybeCreate(callbacks); | 540 WaitableCallbackResults::MaybeCreate(callbacks); |
509 CallDispatcherOnMainThread( | 541 CallDispatcherOnMainThread( |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 int callbacks_id) { | 626 int callbacks_id) { |
595 DCHECK(CalledOnValidThread()); | 627 DCHECK(CalledOnValidThread()); |
596 CallbacksMap::iterator found = callbacks_.find(callbacks_id); | 628 CallbacksMap::iterator found = callbacks_.find(callbacks_id); |
597 DCHECK(found != callbacks_.end()); | 629 DCHECK(found != callbacks_.end()); |
598 WebFileSystemCallbacksType callbacks = found->second; | 630 WebFileSystemCallbacksType callbacks = found->second; |
599 callbacks_.erase(found); | 631 callbacks_.erase(found); |
600 return callbacks; | 632 return callbacks; |
601 } | 633 } |
602 | 634 |
603 } // namespace content | 635 } // namespace content |
OLD | NEW |