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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 void OpenFileSystemCallbackAdapter( | 147 void OpenFileSystemCallbackAdapter( |
148 int thread_id, int callbacks_id, | 148 int thread_id, int callbacks_id, |
149 WaitableCallbackResults* waitable_results, | 149 WaitableCallbackResults* waitable_results, |
150 const std::string& name, const GURL& root) { | 150 const std::string& name, const GURL& root) { |
151 CallbackFileSystemCallbacks( | 151 CallbackFileSystemCallbacks( |
152 thread_id, callbacks_id, waitable_results, | 152 thread_id, callbacks_id, waitable_results, |
153 &WebFileSystemCallbacks::didOpenFileSystem, | 153 &WebFileSystemCallbacks::didOpenFileSystem, |
154 MakeTuple(UTF8ToUTF16(name), root)); | 154 MakeTuple(UTF8ToUTF16(name), root)); |
155 } | 155 } |
156 | 156 |
| 157 void ResolveURLCallbackAdapter( |
| 158 int thread_id, int callbacks_id, |
| 159 WaitableCallbackResults* waitable_results, |
| 160 const fileapi::FileSystemInfo& info, |
| 161 const base::FilePath& file_path, bool is_directory) { |
| 162 CallbackFileSystemCallbacks( |
| 163 thread_id, callbacks_id, waitable_results, |
| 164 &WebFileSystemCallbacks::didResolveURL, |
| 165 MakeTuple(UTF8ToUTF16(info.name), info.root_url, |
| 166 static_cast<WebKit::WebFileSystemType>(info.mount_type), |
| 167 file_path.AsUTF16Unsafe(), is_directory)); |
| 168 } |
| 169 |
157 void StatusCallbackAdapter(int thread_id, int callbacks_id, | 170 void StatusCallbackAdapter(int thread_id, int callbacks_id, |
158 WaitableCallbackResults* waitable_results, | 171 WaitableCallbackResults* waitable_results, |
159 base::PlatformFileError error) { | 172 base::PlatformFileError error) { |
160 if (error == base::PLATFORM_FILE_OK) { | 173 if (error == base::PLATFORM_FILE_OK) { |
161 CallbackFileSystemCallbacks( | 174 CallbackFileSystemCallbacks( |
162 thread_id, callbacks_id, waitable_results, | 175 thread_id, callbacks_id, waitable_results, |
163 &WebFileSystemCallbacks::didSucceed, MakeTuple()); | 176 &WebFileSystemCallbacks::didSucceed, MakeTuple()); |
164 } else { | 177 } else { |
165 CallbackFileSystemCallbacks( | 178 CallbackFileSystemCallbacks( |
166 thread_id, callbacks_id, waitable_results, | 179 thread_id, callbacks_id, waitable_results, |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 0 /* size (not used) */, create, | 338 0 /* size (not used) */, create, |
326 base::Bind(&OpenFileSystemCallbackAdapter, | 339 base::Bind(&OpenFileSystemCallbackAdapter, |
327 CurrentWorkerId(), callbacks_id, | 340 CurrentWorkerId(), callbacks_id, |
328 base::Unretained(waitable_results)), | 341 base::Unretained(waitable_results)), |
329 base::Bind(&StatusCallbackAdapter, | 342 base::Bind(&StatusCallbackAdapter, |
330 CurrentWorkerId(), callbacks_id, | 343 CurrentWorkerId(), callbacks_id, |
331 base::Unretained(waitable_results))), | 344 base::Unretained(waitable_results))), |
332 make_scoped_ptr(waitable_results)); | 345 make_scoped_ptr(waitable_results)); |
333 } | 346 } |
334 | 347 |
| 348 void WebFileSystemImpl::resolveURL( |
| 349 const WebKit::WebURL& filesystem_url, |
| 350 WebFileSystemCallbacks callbacks) { |
| 351 int callbacks_id = RegisterCallbacks(callbacks); |
| 352 WaitableCallbackResults* waitable_results = |
| 353 WaitableCallbackResults::MaybeCreate(callbacks); |
| 354 CallDispatcherOnMainThread( |
| 355 main_thread_loop_.get(), |
| 356 &FileSystemDispatcher::ResolveURL, |
| 357 MakeTuple(GURL(filesystem_url), |
| 358 base::Bind(&ResolveURLCallbackAdapter, |
| 359 CurrentWorkerId(), callbacks_id, |
| 360 base::Unretained(waitable_results)), |
| 361 base::Bind(&StatusCallbackAdapter, |
| 362 CurrentWorkerId(), callbacks_id, |
| 363 base::Unretained(waitable_results))), |
| 364 make_scoped_ptr(waitable_results)); |
| 365 } |
| 366 |
335 void WebFileSystemImpl::deleteFileSystem( | 367 void WebFileSystemImpl::deleteFileSystem( |
336 const WebKit::WebURL& storage_partition, | 368 const WebKit::WebURL& storage_partition, |
337 WebKit::WebFileSystemType type, | 369 WebKit::WebFileSystemType type, |
338 WebFileSystemCallbacks callbacks) { | 370 WebFileSystemCallbacks callbacks) { |
339 int callbacks_id = RegisterCallbacks(callbacks); | 371 int callbacks_id = RegisterCallbacks(callbacks); |
340 WaitableCallbackResults* waitable_results = | 372 WaitableCallbackResults* waitable_results = |
341 WaitableCallbackResults::MaybeCreate(callbacks); | 373 WaitableCallbackResults::MaybeCreate(callbacks); |
342 CallDispatcherOnMainThread( | 374 CallDispatcherOnMainThread( |
343 main_thread_loop_.get(), | 375 main_thread_loop_.get(), |
344 &FileSystemDispatcher::DeleteFileSystem, | 376 &FileSystemDispatcher::DeleteFileSystem, |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 WebFileSystemCallbacks callbacks) { | 506 WebFileSystemCallbacks callbacks) { |
475 int callbacks_id = RegisterCallbacks(callbacks); | 507 int callbacks_id = RegisterCallbacks(callbacks); |
476 WaitableCallbackResults* waitable_results = | 508 WaitableCallbackResults* waitable_results = |
477 WaitableCallbackResults::MaybeCreate(callbacks); | 509 WaitableCallbackResults::MaybeCreate(callbacks); |
478 CallDispatcherOnMainThread( | 510 CallDispatcherOnMainThread( |
479 main_thread_loop_.get(), | 511 main_thread_loop_.get(), |
480 &FileSystemDispatcher::Exists, | 512 &FileSystemDispatcher::Exists, |
481 MakeTuple(GURL(path), false /* directory */, | 513 MakeTuple(GURL(path), false /* directory */, |
482 base::Bind(&StatusCallbackAdapter, | 514 base::Bind(&StatusCallbackAdapter, |
483 CurrentWorkerId(), callbacks_id, | 515 CurrentWorkerId(), callbacks_id, |
484 base::Unretained(waitable_results))), | 516 base::Unretained(waitable_results))), |
485 make_scoped_ptr(waitable_results)); | 517 make_scoped_ptr(waitable_results)); |
486 } | 518 } |
487 | 519 |
488 void WebFileSystemImpl::directoryExists( | 520 void WebFileSystemImpl::directoryExists( |
489 const WebKit::WebURL& path, | 521 const WebKit::WebURL& path, |
490 WebFileSystemCallbacks callbacks) { | 522 WebFileSystemCallbacks callbacks) { |
491 int callbacks_id = RegisterCallbacks(callbacks); | 523 int callbacks_id = RegisterCallbacks(callbacks); |
492 WaitableCallbackResults* waitable_results = | 524 WaitableCallbackResults* waitable_results = |
493 WaitableCallbackResults::MaybeCreate(callbacks); | 525 WaitableCallbackResults::MaybeCreate(callbacks); |
494 CallDispatcherOnMainThread( | 526 CallDispatcherOnMainThread( |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 int callbacks_id) { | 605 int callbacks_id) { |
574 DCHECK(CalledOnValidThread()); | 606 DCHECK(CalledOnValidThread()); |
575 CallbacksMap::iterator found = callbacks_.find(callbacks_id); | 607 CallbacksMap::iterator found = callbacks_.find(callbacks_id); |
576 DCHECK(found != callbacks_.end()); | 608 DCHECK(found != callbacks_.end()); |
577 WebFileSystemCallbacks callbacks = found->second; | 609 WebFileSystemCallbacks callbacks = found->second; |
578 callbacks_.erase(found); | 610 callbacks_.erase(found); |
579 return callbacks; | 611 return callbacks; |
580 } | 612 } |
581 | 613 |
582 } // namespace content | 614 } // namespace content |
OLD | NEW |