| 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 #include "chrome/browser/chromeos/file_manager/volume_manager.h" | 5 #include "chrome/browser/chromeos/file_manager/volume_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 bool success; | 54 bool success; |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 LoggingObserver() {} | 57 LoggingObserver() {} |
| 58 virtual ~LoggingObserver() {} | 58 virtual ~LoggingObserver() {} |
| 59 | 59 |
| 60 const std::vector<Event>& events() const { return events_; } | 60 const std::vector<Event>& events() const { return events_; } |
| 61 | 61 |
| 62 // VolumeManagerObserver overrides. | 62 // VolumeManagerObserver overrides. |
| 63 virtual void OnDiskAdded(const chromeos::disks::DiskMountManager::Disk& disk, | 63 virtual void OnDiskAdded(const chromeos::disks::DiskMountManager::Disk& disk, |
| 64 bool mounting) OVERRIDE { | 64 bool mounting) override { |
| 65 Event event; | 65 Event event; |
| 66 event.type = Event::DISK_ADDED; | 66 event.type = Event::DISK_ADDED; |
| 67 event.device_path = disk.device_path(); // Keep only device_path. | 67 event.device_path = disk.device_path(); // Keep only device_path. |
| 68 event.mounting = mounting; | 68 event.mounting = mounting; |
| 69 events_.push_back(event); | 69 events_.push_back(event); |
| 70 } | 70 } |
| 71 | 71 |
| 72 virtual void OnDiskRemoved( | 72 virtual void OnDiskRemoved( |
| 73 const chromeos::disks::DiskMountManager::Disk& disk) OVERRIDE { | 73 const chromeos::disks::DiskMountManager::Disk& disk) override { |
| 74 Event event; | 74 Event event; |
| 75 event.type = Event::DISK_REMOVED; | 75 event.type = Event::DISK_REMOVED; |
| 76 event.device_path = disk.device_path(); // Keep only device_path. | 76 event.device_path = disk.device_path(); // Keep only device_path. |
| 77 events_.push_back(event); | 77 events_.push_back(event); |
| 78 } | 78 } |
| 79 | 79 |
| 80 virtual void OnDeviceAdded(const std::string& device_path) OVERRIDE { | 80 virtual void OnDeviceAdded(const std::string& device_path) override { |
| 81 Event event; | 81 Event event; |
| 82 event.type = Event::DEVICE_ADDED; | 82 event.type = Event::DEVICE_ADDED; |
| 83 event.device_path = device_path; | 83 event.device_path = device_path; |
| 84 events_.push_back(event); | 84 events_.push_back(event); |
| 85 } | 85 } |
| 86 | 86 |
| 87 virtual void OnDeviceRemoved(const std::string& device_path) OVERRIDE { | 87 virtual void OnDeviceRemoved(const std::string& device_path) override { |
| 88 Event event; | 88 Event event; |
| 89 event.type = Event::DEVICE_REMOVED; | 89 event.type = Event::DEVICE_REMOVED; |
| 90 event.device_path = device_path; | 90 event.device_path = device_path; |
| 91 events_.push_back(event); | 91 events_.push_back(event); |
| 92 } | 92 } |
| 93 | 93 |
| 94 virtual void OnVolumeMounted(chromeos::MountError error_code, | 94 virtual void OnVolumeMounted(chromeos::MountError error_code, |
| 95 const VolumeInfo& volume_info) OVERRIDE { | 95 const VolumeInfo& volume_info) override { |
| 96 Event event; | 96 Event event; |
| 97 event.type = Event::VOLUME_MOUNTED; | 97 event.type = Event::VOLUME_MOUNTED; |
| 98 event.device_path = volume_info.source_path.AsUTF8Unsafe(); | 98 event.device_path = volume_info.source_path.AsUTF8Unsafe(); |
| 99 event.mount_error = error_code; | 99 event.mount_error = error_code; |
| 100 events_.push_back(event); | 100 events_.push_back(event); |
| 101 } | 101 } |
| 102 | 102 |
| 103 virtual void OnVolumeUnmounted(chromeos::MountError error_code, | 103 virtual void OnVolumeUnmounted(chromeos::MountError error_code, |
| 104 const VolumeInfo& volume_info) OVERRIDE { | 104 const VolumeInfo& volume_info) override { |
| 105 Event event; | 105 Event event; |
| 106 event.type = Event::VOLUME_UNMOUNTED; | 106 event.type = Event::VOLUME_UNMOUNTED; |
| 107 event.device_path = volume_info.source_path.AsUTF8Unsafe(); | 107 event.device_path = volume_info.source_path.AsUTF8Unsafe(); |
| 108 event.mount_error = error_code; | 108 event.mount_error = error_code; |
| 109 events_.push_back(event); | 109 events_.push_back(event); |
| 110 } | 110 } |
| 111 | 111 |
| 112 virtual void OnFormatStarted( | 112 virtual void OnFormatStarted( |
| 113 const std::string& device_path, bool success) OVERRIDE { | 113 const std::string& device_path, bool success) override { |
| 114 Event event; | 114 Event event; |
| 115 event.type = Event::FORMAT_STARTED; | 115 event.type = Event::FORMAT_STARTED; |
| 116 event.device_path = device_path; | 116 event.device_path = device_path; |
| 117 event.success = success; | 117 event.success = success; |
| 118 events_.push_back(event); | 118 events_.push_back(event); |
| 119 } | 119 } |
| 120 | 120 |
| 121 virtual void OnFormatCompleted( | 121 virtual void OnFormatCompleted( |
| 122 const std::string& device_path, bool success) OVERRIDE { | 122 const std::string& device_path, bool success) override { |
| 123 Event event; | 123 Event event; |
| 124 event.type = Event::FORMAT_COMPLETED; | 124 event.type = Event::FORMAT_COMPLETED; |
| 125 event.device_path = device_path; | 125 event.device_path = device_path; |
| 126 event.success = success; | 126 event.success = success; |
| 127 events_.push_back(event); | 127 events_.push_back(event); |
| 128 } | 128 } |
| 129 | 129 |
| 130 private: | 130 private: |
| 131 std::vector<Event> events_; | 131 std::vector<Event> events_; |
| 132 | 132 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 163 VolumeManager* volume_manager() const { return volume_manager_.get(); } | 163 VolumeManager* volume_manager() const { return volume_manager_.get(); } |
| 164 | 164 |
| 165 private: | 165 private: |
| 166 scoped_ptr<TestingProfile> profile_; | 166 scoped_ptr<TestingProfile> profile_; |
| 167 scoped_ptr<extensions::ExtensionRegistry> extension_registry_; | 167 scoped_ptr<extensions::ExtensionRegistry> extension_registry_; |
| 168 scoped_ptr<chromeos::file_system_provider::Service> | 168 scoped_ptr<chromeos::file_system_provider::Service> |
| 169 file_system_provider_service_; | 169 file_system_provider_service_; |
| 170 scoped_ptr<VolumeManager> volume_manager_; | 170 scoped_ptr<VolumeManager> volume_manager_; |
| 171 }; | 171 }; |
| 172 | 172 |
| 173 virtual void SetUp() OVERRIDE { | 173 virtual void SetUp() override { |
| 174 power_manager_client_.reset(new chromeos::FakePowerManagerClient); | 174 power_manager_client_.reset(new chromeos::FakePowerManagerClient); |
| 175 disk_mount_manager_.reset(new FakeDiskMountManager); | 175 disk_mount_manager_.reset(new FakeDiskMountManager); |
| 176 main_profile_.reset(new ProfileEnvironment(power_manager_client_.get(), | 176 main_profile_.reset(new ProfileEnvironment(power_manager_client_.get(), |
| 177 disk_mount_manager_.get())); | 177 disk_mount_manager_.get())); |
| 178 } | 178 } |
| 179 | 179 |
| 180 Profile* profile() const { return main_profile_->profile(); } | 180 Profile* profile() const { return main_profile_->profile(); } |
| 181 VolumeManager* volume_manager() const { | 181 VolumeManager* volume_manager() const { |
| 182 return main_profile_->volume_manager(); | 182 return main_profile_->volume_manager(); |
| 183 } | 183 } |
| (...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 // Detach | 856 // Detach |
| 857 volume_manager()->OnRemovableStorageDetached(info); | 857 volume_manager()->OnRemovableStorageDetached(info); |
| 858 ASSERT_EQ(2u, observer.events().size()); | 858 ASSERT_EQ(2u, observer.events().size()); |
| 859 EXPECT_EQ(LoggingObserver::Event::VOLUME_UNMOUNTED, | 859 EXPECT_EQ(LoggingObserver::Event::VOLUME_UNMOUNTED, |
| 860 observer.events()[1].type); | 860 observer.events()[1].type); |
| 861 | 861 |
| 862 EXPECT_FALSE(volume_manager()->FindVolumeInfoById("mtp:model", &volume_info)); | 862 EXPECT_FALSE(volume_manager()->FindVolumeInfoById("mtp:model", &volume_info)); |
| 863 } | 863 } |
| 864 | 864 |
| 865 } // namespace file_manager | 865 } // namespace file_manager |
| OLD | NEW |