OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // MediaFileSystemRegistry implementation. | 5 // MediaFileSystemRegistry implementation. |
6 | 6 |
7 #include "chrome/browser/media_galleries/media_file_system_registry.h" | 7 #include "chrome/browser/media_galleries/media_file_system_registry.h" |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 if (StorageInfo::IsMassStorageDevice(device_id)) { | 330 if (StorageInfo::IsMassStorageDevice(device_id)) { |
331 fsid = file_system_context_->RegisterFileSystemForMassStorage( | 331 fsid = file_system_context_->RegisterFileSystemForMassStorage( |
332 device_id, path); | 332 device_id, path); |
333 } else { | 333 } else { |
334 scoped_refptr<ScopedMTPDeviceMapEntry> mtp_device_host; | 334 scoped_refptr<ScopedMTPDeviceMapEntry> mtp_device_host; |
335 fsid = file_system_context_->RegisterFileSystemForMTPDevice( | 335 fsid = file_system_context_->RegisterFileSystemForMTPDevice( |
336 device_id, path, &mtp_device_host); | 336 device_id, path, &mtp_device_host); |
337 DCHECK(mtp_device_host.get()); | 337 DCHECK(mtp_device_host.get()); |
338 media_device_map_references_[pref_id] = mtp_device_host; | 338 media_device_map_references_[pref_id] = mtp_device_host; |
339 } | 339 } |
340 DCHECK(!fsid.empty()); | 340 if (fsid.empty()) |
| 341 continue; |
341 | 342 |
342 MediaFileSystemInfo new_entry( | 343 MediaFileSystemInfo new_entry( |
343 MediaGalleriesDialogController::GetGalleryDisplayNameNoAttachment( | 344 MediaGalleriesDialogController::GetGalleryDisplayNameNoAttachment( |
344 gallery_info), | 345 gallery_info), |
345 path, | 346 path, |
346 fsid, | 347 fsid, |
347 pref_id, | 348 pref_id, |
348 GetTransientIdForRemovableDeviceId(device_id), | 349 GetTransientIdForRemovableDeviceId(device_id), |
349 StorageInfo::IsRemovableDevice(device_id), | 350 StorageInfo::IsRemovableDevice(device_id), |
350 StorageInfo::IsMediaDevice(device_id)); | 351 StorageInfo::IsMediaDevice(device_id)); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 // Registers and returns the file system id for the mass storage device | 552 // Registers and returns the file system id for the mass storage device |
552 // specified by |device_id| and |path|. | 553 // specified by |device_id| and |path|. |
553 virtual std::string RegisterFileSystemForMassStorage( | 554 virtual std::string RegisterFileSystemForMassStorage( |
554 const std::string& device_id, const base::FilePath& path) OVERRIDE { | 555 const std::string& device_id, const base::FilePath& path) OVERRIDE { |
555 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 556 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
556 DCHECK(StorageInfo::IsMassStorageDevice(device_id)); | 557 DCHECK(StorageInfo::IsMassStorageDevice(device_id)); |
557 | 558 |
558 // Sanity checks for |path|. | 559 // Sanity checks for |path|. |
559 CHECK(path.IsAbsolute()); | 560 CHECK(path.IsAbsolute()); |
560 CHECK(!path.ReferencesParent()); | 561 CHECK(!path.ReferencesParent()); |
561 std::string fs_name(extension_misc::kMediaFileSystemPathPart); | |
562 | 562 |
563 std::string fsid; | 563 std::string fsid; |
564 if (StorageInfo::IsITunesDevice(device_id)) { | 564 if (StorageInfo::IsITunesDevice(device_id)) { |
565 NOTIMPLEMENTED(); | 565 ImportedMediaGalleryRegistry* imported_registry = |
| 566 ImportedMediaGalleryRegistry::GetInstance(); |
| 567 fsid = imported_registry->RegisterITunesFilesystemOnUIThread(path); |
566 } else if (StorageInfo::IsPicasaDevice(device_id)) { | 568 } else if (StorageInfo::IsPicasaDevice(device_id)) { |
567 fsid = ImportedMediaGalleryRegistry::RegisterPicasaFilesystemOnUIThread( | 569 ImportedMediaGalleryRegistry* imported_registry = |
| 570 ImportedMediaGalleryRegistry::GetInstance(); |
| 571 fsid = imported_registry->RegisterPicasaFilesystemOnUIThread( |
568 path); | 572 path); |
569 } else { | 573 } else { |
| 574 std::string fs_name(extension_misc::kMediaFileSystemPathPart); |
570 fsid = IsolatedContext::GetInstance()->RegisterFileSystemForPath( | 575 fsid = IsolatedContext::GetInstance()->RegisterFileSystemForPath( |
571 fileapi::kFileSystemTypeNativeMedia, path, &fs_name); | 576 fileapi::kFileSystemTypeNativeMedia, path, &fs_name); |
572 } | 577 } |
573 | |
574 CHECK(!fsid.empty()); | |
575 return fsid; | 578 return fsid; |
576 } | 579 } |
577 | 580 |
578 virtual std::string RegisterFileSystemForMTPDevice( | 581 virtual std::string RegisterFileSystemForMTPDevice( |
579 const std::string& device_id, const base::FilePath& path, | 582 const std::string& device_id, const base::FilePath& path, |
580 scoped_refptr<ScopedMTPDeviceMapEntry>* entry) OVERRIDE { | 583 scoped_refptr<ScopedMTPDeviceMapEntry>* entry) OVERRIDE { |
581 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 584 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
582 DCHECK(!StorageInfo::IsMassStorageDevice(device_id)); | 585 DCHECK(!StorageInfo::IsMassStorageDevice(device_id)); |
583 | 586 |
584 // Sanity checks for |path|. | 587 // Sanity checks for |path|. |
585 CHECK(MediaStorageUtil::CanCreateFileSystem(device_id, path)); | 588 CHECK(MediaStorageUtil::CanCreateFileSystem(device_id, path)); |
586 std::string fs_name(extension_misc::kMediaFileSystemPathPart); | 589 std::string fs_name(extension_misc::kMediaFileSystemPathPart); |
587 const std::string fsid = | 590 const std::string fsid = |
588 IsolatedContext::GetInstance()->RegisterFileSystemForPath( | 591 IsolatedContext::GetInstance()->RegisterFileSystemForPath( |
589 fileapi::kFileSystemTypeDeviceMedia, path, &fs_name); | 592 fileapi::kFileSystemTypeDeviceMedia, path, &fs_name); |
590 CHECK(!fsid.empty()); | 593 CHECK(!fsid.empty()); |
591 DCHECK(entry); | 594 DCHECK(entry); |
592 *entry = registry_->GetOrCreateScopedMTPDeviceMapEntry(path.value()); | 595 *entry = registry_->GetOrCreateScopedMTPDeviceMapEntry(path.value()); |
593 return fsid; | 596 return fsid; |
594 } | 597 } |
595 | 598 |
596 virtual void RevokeFileSystem(const std::string& fsid) OVERRIDE { | 599 virtual void RevokeFileSystem(const std::string& fsid) OVERRIDE { |
| 600 ImportedMediaGalleryRegistry* imported_registry = |
| 601 ImportedMediaGalleryRegistry::GetInstance(); |
| 602 if (imported_registry->RevokeImportedFilesystemOnUIThread(fsid)) |
| 603 return; |
| 604 |
597 IsolatedContext::GetInstance()->RevokeFileSystem(fsid); | 605 IsolatedContext::GetInstance()->RevokeFileSystem(fsid); |
598 } | 606 } |
599 | 607 |
600 private: | 608 private: |
601 MediaFileSystemRegistry* registry_; | 609 MediaFileSystemRegistry* registry_; |
602 | 610 |
603 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemContextImpl); | 611 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemContextImpl); |
604 }; | 612 }; |
605 | 613 |
606 MediaFileSystemRegistry::MediaFileSystemRegistry() | 614 MediaFileSystemRegistry::MediaFileSystemRegistry() |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 // previously used. | 714 // previously used. |
707 PrefChangeRegistrarMap::iterator pref_it = | 715 PrefChangeRegistrarMap::iterator pref_it = |
708 pref_change_registrar_map_.find(profile); | 716 pref_change_registrar_map_.find(profile); |
709 DCHECK(pref_it != pref_change_registrar_map_.end()); | 717 DCHECK(pref_it != pref_change_registrar_map_.end()); |
710 delete pref_it->second; | 718 delete pref_it->second; |
711 pref_change_registrar_map_.erase(pref_it); | 719 pref_change_registrar_map_.erase(pref_it); |
712 } | 720 } |
713 } | 721 } |
714 | 722 |
715 } // namespace chrome | 723 } // namespace chrome |
OLD | NEW |