| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/chromeos/arc/fileapi/arc_file_system_service.h" | 5 #include "chrome/browser/chromeos/arc/fileapi/arc_file_system_service.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "chrome/browser/chromeos/arc/fileapi/arc_content_file_system_url_util.h
" | 8 #include "chrome/browser/chromeos/arc/fileapi/arc_content_file_system_url_util.h
" |
| 9 #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.h" | 9 #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.h" |
| 10 #include "components/arc/arc_bridge_service.h" | 10 #include "components/arc/arc_bridge_service.h" |
| 11 #include "components/arc/file_system/arc_file_system_observer.h" |
| 11 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 12 #include "storage/browser/fileapi/external_mount_points.h" | 13 #include "storage/browser/fileapi/external_mount_points.h" |
| 13 | 14 |
| 14 using content::BrowserThread; | 15 using content::BrowserThread; |
| 15 | 16 |
| 16 namespace arc { | 17 namespace arc { |
| 17 | 18 |
| 18 ArcFileSystemService::ArcFileSystemService(ArcBridgeService* bridge_service) | 19 ArcFileSystemService::ArcFileSystemService(ArcBridgeService* bridge_service) |
| 19 : ArcService(bridge_service) { | 20 : ArcService(bridge_service) { |
| 20 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 21 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 21 | 22 |
| 22 storage::ExternalMountPoints* mount_points = | 23 storage::ExternalMountPoints* mount_points = |
| 23 storage::ExternalMountPoints::GetSystemInstance(); | 24 storage::ExternalMountPoints::GetSystemInstance(); |
| 24 | 25 |
| 25 mount_points->RegisterFileSystem( | 26 mount_points->RegisterFileSystem( |
| 26 kContentFileSystemMountPointName, storage::kFileSystemTypeArcContent, | 27 kContentFileSystemMountPointName, storage::kFileSystemTypeArcContent, |
| 27 storage::FileSystemMountOption(), | 28 storage::FileSystemMountOption(), |
| 28 base::FilePath(kContentFileSystemMountPointPath)); | 29 base::FilePath(kContentFileSystemMountPointPath)); |
| 29 mount_points->RegisterFileSystem( | 30 mount_points->RegisterFileSystem( |
| 30 kDocumentsProviderMountPointName, | 31 kDocumentsProviderMountPointName, |
| 31 storage::kFileSystemTypeArcDocumentsProvider, | 32 storage::kFileSystemTypeArcDocumentsProvider, |
| 32 storage::FileSystemMountOption(), | 33 storage::FileSystemMountOption(), |
| 33 base::FilePath(kDocumentsProviderMountPointPath)); | 34 base::FilePath(kDocumentsProviderMountPointPath)); |
| 35 |
| 36 arc_bridge_service()->file_system()->AddObserver(this); |
| 34 } | 37 } |
| 35 | 38 |
| 36 ArcFileSystemService::~ArcFileSystemService() { | 39 ArcFileSystemService::~ArcFileSystemService() { |
| 37 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 40 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 38 | 41 |
| 42 arc_bridge_service()->file_system()->RemoveObserver(this); |
| 43 |
| 39 storage::ExternalMountPoints* mount_points = | 44 storage::ExternalMountPoints* mount_points = |
| 40 storage::ExternalMountPoints::GetSystemInstance(); | 45 storage::ExternalMountPoints::GetSystemInstance(); |
| 41 | 46 |
| 42 mount_points->RevokeFileSystem(kContentFileSystemMountPointName); | 47 mount_points->RevokeFileSystem(kContentFileSystemMountPointName); |
| 43 mount_points->RevokeFileSystem(kDocumentsProviderMountPointPath); | 48 mount_points->RevokeFileSystem(kDocumentsProviderMountPointPath); |
| 44 } | 49 } |
| 45 | 50 |
| 51 void ArcFileSystemService::AddObserver(ArcFileSystemObserver* observer) { |
| 52 observer_list_.AddObserver(observer); |
| 53 } |
| 54 |
| 55 void ArcFileSystemService::RemoveObserver(ArcFileSystemObserver* observer) { |
| 56 observer_list_.RemoveObserver(observer); |
| 57 } |
| 58 |
| 59 void ArcFileSystemService::OnInstanceReady() { |
| 60 for (auto& observer : observer_list_) |
| 61 observer.OnFileSystemsReady(); |
| 62 } |
| 63 |
| 46 } // namespace arc | 64 } // namespace arc |
| OLD | NEW |