| 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 unit tests. | 5 // MediaFileSystemRegistry unit tests. |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 explicit TestMediaFileSystemContext(MediaFileSystemRegistry* registry); | 55 explicit TestMediaFileSystemContext(MediaFileSystemRegistry* registry); |
| 56 virtual ~TestMediaFileSystemContext() {} | 56 virtual ~TestMediaFileSystemContext() {} |
| 57 | 57 |
| 58 // MediaFileSystemContext implementation. | 58 // MediaFileSystemContext implementation. |
| 59 virtual std::string RegisterFileSystemForMassStorage( | 59 virtual std::string RegisterFileSystemForMassStorage( |
| 60 const std::string& device_id, const FilePath& path) OVERRIDE; | 60 const std::string& device_id, const FilePath& path) OVERRIDE; |
| 61 | 61 |
| 62 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) | 62 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) |
| 63 virtual std::string RegisterFileSystemForMTPDevice( | 63 virtual std::string RegisterFileSystemForMTPDevice( |
| 64 const std::string& device_id, const FilePath& path, | 64 const std::string& device_id, const FilePath& path, |
| 65 scoped_refptr<ScopedMTPDeviceMapEntry>* entry) OVERRIDE; | 65 const ExtensionGalleriesHost* galleries_host) OVERRIDE; |
| 66 |
| 67 virtual void RemoveMTPDeviceReferenceForHost( |
| 68 const std::string& device_location, |
| 69 const chrome::ExtensionGalleriesHost* galleries_host) OVERRIDE; |
| 66 #endif | 70 #endif |
| 67 | 71 |
| 68 virtual void RevokeFileSystem(const std::string& fsid) OVERRIDE; | 72 virtual void RevokeFileSystem(const std::string& fsid) OVERRIDE; |
| 69 | 73 |
| 70 private: | 74 private: |
| 71 std::string AddFSEntry(const std::string& device_id, const FilePath& path); | 75 std::string AddFSEntry(const std::string& device_id, const FilePath& path); |
| 72 | 76 |
| 73 MediaFileSystemRegistry* registry_; | 77 MediaFileSystemRegistry* registry_; |
| 74 | 78 |
| 75 // A counter used to construct mock FSIDs. | 79 // A counter used to construct mock FSIDs. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 104 | 108 |
| 105 std::string TestMediaFileSystemContext::RegisterFileSystemForMassStorage( | 109 std::string TestMediaFileSystemContext::RegisterFileSystemForMassStorage( |
| 106 const std::string& device_id, const FilePath& path) { | 110 const std::string& device_id, const FilePath& path) { |
| 107 CHECK(MediaStorageUtil::IsMassStorageDevice(device_id)); | 111 CHECK(MediaStorageUtil::IsMassStorageDevice(device_id)); |
| 108 return AddFSEntry(device_id, path); | 112 return AddFSEntry(device_id, path); |
| 109 } | 113 } |
| 110 | 114 |
| 111 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) | 115 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) |
| 112 std::string TestMediaFileSystemContext::RegisterFileSystemForMTPDevice( | 116 std::string TestMediaFileSystemContext::RegisterFileSystemForMTPDevice( |
| 113 const std::string& device_id, const FilePath& path, | 117 const std::string& device_id, const FilePath& path, |
| 114 scoped_refptr<ScopedMTPDeviceMapEntry>* entry) { | 118 const ExtensionGalleriesHost* galleries_host) { |
| 115 CHECK(!MediaStorageUtil::IsMassStorageDevice(device_id)); | 119 CHECK(!MediaStorageUtil::IsMassStorageDevice(device_id)); |
| 116 DCHECK(entry); | 120 registry_->AddGalleriesHostReferenceForMTPDevice(path.value(), |
| 117 *entry = registry_->GetOrCreateScopedMTPDeviceMapEntry(path.value()); | 121 galleries_host); |
| 118 return AddFSEntry(device_id, path); | 122 return AddFSEntry(device_id, path); |
| 119 } | 123 } |
| 124 |
| 125 void TestMediaFileSystemContext::RemoveMTPDeviceReferenceForHost( |
| 126 const std::string& device_location, |
| 127 const chrome::ExtensionGalleriesHost* galleries_host) { |
| 128 registry_->RemoveGalleriesHostReferenceForMTPDevice(device_location, |
| 129 galleries_host); |
| 130 } |
| 120 #endif | 131 #endif |
| 121 | 132 |
| 122 void TestMediaFileSystemContext::RevokeFileSystem(const std::string& fsid) { | 133 void TestMediaFileSystemContext::RevokeFileSystem(const std::string& fsid) { |
| 123 if (!ContainsKey(file_systems_by_id_, fsid)) | 134 if (!ContainsKey(file_systems_by_id_, fsid)) |
| 124 return; | 135 return; |
| 125 EXPECT_EQ(1U, file_systems_by_id_.erase(fsid)); | 136 EXPECT_EQ(1U, file_systems_by_id_.erase(fsid)); |
| 126 } | 137 } |
| 127 | 138 |
| 128 std::string TestMediaFileSystemContext::AddFSEntry(const std::string& device_id, | 139 std::string TestMediaFileSystemContext::AddFSEntry(const std::string& device_id, |
| 129 const FilePath& path) { | 140 const FilePath& path) { |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 SetGalleryPermission(0, GetProfileState(0)->all_permission_extension(), | 640 SetGalleryPermission(0, GetProfileState(0)->all_permission_extension(), |
| 630 device_id, true /*has access*/); | 641 device_id, true /*has access*/); |
| 631 auto_galleries.push_back(added_info); | 642 auto_galleries.push_back(added_info); |
| 632 GetProfileState(0)->CheckGalleries("user added all", added_galleries, | 643 GetProfileState(0)->CheckGalleries("user added all", added_galleries, |
| 633 auto_galleries); | 644 auto_galleries); |
| 634 } | 645 } |
| 635 | 646 |
| 636 } // namespace | 647 } // namespace |
| 637 | 648 |
| 638 } // namespace chrome | 649 } // namespace chrome |
| OLD | NEW |