OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_CHROMEOS_FILE_MANAGER_VOLUME_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_MANAGER_VOLUME_MANAGER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_FILE_MANAGER_VOLUME_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_FILE_MANAGER_VOLUME_MANAGER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
15 #include "base/prefs/pref_change_registrar.h" | 15 #include "base/prefs/pref_change_registrar.h" |
16 #include "chrome/browser/chromeos/drive/drive_integration_service.h" | 16 #include "chrome/browser/chromeos/drive/drive_integration_service.h" |
17 #include "chrome/browser/chromeos/file_system_provider/observer.h" | |
18 #include "chrome/browser/chromeos/file_system_provider/service.h" | |
17 #include "chrome/browser/local_discovery/storage/privet_volume_lister.h" | 19 #include "chrome/browser/local_discovery/storage/privet_volume_lister.h" |
18 #include "chromeos/dbus/cros_disks_client.h" | 20 #include "chromeos/dbus/cros_disks_client.h" |
19 #include "chromeos/disks/disk_mount_manager.h" | 21 #include "chromeos/disks/disk_mount_manager.h" |
20 #include "components/keyed_service/core/keyed_service.h" | 22 #include "components/keyed_service/core/keyed_service.h" |
21 | 23 |
22 class Profile; | 24 class Profile; |
23 | 25 |
24 namespace chromeos { | 26 namespace chromeos { |
25 class PowerManagerClient; | 27 class PowerManagerClient; |
26 } // namespace chromeos | 28 } // namespace chromeos |
(...skipping 12 matching lines...) Expand all Loading... | |
39 class VolumeManagerObserver; | 41 class VolumeManagerObserver; |
40 | 42 |
41 // This manager manages "Drive" and "Downloads" in addition to disks managed | 43 // This manager manages "Drive" and "Downloads" in addition to disks managed |
42 // by DiskMountManager. | 44 // by DiskMountManager. |
43 enum VolumeType { | 45 enum VolumeType { |
44 VOLUME_TYPE_GOOGLE_DRIVE, | 46 VOLUME_TYPE_GOOGLE_DRIVE, |
45 VOLUME_TYPE_DOWNLOADS_DIRECTORY, | 47 VOLUME_TYPE_DOWNLOADS_DIRECTORY, |
46 VOLUME_TYPE_REMOVABLE_DISK_PARTITION, | 48 VOLUME_TYPE_REMOVABLE_DISK_PARTITION, |
47 VOLUME_TYPE_MOUNTED_ARCHIVE_FILE, | 49 VOLUME_TYPE_MOUNTED_ARCHIVE_FILE, |
48 VOLUME_TYPE_CLOUD_DEVICE, | 50 VOLUME_TYPE_CLOUD_DEVICE, |
51 VOLUME_TYPE_PROVIDED, | |
satorux1
2014/03/26 07:55:37
could you add a comment about the new enum? this o
mtomasz
2014/03/26 09:21:43
Done.
| |
49 VOLUME_TYPE_TESTING | 52 VOLUME_TYPE_TESTING |
50 }; | 53 }; |
51 | 54 |
52 struct VolumeInfo { | 55 struct VolumeInfo { |
53 VolumeInfo(); | 56 VolumeInfo(); |
54 ~VolumeInfo(); | 57 ~VolumeInfo(); |
55 | 58 |
56 // The ID of the volume. | 59 // The ID of the volume. |
57 std::string volume_id; | 60 std::string volume_id; |
58 | 61 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 }; | 96 }; |
94 | 97 |
95 // Manages "Volume"s for file manager. Here are "Volume"s. | 98 // Manages "Volume"s for file manager. Here are "Volume"s. |
96 // - Drive File System (not yet supported). | 99 // - Drive File System (not yet supported). |
97 // - Downloads directory. | 100 // - Downloads directory. |
98 // - Removable disks (volume will be created for each partition, not only one | 101 // - Removable disks (volume will be created for each partition, not only one |
99 // for a device). | 102 // for a device). |
100 // - Mounted zip archives. | 103 // - Mounted zip archives. |
101 class VolumeManager : public KeyedService, | 104 class VolumeManager : public KeyedService, |
102 public drive::DriveIntegrationServiceObserver, | 105 public drive::DriveIntegrationServiceObserver, |
103 public chromeos::disks::DiskMountManager::Observer { | 106 public chromeos::disks::DiskMountManager::Observer, |
107 public chromeos::file_system_provider::Observer { | |
104 public: | 108 public: |
105 VolumeManager(Profile* profile, | 109 VolumeManager( |
106 drive::DriveIntegrationService* drive_integration_service, | 110 Profile* profile, |
107 chromeos::PowerManagerClient* power_manager_client, | 111 drive::DriveIntegrationService* drive_integration_service, |
108 chromeos::disks::DiskMountManager* disk_mount_manager); | 112 chromeos::PowerManagerClient* power_manager_client, |
113 chromeos::disks::DiskMountManager* disk_mount_manager, | |
114 chromeos::file_system_provider::Service* file_system_provider_service); | |
109 virtual ~VolumeManager(); | 115 virtual ~VolumeManager(); |
110 | 116 |
111 // Returns the instance corresponding to the |context|. | 117 // Returns the instance corresponding to the |context|. |
112 static VolumeManager* Get(content::BrowserContext* context); | 118 static VolumeManager* Get(content::BrowserContext* context); |
113 | 119 |
114 // Intializes this instance. | 120 // Intializes this instance. |
115 void Initialize(); | 121 void Initialize(); |
116 | 122 |
117 // Disposes this instance. | 123 // Disposes this instance. |
118 virtual void Shutdown() OVERRIDE; | 124 virtual void Shutdown() OVERRIDE; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 virtual void OnMountEvent( | 161 virtual void OnMountEvent( |
156 chromeos::disks::DiskMountManager::MountEvent event, | 162 chromeos::disks::DiskMountManager::MountEvent event, |
157 chromeos::MountError error_code, | 163 chromeos::MountError error_code, |
158 const chromeos::disks::DiskMountManager::MountPointInfo& mount_info) | 164 const chromeos::disks::DiskMountManager::MountPointInfo& mount_info) |
159 OVERRIDE; | 165 OVERRIDE; |
160 virtual void OnFormatEvent( | 166 virtual void OnFormatEvent( |
161 chromeos::disks::DiskMountManager::FormatEvent event, | 167 chromeos::disks::DiskMountManager::FormatEvent event, |
162 chromeos::FormatError error_code, | 168 chromeos::FormatError error_code, |
163 const std::string& device_path) OVERRIDE; | 169 const std::string& device_path) OVERRIDE; |
164 | 170 |
171 // chromeos::file_system_provider::Observer overrides. | |
172 virtual void OnProvidedFileSystemRegistered( | |
173 const chromeos::file_system_provider::ProvidedFileSystem& file_system) | |
174 OVERRIDE; | |
175 virtual void OnProvidedFileSystemUnregistered( | |
176 const chromeos::file_system_provider::ProvidedFileSystem& file_system) | |
177 OVERRIDE; | |
178 | |
165 // Called on change to kExternalStorageDisabled pref. | 179 // Called on change to kExternalStorageDisabled pref. |
166 void OnExternalStorageDisabledChanged(); | 180 void OnExternalStorageDisabledChanged(); |
167 | 181 |
168 private: | 182 private: |
169 void OnPrivetVolumesAvailable( | 183 void OnPrivetVolumesAvailable( |
170 const local_discovery::PrivetVolumeLister::VolumeList& volumes); | 184 const local_discovery::PrivetVolumeLister::VolumeList& volumes); |
171 void DoMountEvent(chromeos::MountError error_code, | 185 void DoMountEvent(chromeos::MountError error_code, |
172 const VolumeInfo& volume_info, | 186 const VolumeInfo& volume_info, |
173 bool is_remounting); | 187 bool is_remounting); |
174 void DoUnmountEvent(chromeos::MountError error_code, | 188 void DoUnmountEvent(chromeos::MountError error_code, |
175 const VolumeInfo& volume_info); | 189 const VolumeInfo& volume_info); |
176 | 190 |
177 Profile* profile_; | 191 Profile* profile_; |
178 drive::DriveIntegrationService* drive_integration_service_; | 192 drive::DriveIntegrationService* drive_integration_service_; |
179 chromeos::disks::DiskMountManager* disk_mount_manager_; | 193 chromeos::disks::DiskMountManager* disk_mount_manager_; |
180 scoped_ptr<MountedDiskMonitor> mounted_disk_monitor_; | 194 scoped_ptr<MountedDiskMonitor> mounted_disk_monitor_; |
181 PrefChangeRegistrar pref_change_registrar_; | 195 PrefChangeRegistrar pref_change_registrar_; |
182 ObserverList<VolumeManagerObserver> observers_; | 196 ObserverList<VolumeManagerObserver> observers_; |
183 scoped_ptr<local_discovery::PrivetVolumeLister> privet_volume_lister_; | 197 scoped_ptr<local_discovery::PrivetVolumeLister> privet_volume_lister_; |
198 chromeos::file_system_provider::Service* file_system_provider_service_; | |
satorux1
2014/03/26 07:55:37
Please add a comment about who owns this object.
mtomasz
2014/03/26 09:21:43
It is owned very deeply by BrowserContextKeyedServ
satorux1
2014/03/27 04:38:55
Thanks. I was interested in whether or not if this
mtomasz
2014/03/27 04:43:33
Done.
| |
184 | 199 |
185 std::map<std::string, VolumeInfo> mounted_volumes_; | 200 std::map<std::string, VolumeInfo> mounted_volumes_; |
186 | 201 |
187 DISALLOW_COPY_AND_ASSIGN(VolumeManager); | 202 DISALLOW_COPY_AND_ASSIGN(VolumeManager); |
188 }; | 203 }; |
189 | 204 |
190 } // namespace file_manager | 205 } // namespace file_manager |
191 | 206 |
192 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_VOLUME_MANAGER_H_ | 207 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_VOLUME_MANAGER_H_ |
OLD | NEW |