Chromium Code Reviews| 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 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 555 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 555 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 556 DCHECK(StorageInfo::IsMassStorageDevice(device_id)); | 556 DCHECK(StorageInfo::IsMassStorageDevice(device_id)); |
| 557 | 557 |
| 558 // Sanity checks for |path|. | 558 // Sanity checks for |path|. |
| 559 CHECK(path.IsAbsolute()); | 559 CHECK(path.IsAbsolute()); |
| 560 CHECK(!path.ReferencesParent()); | 560 CHECK(!path.ReferencesParent()); |
| 561 std::string fs_name(extension_misc::kMediaFileSystemPathPart); | 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 { |
| 570 fsid = IsolatedContext::GetInstance()->RegisterFileSystemForPath( | 574 fsid = IsolatedContext::GetInstance()->RegisterFileSystemForPath( |
| 571 fileapi::kFileSystemTypeNativeMedia, path, &fs_name); | 575 fileapi::kFileSystemTypeNativeMedia, path, &fs_name); |
| 572 } | 576 } |
| 573 | 577 |
| 574 CHECK(!fsid.empty()); | 578 CHECK(!fsid.empty()); |
| 575 return fsid; | 579 return fsid; |
| 576 } | 580 } |
| 577 | 581 |
| 578 virtual std::string RegisterFileSystemForMTPDevice( | 582 virtual std::string RegisterFileSystemForMTPDevice( |
| 579 const std::string& device_id, const base::FilePath& path, | 583 const std::string& device_id, const base::FilePath& path, |
| 580 scoped_refptr<ScopedMTPDeviceMapEntry>* entry) OVERRIDE { | 584 scoped_refptr<ScopedMTPDeviceMapEntry>* entry) OVERRIDE { |
| 581 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 585 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 582 DCHECK(!StorageInfo::IsMassStorageDevice(device_id)); | 586 DCHECK(!StorageInfo::IsMassStorageDevice(device_id)); |
| 583 | 587 |
| 584 // Sanity checks for |path|. | 588 // Sanity checks for |path|. |
| 585 CHECK(MediaStorageUtil::CanCreateFileSystem(device_id, path)); | 589 CHECK(MediaStorageUtil::CanCreateFileSystem(device_id, path)); |
| 586 std::string fs_name(extension_misc::kMediaFileSystemPathPart); | 590 std::string fs_name(extension_misc::kMediaFileSystemPathPart); |
| 587 const std::string fsid = | 591 const std::string fsid = |
| 588 IsolatedContext::GetInstance()->RegisterFileSystemForPath( | 592 IsolatedContext::GetInstance()->RegisterFileSystemForPath( |
| 589 fileapi::kFileSystemTypeDeviceMedia, path, &fs_name); | 593 fileapi::kFileSystemTypeDeviceMedia, path, &fs_name); |
| 590 CHECK(!fsid.empty()); | 594 CHECK(!fsid.empty()); |
| 591 DCHECK(entry); | 595 DCHECK(entry); |
| 592 *entry = registry_->GetOrCreateScopedMTPDeviceMapEntry(path.value()); | 596 *entry = registry_->GetOrCreateScopedMTPDeviceMapEntry(path.value()); |
| 593 return fsid; | 597 return fsid; |
| 594 } | 598 } |
| 595 | 599 |
| 596 virtual void RevokeFileSystem(const std::string& fsid) OVERRIDE { | 600 virtual void RevokeFileSystem(const std::string& fsid) OVERRIDE { |
| 601 ImportedMediaGalleryRegistry* imported_registry = | |
| 602 ImportedMediaGalleryRegistry::GetInstance(); | |
| 603 if (imported_registry->RevokeImportedFilesystemOnUIThread(fsid)) | |
| 604 return; | |
| 605 | |
| 597 IsolatedContext::GetInstance()->RevokeFileSystem(fsid); | 606 IsolatedContext::GetInstance()->RevokeFileSystem(fsid); |
|
vandebo (ex-Chrome)
2013/06/05 22:49:32
This was a bug, we never tried to unregister picas
| |
| 598 } | 607 } |
| 599 | 608 |
| 600 private: | 609 private: |
| 601 MediaFileSystemRegistry* registry_; | 610 MediaFileSystemRegistry* registry_; |
| 602 | 611 |
| 603 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemContextImpl); | 612 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemContextImpl); |
| 604 }; | 613 }; |
| 605 | 614 |
| 606 MediaFileSystemRegistry::MediaFileSystemRegistry() | 615 MediaFileSystemRegistry::MediaFileSystemRegistry() |
| 607 : file_system_context_(new MediaFileSystemContextImpl(this)) { | 616 : file_system_context_(new MediaFileSystemContextImpl(this)) { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 706 // previously used. | 715 // previously used. |
| 707 PrefChangeRegistrarMap::iterator pref_it = | 716 PrefChangeRegistrarMap::iterator pref_it = |
| 708 pref_change_registrar_map_.find(profile); | 717 pref_change_registrar_map_.find(profile); |
| 709 DCHECK(pref_it != pref_change_registrar_map_.end()); | 718 DCHECK(pref_it != pref_change_registrar_map_.end()); |
| 710 delete pref_it->second; | 719 delete pref_it->second; |
| 711 pref_change_registrar_map_.erase(pref_it); | 720 pref_change_registrar_map_.erase(pref_it); |
| 712 } | 721 } |
| 713 } | 722 } |
| 714 | 723 |
| 715 } // namespace chrome | 724 } // namespace chrome |
| OLD | NEW |