| 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 |
| 19 // static |
| 20 const char ArcFileSystemService::kArcServiceName[] = |
| 21 "arc::ArcFileSystemService"; |
| 22 |
| 18 ArcFileSystemService::ArcFileSystemService(ArcBridgeService* bridge_service) | 23 ArcFileSystemService::ArcFileSystemService(ArcBridgeService* bridge_service) |
| 19 : ArcService(bridge_service) { | 24 : ArcService(bridge_service) { |
| 20 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 25 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 21 | 26 |
| 22 storage::ExternalMountPoints* mount_points = | 27 storage::ExternalMountPoints* mount_points = |
| 23 storage::ExternalMountPoints::GetSystemInstance(); | 28 storage::ExternalMountPoints::GetSystemInstance(); |
| 24 | 29 |
| 25 mount_points->RegisterFileSystem( | 30 mount_points->RegisterFileSystem( |
| 26 kContentFileSystemMountPointName, storage::kFileSystemTypeArcContent, | 31 kContentFileSystemMountPointName, storage::kFileSystemTypeArcContent, |
| 27 storage::FileSystemMountOption(), | 32 storage::FileSystemMountOption(), |
| 28 base::FilePath(kContentFileSystemMountPointPath)); | 33 base::FilePath(kContentFileSystemMountPointPath)); |
| 29 mount_points->RegisterFileSystem( | 34 mount_points->RegisterFileSystem( |
| 30 kDocumentsProviderMountPointName, | 35 kDocumentsProviderMountPointName, |
| 31 storage::kFileSystemTypeArcDocumentsProvider, | 36 storage::kFileSystemTypeArcDocumentsProvider, |
| 32 storage::FileSystemMountOption(), | 37 storage::FileSystemMountOption(), |
| 33 base::FilePath(kDocumentsProviderMountPointPath)); | 38 base::FilePath(kDocumentsProviderMountPointPath)); |
| 39 |
| 40 arc_bridge_service()->file_system()->AddObserver(this); |
| 34 } | 41 } |
| 35 | 42 |
| 36 ArcFileSystemService::~ArcFileSystemService() { | 43 ArcFileSystemService::~ArcFileSystemService() { |
| 37 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 44 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 38 | 45 |
| 46 arc_bridge_service()->file_system()->RemoveObserver(this); |
| 47 |
| 39 storage::ExternalMountPoints* mount_points = | 48 storage::ExternalMountPoints* mount_points = |
| 40 storage::ExternalMountPoints::GetSystemInstance(); | 49 storage::ExternalMountPoints::GetSystemInstance(); |
| 41 | 50 |
| 42 mount_points->RevokeFileSystem(kContentFileSystemMountPointName); | 51 mount_points->RevokeFileSystem(kContentFileSystemMountPointName); |
| 43 mount_points->RevokeFileSystem(kDocumentsProviderMountPointPath); | 52 mount_points->RevokeFileSystem(kDocumentsProviderMountPointPath); |
| 44 } | 53 } |
| 45 | 54 |
| 55 void ArcFileSystemService::AddObserver(ArcFileSystemObserver* observer) { |
| 56 observer_list_.AddObserver(observer); |
| 57 } |
| 58 |
| 59 void ArcFileSystemService::RemoveObserver(ArcFileSystemObserver* observer) { |
| 60 observer_list_.RemoveObserver(observer); |
| 61 } |
| 62 |
| 63 void ArcFileSystemService::OnInstanceReady() { |
| 64 for (auto& observer : observer_list_) |
| 65 observer.OnFileSystemsReady(); |
| 66 } |
| 67 |
| 68 void ArcFileSystemService::OnInstanceClosed() { |
| 69 for (auto& observer : observer_list_) |
| 70 observer.OnFileSystemsClosed(); |
| 71 } |
| 72 |
| 46 } // namespace arc | 73 } // namespace arc |
| OLD | NEW |