diff options
16 files changed, 46 insertions, 73 deletions
diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc index 0b52b59..68176a5 100644 --- a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc +++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc @@ -21,7 +21,6 @@ #include "chrome/browser/chromeos/cros/cros_library.h" #include "chrome/browser/chromeos/cryptohome/async_method_caller.h" #include "chrome/browser/chromeos/dbus/cros_dbus_service.h" -#include "chrome/browser/chromeos/disks/disk_mount_manager.h" #include "chrome/browser/chromeos/external_metrics.h" #include "chrome/browser/chromeos/imageburner/burn_manager.h" #include "chrome/browser/chromeos/input_method/input_method_manager.h" @@ -75,6 +74,7 @@ #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/power_manager_client.h" #include "chromeos/dbus/session_manager_client.h" +#include "chromeos/disks/disk_mount_manager.h" #include "content/public/browser/notification_service.h" #include "content/public/common/main_function_params.h" #include "grit/platform_locale_settings.h" diff --git a/chrome/browser/chromeos/cros/burn_library.cc b/chrome/browser/chromeos/cros/burn_library.cc index aaebe1f..4fb4d40 100644 --- a/chrome/browser/chromeos/cros/burn_library.cc +++ b/chrome/browser/chromeos/cros/burn_library.cc @@ -9,10 +9,10 @@ #include "base/memory/ref_counted_memory.h" #include "base/observer_list.h" #include "base/threading/worker_pool.h" -#include "chrome/browser/chromeos/disks/disk_mount_manager.h" #include "chrome/common/zip.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/image_burner_client.h" +#include "chromeos/disks/disk_mount_manager.h" namespace chromeos { diff --git a/chrome/browser/chromeos/extensions/file_browser_event_router.h b/chrome/browser/chromeos/extensions/file_browser_event_router.h index 4cf30db..2d3b310 100644 --- a/chrome/browser/chromeos/extensions/file_browser_event_router.h +++ b/chrome/browser/chromeos/extensions/file_browser_event_router.h @@ -15,11 +15,11 @@ #include "base/string16.h" #include "base/synchronization/lock.h" #include "chrome/browser/chromeos/cros/network_library.h" -#include "chrome/browser/chromeos/disks/disk_mount_manager.h" #include "chrome/browser/chromeos/gdata/drive_file_system_interface.h" #include "chrome/browser/chromeos/gdata/operation_registry.h" #include "chrome/browser/profiles/refcounted_profile_keyed_service.h" #include "chrome/browser/profiles/refcounted_profile_keyed_service_factory.h" +#include "chromeos/disks/disk_mount_manager.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_source.h" diff --git a/chrome/browser/chromeos/extensions/file_browser_private_api.cc b/chrome/browser/chromeos/extensions/file_browser_private_api.cc index 21bb18a..4bab431 100644 --- a/chrome/browser/chromeos/extensions/file_browser_private_api.cc +++ b/chrome/browser/chromeos/extensions/file_browser_private_api.cc @@ -4,6 +4,7 @@ #include "chrome/browser/chromeos/extensions/file_browser_private_api.h" +#include <sys/statvfs.h> #include <utility> #include "base/base64.h" @@ -18,7 +19,6 @@ #include "base/values.h" #include "chrome/browser/chromeos/cros/cros_library.h" #include "chrome/browser/chromeos/cros/network_library.h" -#include "chrome/browser/chromeos/disks/disk_mount_manager.h" #include "chrome/browser/chromeos/extensions/file_handler_util.h" #include "chrome/browser/chromeos/extensions/file_manager_util.h" #include "chrome/browser/chromeos/gdata/drive.pb.h" @@ -45,6 +45,7 @@ #include "chrome/common/extensions/extension_icon_set.h" #include "chrome/common/extensions/file_browser_handler.h" #include "chrome/common/pref_names.h" +#include "chromeos/disks/disk_mount_manager.h" #include "content/public/browser/child_process_security_policy.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" @@ -253,6 +254,26 @@ GURL FindPreferredIcon(const InstalledApp::IconList& icons, return result; } +// Retrieves total and remaining available size on |mount_path|. +void GetSizeStatsOnFileThread(const std::string& mount_path, + size_t* total_size_kb, + size_t* remaining_size_kb) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); + + uint64_t total_size_in_bytes = 0; + uint64_t remaining_size_in_bytes = 0; + + struct statvfs stat = {}; // Zero-clear + if (statvfs(mount_path.c_str(), &stat) == 0) { + total_size_in_bytes = + static_cast<uint64_t>(stat.f_blocks) * stat.f_frsize; + remaining_size_in_bytes = + static_cast<uint64_t>(stat.f_bfree) * stat.f_frsize; + } + *total_size_kb = static_cast<size_t>(total_size_in_bytes / 1024); + *remaining_size_kb = static_cast<size_t>(remaining_size_in_bytes / 1024); +} + } // namespace class RequestLocalFileSystemFunction::LocalFileSystemCallbackDispatcher { @@ -1268,8 +1289,7 @@ void GetSizeStatsFunction::CallGetSizeStatsOnFileThread( size_t total_size_kb = 0; size_t remaining_size_kb = 0; - DiskMountManager::GetInstance()-> - GetSizeStatsOnFileThread(mount_path, &total_size_kb, &remaining_size_kb); + GetSizeStatsOnFileThread(mount_path, &total_size_kb, &remaining_size_kb); BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, diff --git a/chrome/browser/chromeos/extensions/file_browser_private_apitest.cc b/chrome/browser/chromeos/extensions/file_browser_private_apitest.cc index a70d348..1638a02 100644 --- a/chrome/browser/chromeos/extensions/file_browser_private_apitest.cc +++ b/chrome/browser/chromeos/extensions/file_browser_private_apitest.cc @@ -5,11 +5,11 @@ #include <stdio.h> #include "base/stl_util.h" -#include "chrome/browser/chromeos/disks/mock_disk_mount_manager.h" #include "chrome/browser/extensions/extension_apitest.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/test/base/ui_test_utils.h" +#include "chromeos/disks/mock_disk_mount_manager.h" #include "content/public/browser/browser_thread.h" #include "webkit/fileapi/file_system_context.h" #include "webkit/fileapi/file_system_mount_point_provider.h" diff --git a/chrome/browser/chromeos/imageburner/burn_controller.h b/chrome/browser/chromeos/imageburner/burn_controller.h index e34c861..e35ecd6 100644 --- a/chrome/browser/chromeos/imageburner/burn_controller.h +++ b/chrome/browser/chromeos/imageburner/burn_controller.h @@ -8,7 +8,7 @@ #include <vector> #include "base/basictypes.h" -#include "chrome/browser/chromeos/disks/disk_mount_manager.h" +#include "chromeos/disks/disk_mount_manager.h" class FilePath; diff --git a/chrome/browser/media_gallery/media_device_notifications_chromeos.h b/chrome/browser/media_gallery/media_device_notifications_chromeos.h index 7f9b625e..49822b9 100644 --- a/chrome/browser/media_gallery/media_device_notifications_chromeos.h +++ b/chrome/browser/media_gallery/media_device_notifications_chromeos.h @@ -19,7 +19,7 @@ #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" #include "base/system_monitor/system_monitor.h" -#include "chrome/browser/chromeos/disks/disk_mount_manager.h" +#include "chromeos/disks/disk_mount_manager.h" namespace chromeos { diff --git a/chrome/browser/media_gallery/media_device_notifications_chromeos_unittest.cc b/chrome/browser/media_gallery/media_device_notifications_chromeos_unittest.cc index eedd63e..cc57de4 100644 --- a/chrome/browser/media_gallery/media_device_notifications_chromeos_unittest.cc +++ b/chrome/browser/media_gallery/media_device_notifications_chromeos_unittest.cc @@ -14,8 +14,8 @@ #include "base/system_monitor/system_monitor.h" #include "base/test/mock_devices_changed_observer.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/chromeos/disks/mock_disk_mount_manager.h" #include "chrome/browser/media_gallery/media_storage_util.h" +#include "chromeos/disks/mock_disk_mount_manager.h" #include "content/public/test/test_browser_thread.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/browser/resources/file_manager/js/volume_manager.js b/chrome/browser/resources/file_manager/js/volume_manager.js index fd9f0a9..965b6d3 100644 --- a/chrome/browser/resources/file_manager/js/volume_manager.js +++ b/chrome/browser/resources/file_manager/js/volume_manager.js @@ -348,7 +348,7 @@ VolumeManager.prototype.isUnreadable = function(mountPath) { /** * @param {string} mountPath Volume mounted path. * @return {string} Device type ('usb'|'sd'|'optical'|'mobile'|'unknown') - * (as defined in chrome/browser/chromeos/disks/disk_mount_manager.cc). + * (as defined in chromeos/disks/disk_mount_manager.cc). */ VolumeManager.prototype.getDeviceType = function(mountPath) { return this.getVolumeInfo_(mountPath).deviceType; diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index d96894b..1f698b4 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -540,8 +540,6 @@ 'browser/chromeos/dbus/proxy_resolution_service_provider.cc', 'browser/chromeos/dbus/proxy_resolution_service_provider.h', 'browser/chromeos/device_hierarchy_observer.h', - 'browser/chromeos/disks/disk_mount_manager.cc', - 'browser/chromeos/disks/disk_mount_manager.h', 'browser/chromeos/enrollment_dialog_view.cc', 'browser/chromeos/enrollment_dialog_view.h', 'browser/chromeos/enterprise_extension_observer.cc', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 8680e6d..c6a4047 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -1108,8 +1108,6 @@ 'browser/chromeos/cros/network_ui_data_unittest.cc', 'browser/chromeos/cros/onc_network_parser_unittest.cc', 'browser/chromeos/customization_document_unittest.cc', - 'browser/chromeos/disks/mock_disk_mount_manager.cc', - 'browser/chromeos/disks/mock_disk_mount_manager.h', 'browser/chromeos/dbus/cros_dbus_service_unittest.cc', 'browser/chromeos/dbus/proxy_resolution_service_provider_unittest.cc', 'browser/chromeos/extensions/file_browser_notifications_unittest.cc', @@ -2709,8 +2707,6 @@ 'browser/chromeos/cros/cros_in_process_browser_test.h', 'browser/chromeos/cros/cros_mock.cc', 'browser/chromeos/cros/cros_mock.h', - 'browser/chromeos/disks/mock_disk_mount_manager.cc', - 'browser/chromeos/disks/mock_disk_mount_manager.h', 'browser/chromeos/extensions/file_browser_handler_api_test.cc', 'browser/chromeos/extensions/file_browser_notifications_browsertest.cc', 'browser/chromeos/extensions/file_browser_private_apitest.cc', diff --git a/chromeos/chromeos.gyp b/chromeos/chromeos.gyp index 47b9587..575dfaf 100644 --- a/chromeos/chromeos.gyp +++ b/chromeos/chromeos.gyp @@ -111,6 +111,8 @@ 'dbus/sms_client.h', 'dbus/update_engine_client.cc', 'dbus/update_engine_client.h', + 'disks/disk_mount_manager.cc', + 'disks/disk_mount_manager.h', 'display/output_configurator.cc', 'display/output_configurator.h', 'network/network_sms_handler.cc', @@ -186,6 +188,8 @@ 'dbus/mock_speech_synthesizer_client.h', 'dbus/mock_update_engine_client.cc', 'dbus/mock_update_engine_client.h', + 'disks/mock_disk_mount_manager.cc', + 'disks/mock_disk_mount_manager.h', ], 'include_dirs': [ '..', diff --git a/chrome/browser/chromeos/disks/disk_mount_manager.cc b/chromeos/disks/disk_mount_manager.cc index 388259c..828cebb 100644 --- a/chrome/browser/chromeos/disks/disk_mount_manager.cc +++ b/chromeos/disks/disk_mount_manager.cc @@ -2,9 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/chromeos/disks/disk_mount_manager.h" - -#include <sys/statvfs.h> +#include "chromeos/disks/disk_mount_manager.h" #include <map> #include <set> @@ -14,9 +12,6 @@ #include "base/observer_list.h" #include "base/string_util.h" #include "chromeos/dbus/dbus_thread_manager.h" -#include "content/public/browser/browser_thread.h" - -using content::BrowserThread; namespace chromeos { namespace disks { @@ -69,7 +64,6 @@ class DiskMountManagerImpl : public DiskMountManager { return; } } - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); cros_disks_client_->Mount( source_path, source_format, @@ -88,7 +82,6 @@ class DiskMountManagerImpl : public DiskMountManager { // DiskMountManager override. virtual void UnmountPath(const std::string& mount_path) OVERRIDE { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); cros_disks_client_->Unmount(mount_path, base::Bind(&DiskMountManagerImpl::OnUnmountPath, weak_ptr_factory_.GetWeakPtr()), @@ -96,28 +89,7 @@ class DiskMountManagerImpl : public DiskMountManager { } // DiskMountManager override. - virtual void GetSizeStatsOnFileThread(const std::string& mount_path, - size_t* total_size_kb, - size_t* remaining_size_kb) OVERRIDE { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); - - uint64_t total_size_in_bytes = 0; - uint64_t remaining_size_in_bytes = 0; - - struct statvfs stat = {}; // Zero-clear - if (statvfs(mount_path.c_str(), &stat) == 0) { - total_size_in_bytes = - static_cast<uint64_t>(stat.f_blocks) * stat.f_frsize; - remaining_size_in_bytes = - static_cast<uint64_t>(stat.f_bfree) * stat.f_frsize; - } - *total_size_kb = static_cast<size_t>(total_size_in_bytes / 1024); - *remaining_size_kb = static_cast<size_t>(remaining_size_in_bytes / 1024); - } - - // DiskMountManager override. virtual void FormatUnmountedDevice(const std::string& file_path) OVERRIDE { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); for (DiskMountManager::DiskMap::iterator it = disks_.begin(); it != disks_.end(); ++it) { if (it->second->file_path() == file_path && @@ -220,7 +192,6 @@ class DiskMountManagerImpl : public DiskMountManager { // DiskMountManager override. virtual void RequestMountInfoRefresh() OVERRIDE { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); cros_disks_client_->EnumerateAutoMountableDevices( base::Bind(&DiskMountManagerImpl::OnRequestMountInfo, weak_ptr_factory_.GetWeakPtr()), @@ -486,14 +457,12 @@ class DiskMountManagerImpl : public DiskMountManager { // Notifies all observers about disk status update. void NotifyDiskStatusUpdate(DiskMountManagerEventType event, const Disk* disk) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); FOR_EACH_OBSERVER(Observer, observers_, DiskChanged(event, disk)); } // Notifies all observers about device status update. void NotifyDeviceStatusUpdate(DiskMountManagerEventType event, const std::string& device_path) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); FOR_EACH_OBSERVER(Observer, observers_, DeviceChanged(event, device_path)); } @@ -501,7 +470,6 @@ class DiskMountManagerImpl : public DiskMountManager { void NotifyMountCompleted(MountEvent event_type, MountError error_code, const MountPointInfo& mount_info) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); FOR_EACH_OBSERVER(Observer, observers_, MountCompleted(event_type, error_code, mount_info)); } diff --git a/chrome/browser/chromeos/disks/disk_mount_manager.h b/chromeos/disks/disk_mount_manager.h index 546c4b7..dfe80c3 100644 --- a/chrome/browser/chromeos/disks/disk_mount_manager.h +++ b/chromeos/disks/disk_mount_manager.h @@ -2,11 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CHROMEOS_DISKS_DISK_MOUNT_MANAGER_H_ -#define CHROME_BROWSER_CHROMEOS_DISKS_DISK_MOUNT_MANAGER_H_ +#ifndef CHROMEOS_DISKS_DISK_MOUNT_MANAGER_H_ +#define CHROMEOS_DISKS_DISK_MOUNT_MANAGER_H_ #include <map> +#include "chromeos/chromeos_export.h" #include "chromeos/dbus/cros_disks_client.h" namespace chromeos { @@ -35,7 +36,7 @@ enum MountCondition { // This class handles the interaction with cros-disks. // Other classes can add themselves as observers. -class DiskMountManager { +class CHROMEOS_EXPORT DiskMountManager { public: // Event type given to observers' MountCompleted method. enum MountEvent { @@ -217,10 +218,6 @@ class DiskMountManager { // Unmounts a mounted disk. virtual void UnmountPath(const std::string& mount_path) = 0; - // Retrieves total and remaining available size on |mount_path|. - virtual void GetSizeStatsOnFileThread(const std::string& mount_path, - size_t* total_size_kb, - size_t* remaining_size_kb) = 0; // Formats device given its file path. // Example: file_path: /dev/sdb1 virtual void FormatUnmountedDevice(const std::string& file_path) = 0; @@ -267,4 +264,4 @@ class DiskMountManager { } // namespace disks } // namespace chromeos -#endif // CHROME_BROWSER_CHROMEOS_DISKS_DISK_MOUNT_MANAGER_H_ +#endif // CHROMEOS_DISKS_DISK_MOUNT_MANAGER_H_ diff --git a/chrome/browser/chromeos/disks/mock_disk_mount_manager.cc b/chromeos/disks/mock_disk_mount_manager.cc index de08ebe..0b67c9a 100644 --- a/chrome/browser/chromeos/disks/mock_disk_mount_manager.cc +++ b/chromeos/disks/mock_disk_mount_manager.cc @@ -2,16 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/chromeos/disks/mock_disk_mount_manager.h" +#include "chromeos/disks/mock_disk_mount_manager.h" #include <utility> #include "base/message_loop.h" #include "base/stl_util.h" #include "base/string_util.h" -#include "content/public/browser/browser_thread.h" -using content::BrowserThread; using testing::_; using testing::AnyNumber; using testing::Invoke; @@ -217,17 +215,11 @@ MockDiskMountManager::FindDiskBySourcePathInternal( void MockDiskMountManager::NotifyDiskChanged( DiskMountManagerEventType event, const DiskMountManager::Disk* disk) { - // Make sure we run on UI thread. - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - FOR_EACH_OBSERVER(Observer, observers_, DiskChanged(event, disk)); } void MockDiskMountManager::NotifyDeviceChanged(DiskMountManagerEventType event, const std::string& path) { - // Make sure we run on UI thread. - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - FOR_EACH_OBSERVER(Observer, observers_, DeviceChanged(event, path)); } diff --git a/chrome/browser/chromeos/disks/mock_disk_mount_manager.h b/chromeos/disks/mock_disk_mount_manager.h index aec2894..169f33d 100644 --- a/chrome/browser/chromeos/disks/mock_disk_mount_manager.h +++ b/chromeos/disks/mock_disk_mount_manager.h @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CHROMEOS_DISKS_MOCK_DISK_MOUNT_MANAGER_H_ -#define CHROME_BROWSER_CHROMEOS_DISKS_MOCK_DISK_MOUNT_MANAGER_H_ +#ifndef CHROMEOS_DISKS_MOCK_DISK_MOUNT_MANAGER_H_ +#define CHROMEOS_DISKS_MOCK_DISK_MOUNT_MANAGER_H_ #include <string> #include "base/observer_list.h" #include "base/time.h" -#include "chrome/browser/chromeos/disks/disk_mount_manager.h" +#include "chromeos/disks/disk_mount_manager.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -34,8 +34,6 @@ class MockDiskMountManager : public DiskMountManager { MOCK_METHOD4(MountPath, void(const std::string&, const std::string&, const std::string&, MountType)); MOCK_METHOD1(UnmountPath, void(const std::string&)); - MOCK_METHOD3(GetSizeStatsOnFileThread, void(const std::string&, size_t*, - size_t*)); MOCK_METHOD1(FormatUnmountedDevice, void(const std::string&)); MOCK_METHOD1(FormatMountedDevice, void(const std::string&)); MOCK_METHOD3(UnmountDeviceRecursive, void(const std::string&, @@ -100,4 +98,4 @@ class MockDiskMountManager : public DiskMountManager { } // namespace disks } // namespace chromeos -#endif // CHROME_BROWSER_CHROMEOS_DISKS_MOCK_DISK_MOUNT_MANAGER_H_ +#endif // CHROMEOS_DISKS_MOCK_DISK_MOUNT_MANAGER_H_ |