Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: chrome/browser/chromeos/file_manager/volume_manager.h

Issue 2707193005: Some linked_ptr removal in chromeos file_browser_handler. (Closed)
Patch Set: sync Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/files/file.h" 14 #include "base/files/file.h"
15 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/linked_ptr.h"
18 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
19 #include "base/observer_list.h" 18 #include "base/observer_list.h"
20 #include "chrome/browser/chromeos/arc/arc_session_manager.h" 19 #include "chrome/browser/chromeos/arc/arc_session_manager.h"
21 #include "chrome/browser/chromeos/drive/drive_integration_service.h" 20 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
22 #include "chrome/browser/chromeos/file_system_provider/observer.h" 21 #include "chrome/browser/chromeos/file_system_provider/observer.h"
23 #include "chrome/browser/chromeos/file_system_provider/service.h" 22 #include "chrome/browser/chromeos/file_system_provider/service.h"
24 #include "chromeos/dbus/cros_disks_client.h" 23 #include "chromeos/dbus/cros_disks_client.h"
25 #include "chromeos/disks/disk_mount_manager.h" 24 #include "chromeos/disks/disk_mount_manager.h"
26 #include "components/keyed_service/core/keyed_service.h" 25 #include "components/keyed_service/core/keyed_service.h"
27 #include "components/prefs/pref_change_registrar.h" 26 #include "components/prefs/pref_change_registrar.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 enum Source { SOURCE_FILE, SOURCE_DEVICE, SOURCE_NETWORK, SOURCE_SYSTEM }; 72 enum Source { SOURCE_FILE, SOURCE_DEVICE, SOURCE_NETWORK, SOURCE_SYSTEM };
74 73
75 // Represents a volume (mount point) in the volume manager. Validity of the data 74 // Represents a volume (mount point) in the volume manager. Validity of the data
76 // is guaranteed by the weak pointer. Simply saying, the weak pointer should be 75 // is guaranteed by the weak pointer. Simply saying, the weak pointer should be
77 // valid as long as the volume is mounted. 76 // valid as long as the volume is mounted.
78 class Volume : public base::SupportsWeakPtr<Volume> { 77 class Volume : public base::SupportsWeakPtr<Volume> {
79 public: 78 public:
80 ~Volume(); 79 ~Volume();
81 80
82 // Factory static methods for different volume types. 81 // Factory static methods for different volume types.
83 static Volume* CreateForDrive(Profile* profile); 82 static std::unique_ptr<Volume> CreateForDrive(Profile* profile);
84 static Volume* CreateForDownloads(const base::FilePath& downloads_path); 83 static std::unique_ptr<Volume> CreateForDownloads(
85 static Volume* CreateForRemovable( 84 const base::FilePath& downloads_path);
85 static std::unique_ptr<Volume> CreateForRemovable(
86 const chromeos::disks::DiskMountManager::MountPointInfo& mount_point, 86 const chromeos::disks::DiskMountManager::MountPointInfo& mount_point,
87 const chromeos::disks::DiskMountManager::Disk* disk); 87 const chromeos::disks::DiskMountManager::Disk* disk);
88 static Volume* CreateForProvidedFileSystem( 88 static std::unique_ptr<Volume> CreateForProvidedFileSystem(
89 const chromeos::file_system_provider::ProvidedFileSystemInfo& 89 const chromeos::file_system_provider::ProvidedFileSystemInfo&
90 file_system_info, 90 file_system_info,
91 MountContext mount_context); 91 MountContext mount_context);
92 static Volume* CreateForMTP(const base::FilePath& mount_path, 92 static std::unique_ptr<Volume> CreateForMTP(const base::FilePath& mount_path,
93 const std::string& label, 93 const std::string& label,
94 bool read_only); 94 bool read_only);
95 static Volume* CreateForMediaView(const std::string& root_document_id); 95 static std::unique_ptr<Volume> CreateForMediaView(
96 static Volume* CreateForTesting(const base::FilePath& path, 96 const std::string& root_document_id);
97 VolumeType volume_type, 97 static std::unique_ptr<Volume> CreateForTesting(
98 chromeos::DeviceType device_type, 98 const base::FilePath& path,
99 bool read_only); 99 VolumeType volume_type,
100 static Volume* CreateForTesting(const base::FilePath& device_path, 100 chromeos::DeviceType device_type,
101 const base::FilePath& mount_path); 101 bool read_only);
102 static std::unique_ptr<Volume> CreateForTesting(
103 const base::FilePath& device_path,
104 const base::FilePath& mount_path);
102 105
103 // Getters for all members. See below for details. 106 // Getters for all members. See below for details.
104 const std::string& volume_id() const { return volume_id_; } 107 const std::string& volume_id() const { return volume_id_; }
105 const std::string& file_system_id() const { return file_system_id_; } 108 const std::string& file_system_id() const { return file_system_id_; }
106 const std::string& extension_id() const { return extension_id_; } 109 const std::string& extension_id() const { return extension_id_; }
107 Source source() const { return source_; } 110 Source source() const { return source_; }
108 VolumeType type() const { return type_; } 111 VolumeType type() const { return type_; }
109 chromeos::DeviceType device_type() const { return device_type_; } 112 chromeos::DeviceType device_type() const { return device_type_; }
110 const base::FilePath& source_path() const { return source_path_; } 113 const base::FilePath& source_path() const { return source_path_; }
111 const base::FilePath& mount_path() const { return mount_path_; } 114 const base::FilePath& mount_path() const { return mount_path_; }
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 bool RegisterDownloadsDirectoryForTesting(const base::FilePath& path); 266 bool RegisterDownloadsDirectoryForTesting(const base::FilePath& path);
264 267
265 // For testing purpose, adds a volume info pointing to |path|, with TESTING 268 // For testing purpose, adds a volume info pointing to |path|, with TESTING
266 // type. Assumes that the mount point is already registered. 269 // type. Assumes that the mount point is already registered.
267 void AddVolumeForTesting(const base::FilePath& path, 270 void AddVolumeForTesting(const base::FilePath& path,
268 VolumeType volume_type, 271 VolumeType volume_type,
269 chromeos::DeviceType device_type, 272 chromeos::DeviceType device_type,
270 bool read_only); 273 bool read_only);
271 274
272 // For testing purpose, adds the volume info to the volume manager. 275 // For testing purpose, adds the volume info to the volume manager.
273 void AddVolumeForTesting(const linked_ptr<Volume>& volume); 276 void AddVolumeForTesting(std::unique_ptr<Volume> volume);
274 277
275 // drive::DriveIntegrationServiceObserver overrides. 278 // drive::DriveIntegrationServiceObserver overrides.
276 void OnFileSystemMounted() override; 279 void OnFileSystemMounted() override;
277 void OnFileSystemBeingUnmounted() override; 280 void OnFileSystemBeingUnmounted() override;
278 281
279 // chromeos::disks::DiskMountManager::Observer overrides. 282 // chromeos::disks::DiskMountManager::Observer overrides.
280 void OnDiskEvent( 283 void OnDiskEvent(
281 chromeos::disks::DiskMountManager::DiskEvent event, 284 chromeos::disks::DiskMountManager::DiskEvent event,
282 const chromeos::disks::DiskMountManager::Disk* disk) override; 285 const chromeos::disks::DiskMountManager::Disk* disk) override;
283 void OnDeviceEvent(chromeos::disks::DiskMountManager::DeviceEvent event, 286 void OnDeviceEvent(chromeos::disks::DiskMountManager::DeviceEvent event,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 const storage_monitor::StorageInfo& info) override; 318 const storage_monitor::StorageInfo& info) override;
316 void OnRemovableStorageDetached( 319 void OnRemovableStorageDetached(
317 const storage_monitor::StorageInfo& info) override; 320 const storage_monitor::StorageInfo& info) override;
318 321
319 SnapshotManager* snapshot_manager() { return snapshot_manager_.get(); } 322 SnapshotManager* snapshot_manager() { return snapshot_manager_.get(); }
320 323
321 private: 324 private:
322 void OnDiskMountManagerRefreshed(bool success); 325 void OnDiskMountManagerRefreshed(bool success);
323 void OnStorageMonitorInitialized(); 326 void OnStorageMonitorInitialized();
324 void DoMountEvent(chromeos::MountError error_code, 327 void DoMountEvent(chromeos::MountError error_code,
325 const linked_ptr<Volume>& volume); 328 std::unique_ptr<Volume> volume);
326 void DoUnmountEvent(chromeos::MountError error_code, 329 void DoUnmountEvent(chromeos::MountError error_code, const Volume& volume);
327 const linked_ptr<Volume>& volume);
328 void OnExternalStorageDisabledChangedUnmountCallback( 330 void OnExternalStorageDisabledChangedUnmountCallback(
329 chromeos::MountError error_code); 331 chromeos::MountError error_code);
330 332
331 Profile* profile_; 333 Profile* profile_;
332 drive::DriveIntegrationService* drive_integration_service_; // Not owned. 334 drive::DriveIntegrationService* drive_integration_service_; // Not owned.
333 chromeos::disks::DiskMountManager* disk_mount_manager_; // Not owned. 335 chromeos::disks::DiskMountManager* disk_mount_manager_; // Not owned.
334 PrefChangeRegistrar pref_change_registrar_; 336 PrefChangeRegistrar pref_change_registrar_;
335 base::ObserverList<VolumeManagerObserver> observers_; 337 base::ObserverList<VolumeManagerObserver> observers_;
336 chromeos::file_system_provider::Service* 338 chromeos::file_system_provider::Service*
337 file_system_provider_service_; // Not owned by this class. 339 file_system_provider_service_; // Not owned by this class.
338 GetMtpStorageInfoCallback get_mtp_storage_info_callback_; 340 GetMtpStorageInfoCallback get_mtp_storage_info_callback_;
339 std::map<std::string, linked_ptr<Volume>> mounted_volumes_; 341 std::map<std::string, std::unique_ptr<Volume>> mounted_volumes_;
340 std::unique_ptr<SnapshotManager> snapshot_manager_; 342 std::unique_ptr<SnapshotManager> snapshot_manager_;
341 bool arc_volumes_mounted_ = false; 343 bool arc_volumes_mounted_ = false;
342 344
343 // Note: This should remain the last member so it'll be destroyed and 345 // Note: This should remain the last member so it'll be destroyed and
344 // invalidate its weak pointers before any other members are destroyed. 346 // invalidate its weak pointers before any other members are destroyed.
345 base::WeakPtrFactory<VolumeManager> weak_ptr_factory_; 347 base::WeakPtrFactory<VolumeManager> weak_ptr_factory_;
346 DISALLOW_COPY_AND_ASSIGN(VolumeManager); 348 DISALLOW_COPY_AND_ASSIGN(VolumeManager);
347 }; 349 };
348 350
349 } // namespace file_manager 351 } // namespace file_manager
350 352
351 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_VOLUME_MANAGER_H_ 353 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_VOLUME_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698