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