diff options
author | thiago.santos@intel.com <thiago.santos@intel.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-25 10:22:39 +0000 |
---|---|---|
committer | thiago.santos@intel.com <thiago.santos@intel.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-25 10:22:39 +0000 |
commit | 7bfe94604142cc8df365fbb41a361041c574aa56 (patch) | |
tree | 3e30df28971747506e8e86186a1f1acbecaa22c2 /components/storage_monitor | |
parent | baf821508c4e305c60f7176319916bb4d066841b (diff) | |
download | chromium_src-7bfe94604142cc8df365fbb41a361041c574aa56.zip chromium_src-7bfe94604142cc8df365fbb41a361041c574aa56.tar.gz chromium_src-7bfe94604142cc8df365fbb41a361041c574aa56.tar.bz2 |
Add the storage_monitor:: namespace for the storage_monitor component
This is a follow-up of the patch moving storage_monitor from chrome/ to
components/.
R=joi@chromium.org,thestig@chromium.org
BUG=
Review URL: https://codereview.chromium.org/172163003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253122 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/storage_monitor')
54 files changed, 459 insertions, 175 deletions
diff --git a/components/storage_monitor/image_capture_device.h b/components/storage_monitor/image_capture_device.h index 67de8ef..55dc1fe 100644 --- a/components/storage_monitor/image_capture_device.h +++ b/components/storage_monitor/image_capture_device.h @@ -19,6 +19,8 @@ #include "base/strings/sys_string_conversions.h" #include "base/synchronization/lock.h" +namespace storage_monitor { + // Clients use this listener interface to get notifications about // events happening as a particular ImageCapture device is interacted with. // Clients drive the interaction through the ImageCaptureDeviceManager @@ -50,6 +52,8 @@ class ImageCaptureDeviceListener { virtual void DeviceRemoved() = 0; }; +} // namespace storage_monitor + // Interface to a camera device found by ImageCaptureCore. This class manages a // session to the camera and provides the backing interactions to present the // media files on it to the filesystem delegate. FilePaths will be artificial, @@ -59,12 +63,13 @@ class ImageCaptureDeviceListener { : NSObject<ICCameraDeviceDelegate, ICCameraDeviceDownloadDelegate> { @private base::scoped_nsobject<ICCameraDevice> camera_; - base::WeakPtr<ImageCaptureDeviceListener> listener_; + base::WeakPtr<storage_monitor::ImageCaptureDeviceListener> listener_; bool closing_; } - (id)initWithCameraDevice:(ICCameraDevice*)cameraDevice; -- (void)setListener:(base::WeakPtr<ImageCaptureDeviceListener>)listener; +- (void)setListener: + (base::WeakPtr<storage_monitor::ImageCaptureDeviceListener>)listener; - (void)open; - (void)close; diff --git a/components/storage_monitor/image_capture_device.mm b/components/storage_monitor/image_capture_device.mm index 9e1fcdc..e28137e 100644 --- a/components/storage_monitor/image_capture_device.mm +++ b/components/storage_monitor/image_capture_device.mm @@ -7,6 +7,8 @@ #include "base/file_util.h" #include "content/public/browser/browser_thread.h" +namespace storage_monitor { + namespace { base::File::Error RenameFile(const base::FilePath& downloaded_filename, @@ -50,6 +52,8 @@ base::FilePath PathForCameraItem(ICCameraItem* item) { } // namespace +} // namespace storage_monitor + @implementation ImageCaptureDevice - (id)initWithCameraDevice:(ICCameraDevice*)cameraDevice { @@ -69,7 +73,8 @@ base::FilePath PathForCameraItem(ICCameraItem* item) { [super dealloc]; } -- (void)setListener:(base::WeakPtr<ImageCaptureDeviceListener>)listener { +- (void)setListener:(base::WeakPtr<storage_monitor::ImageCaptureDeviceListener>) + listener { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); listener_ = listener; } @@ -99,7 +104,7 @@ base::FilePath PathForCameraItem(ICCameraItem* item) { // Find the file with that name and start download. for (ICCameraItem* item in [camera_ mediaFiles]) { - std::string itemName = PathForCameraItem(item).value(); + std::string itemName = storage_monitor::PathForCameraItem(item).value(); if (itemName == name) { // To create save options for ImageCapture, we need to // split the target filename into directory/name @@ -137,10 +142,11 @@ base::FilePath PathForCameraItem(ICCameraItem* item) { else info.size = [base::mac::ObjCCastStrict<ICCameraFile>(item) fileSize]; - base::FilePath path = PathForCameraItem(item); + base::FilePath path = storage_monitor::PathForCameraItem(item); - info.last_modified = NSDateToBaseTime([item modificationDate]); - info.creation_time = NSDateToBaseTime([item creationDate]); + info.last_modified = + storage_monitor::NSDateToBaseTime([item modificationDate]); + info.creation_time = storage_monitor::NSDateToBaseTime([item creationDate]); info.last_accessed = info.last_modified; if (listener_) @@ -183,7 +189,7 @@ base::FilePath PathForCameraItem(ICCameraItem* item) { if (closing_) return; - std::string name = PathForCameraItem(file).value(); + std::string name = storage_monitor::PathForCameraItem(file).value(); if (error) { DVLOG(1) << "error..." @@ -214,8 +220,9 @@ base::FilePath PathForCameraItem(ICCameraItem* item) { content::BrowserThread::PostTaskAndReplyWithResult( content::BrowserThread::FILE, FROM_HERE, - base::Bind(&RenameFile, savedPath, saveAsPath), - base::Bind(&ReturnRenameResultToListener, listener_, name)); + base::Bind(&storage_monitor::RenameFile, savedPath, saveAsPath), + base::Bind( + &storage_monitor::ReturnRenameResultToListener, listener_, name)); } @end // ImageCaptureDevice diff --git a/components/storage_monitor/image_capture_device_manager.h b/components/storage_monitor/image_capture_device_manager.h index cc0287a..2a4578f 100644 --- a/components/storage_monitor/image_capture_device_manager.h +++ b/components/storage_monitor/image_capture_device_manager.h @@ -15,6 +15,8 @@ @class ImageCaptureDevice; @class ImageCaptureDeviceManagerImpl; +namespace storage_monitor { + // Upon creation, begins monitoring for any attached devices using the // ImageCapture API. Notifies clients of the presence of such devices // (i.e. cameras, USB cards) using the SystemMonitor and makes them @@ -45,4 +47,6 @@ class ImageCaptureDeviceManager { base::scoped_nsobject<ImageCaptureDeviceManagerImpl> device_browser_; }; +} // namespace storage_monitor + #endif // COMPONENTS_STORAGE_MONITOR_IMAGE_CAPTURE_DEVICE_MANAGER_H_ diff --git a/components/storage_monitor/image_capture_device_manager.mm b/components/storage_monitor/image_capture_device_manager.mm index 95b1c79..10b4d4e 100644 --- a/components/storage_monitor/image_capture_device_manager.mm +++ b/components/storage_monitor/image_capture_device_manager.mm @@ -11,7 +11,8 @@ namespace { -ImageCaptureDeviceManager* g_image_capture_device_manager = NULL; +storage_monitor::ImageCaptureDeviceManager* g_image_capture_device_manager = + NULL; } // namespace @@ -30,10 +31,11 @@ ImageCaptureDeviceManager* g_image_capture_device_manager = NULL; // Guaranteed to outlive this class. // TODO(gbillock): Update when ownership chains go up through // a StorageMonitor subclass. - StorageMonitor::Receiver* notifications_; + storage_monitor::StorageMonitor::Receiver* notifications_; } -- (void)setNotifications:(StorageMonitor::Receiver*)notifications; +- (void)setNotifications: + (storage_monitor::StorageMonitor::Receiver*)notifications; - (void)close; // The UUIDs passed here are available in the device attach notifications. @@ -58,7 +60,8 @@ ImageCaptureDeviceManager* g_image_capture_device_manager = NULL; return self; } -- (void)setNotifications:(StorageMonitor::Receiver*)notifications { +- (void)setNotifications: + (storage_monitor::StorageMonitor::Receiver*)notifications { notifications_ = notifications; } @@ -97,9 +100,9 @@ ImageCaptureDeviceManager* g_image_capture_device_manager = NULL; [cameras_ addObject:addedDevice]; // TODO(gbillock): use [cameraDevice mountPoint] here when possible. - StorageInfo info( - StorageInfo::MakeDeviceId( - StorageInfo::MAC_IMAGE_CAPTURE, + storage_monitor::StorageInfo info( + storage_monitor::StorageInfo::MakeDeviceId( + storage_monitor::StorageInfo::MAC_IMAGE_CAPTURE, base::SysNSStringToUTF8([cameraDevice UUIDString])), base::SysNSStringToUTF16([cameraDevice name]), "", @@ -121,12 +124,14 @@ ImageCaptureDeviceManager* g_image_capture_device_manager = NULL; // May delete |device|. [cameras_ removeObject:device]; - notifications_->ProcessDetach( - StorageInfo::MakeDeviceId(StorageInfo::MAC_IMAGE_CAPTURE, uuid)); + notifications_->ProcessDetach(storage_monitor::StorageInfo::MakeDeviceId( + storage_monitor::StorageInfo::MAC_IMAGE_CAPTURE, uuid)); } @end // ImageCaptureDeviceManagerImpl +namespace storage_monitor { + ImageCaptureDeviceManager::ImageCaptureDeviceManager() { device_browser_.reset([[ImageCaptureDeviceManagerImpl alloc] init]); g_image_capture_device_manager = this; @@ -163,3 +168,5 @@ ImageCaptureDevice* ImageCaptureDeviceManager::deviceForUUID( id<ICDeviceBrowserDelegate> ImageCaptureDeviceManager::device_browser() { return device_browser_.get(); } + +} // namespace storage_monitor diff --git a/components/storage_monitor/image_capture_device_manager_unittest.mm b/components/storage_monitor/image_capture_device_manager_unittest.mm index 2f4aae9..01a74df 100644 --- a/components/storage_monitor/image_capture_device_manager_unittest.mm +++ b/components/storage_monitor/image_capture_device_manager_unittest.mm @@ -207,6 +207,8 @@ const char kTestFileContents[] = "test"; @end +namespace storage_monitor { + class TestCameraListener : public ImageCaptureDeviceListener, public base::SupportsWeakPtr<TestCameraListener> { @@ -432,3 +434,5 @@ TEST_F(ImageCaptureDeviceManagerTest, TestSubdirectories) { [camera didRemoveDevice:device]; } + +} // namespace storage_monitor diff --git a/components/storage_monitor/media_storage_util.cc b/components/storage_monitor/media_storage_util.cc index 149f10c..20190d4 100644 --- a/components/storage_monitor/media_storage_util.cc +++ b/components/storage_monitor/media_storage_util.cc @@ -18,6 +18,8 @@ using content::BrowserThread; +namespace storage_monitor { + namespace { // MediaDeviceNotification.DeviceInfo histogram values. @@ -244,3 +246,5 @@ bool MediaStorageUtil::IsRemovableStorageAttached(const std::string& id) { } return false; } + +} // namespace storage_monitor diff --git a/components/storage_monitor/media_storage_util.h b/components/storage_monitor/media_storage_util.h index 7c3ed10..12dcd46 100644 --- a/components/storage_monitor/media_storage_util.h +++ b/components/storage_monitor/media_storage_util.h @@ -15,6 +15,8 @@ #include "base/callback_forward.h" #include "base/files/file_path.h" +namespace storage_monitor { + class StorageInfo; class MediaStorageUtil { @@ -63,4 +65,6 @@ class MediaStorageUtil { DISALLOW_IMPLICIT_CONSTRUCTORS(MediaStorageUtil); }; +} // namespace storage_monitor + #endif // COMPONENTS_STORAGE_MONITOR_MEDIA_STORAGE_UTIL_H_ diff --git a/components/storage_monitor/media_storage_util_unittest.cc b/components/storage_monitor/media_storage_util_unittest.cc index 5f93ce1..1d32e49 100644 --- a/components/storage_monitor/media_storage_util_unittest.cc +++ b/components/storage_monitor/media_storage_util_unittest.cc @@ -25,6 +25,8 @@ const char kImageCaptureDeviceId[] = "ic:xyz"; using content::BrowserThread; +namespace storage_monitor { + class MediaStorageUtilTest : public testing::Test { public: MediaStorageUtilTest() @@ -150,3 +152,5 @@ TEST_F(MediaStorageUtilTest, DetectDeviceFiltered) { EXPECT_TRUE(devices.find(kImageCaptureDeviceId) != devices.end()); } + +} // namespace storage_monitor diff --git a/components/storage_monitor/media_transfer_protocol_device_observer_linux.cc b/components/storage_monitor/media_transfer_protocol_device_observer_linux.cc index 0bd7375..5babbca 100644 --- a/components/storage_monitor/media_transfer_protocol_device_observer_linux.cc +++ b/components/storage_monitor/media_transfer_protocol_device_observer_linux.cc @@ -15,6 +15,8 @@ #include "components/storage_monitor/removable_device_constants.h" #include "device/media_transfer_protocol/mtp_storage_info.pb.h" +namespace storage_monitor { + namespace { // Device root path constant. @@ -237,3 +239,5 @@ bool MediaTransferProtocolDeviceObserverLinux::GetLocationForDeviceId( return false; } + +} // namespace storage_monitor diff --git a/components/storage_monitor/media_transfer_protocol_device_observer_linux.h b/components/storage_monitor/media_transfer_protocol_device_observer_linux.h index 51eaac6..84fee1d 100644 --- a/components/storage_monitor/media_transfer_protocol_device_observer_linux.h +++ b/components/storage_monitor/media_transfer_protocol_device_observer_linux.h @@ -16,6 +16,8 @@ namespace base { class FilePath; } +namespace storage_monitor { + // Gets the mtp device information given a |storage_name|. On success, // fills in |id|, |name| and |location|. typedef void (*GetStorageInfoFunc)( @@ -85,4 +87,6 @@ class MediaTransferProtocolDeviceObserverLinux DISALLOW_COPY_AND_ASSIGN(MediaTransferProtocolDeviceObserverLinux); }; +} // namespace storage_monitor + #endif // COMPONENTS_STORAGE_MONITOR_MEDIA_TRANSFER_PROTOCOL_DEVICE_OBSERVER_LINUX_H_ diff --git a/components/storage_monitor/media_transfer_protocol_device_observer_linux_unittest.cc b/components/storage_monitor/media_transfer_protocol_device_observer_linux_unittest.cc index 5b9274b..4bd6a63 100644 --- a/components/storage_monitor/media_transfer_protocol_device_observer_linux_unittest.cc +++ b/components/storage_monitor/media_transfer_protocol_device_observer_linux_unittest.cc @@ -19,6 +19,8 @@ #include "device/media_transfer_protocol/media_transfer_protocol_manager.h" #include "testing/gtest/include/gtest/gtest.h" +namespace storage_monitor { + namespace { // Sample mtp device storage information. @@ -159,3 +161,5 @@ TEST_F(MediaTransferProtocolDeviceObserverLinuxTest, StorageWithInvalidInfo) { EXPECT_EQ(0, observer().attach_calls()); EXPECT_EQ(0, observer().detach_calls()); } + +} // namespace storage_monitor diff --git a/components/storage_monitor/mock_removable_storage_observer.cc b/components/storage_monitor/mock_removable_storage_observer.cc index f89a8a6..f043391 100644 --- a/components/storage_monitor/mock_removable_storage_observer.cc +++ b/components/storage_monitor/mock_removable_storage_observer.cc @@ -4,6 +4,8 @@ #include "components/storage_monitor/mock_removable_storage_observer.h" +namespace storage_monitor { + MockRemovableStorageObserver::MockRemovableStorageObserver() : attach_calls_(0), detach_calls_(0) { } @@ -22,3 +24,5 @@ void MockRemovableStorageObserver::OnRemovableStorageDetached( detach_calls_++; last_detached_ = info; } + +} // namespace storage_monitor diff --git a/components/storage_monitor/mock_removable_storage_observer.h b/components/storage_monitor/mock_removable_storage_observer.h index 9d8c57c..80019b3 100644 --- a/components/storage_monitor/mock_removable_storage_observer.h +++ b/components/storage_monitor/mock_removable_storage_observer.h @@ -8,6 +8,8 @@ #include "components/storage_monitor/removable_storage_observer.h" #include "components/storage_monitor/storage_info.h" +namespace storage_monitor { + class MockRemovableStorageObserver : public RemovableStorageObserver { public: MockRemovableStorageObserver(); @@ -36,4 +38,6 @@ class MockRemovableStorageObserver : public RemovableStorageObserver { StorageInfo last_detached_; }; +} // namespace storage_monitor + #endif // COMPONENTS_STORAGE_MONITOR_MOCK_REMOVABLE_STORAGE_OBSERVER_H_ diff --git a/components/storage_monitor/mtab_watcher_linux.cc b/components/storage_monitor/mtab_watcher_linux.cc index 353381f..00a9d0c 100644 --- a/components/storage_monitor/mtab_watcher_linux.cc +++ b/components/storage_monitor/mtab_watcher_linux.cc @@ -31,6 +31,8 @@ const char* const kKnownFileSystems[] = { } // namespace +namespace storage_monitor { + MtabWatcherLinux::MtabWatcherLinux(const base::FilePath& mtab_path, base::WeakPtr<Delegate> delegate) : mtab_path_(mtab_path), @@ -100,3 +102,5 @@ void MtabWatcherLinux::OnFilePathChanged( ReadMtab(); } + +} // namespace storage_monitor diff --git a/components/storage_monitor/mtab_watcher_linux.h b/components/storage_monitor/mtab_watcher_linux.h index 7078779..206ed53 100644 --- a/components/storage_monitor/mtab_watcher_linux.h +++ b/components/storage_monitor/mtab_watcher_linux.h @@ -20,6 +20,8 @@ #include "base/files/file_path_watcher.h" #include "base/memory/weak_ptr.h" +namespace storage_monitor { + class MtabWatcherLinux { public: // (mount point, mount device) @@ -59,4 +61,6 @@ class MtabWatcherLinux { DISALLOW_COPY_AND_ASSIGN(MtabWatcherLinux); }; +} // namespace storage_monitor + #endif // COMPONENTS_STORAGE_MONITOR_MTAB_WATCHER_LINUX_H_ diff --git a/components/storage_monitor/portable_device_watcher_win.cc b/components/storage_monitor/portable_device_watcher_win.cc index ad0a547..571bdaf 100644 --- a/components/storage_monitor/portable_device_watcher_win.cc +++ b/components/storage_monitor/portable_device_watcher_win.cc @@ -25,6 +25,8 @@ #include "components/storage_monitor/storage_info.h" #include "content/public/browser/browser_thread.h" +namespace storage_monitor { + namespace { // Name of the client application that communicates with the MTP device. @@ -666,3 +668,5 @@ void PortableDeviceWatcherWin::HandleDeviceDetachEvent( } device_map_.erase(device_iter); } + +} // namespace storage_monitor diff --git a/components/storage_monitor/portable_device_watcher_win.h b/components/storage_monitor/portable_device_watcher_win.h index 494181f..cc5e54a 100644 --- a/components/storage_monitor/portable_device_watcher_win.h +++ b/components/storage_monitor/portable_device_watcher_win.h @@ -20,6 +20,8 @@ namespace base { class SequencedTaskRunner; } +namespace storage_monitor { + class TestPortableDeviceWatcherWin; // This class watches the portable device mount points and sends notifications @@ -139,4 +141,6 @@ class PortableDeviceWatcherWin { DISALLOW_COPY_AND_ASSIGN(PortableDeviceWatcherWin); }; +} // namespace storage_monitor + #endif // COMPONENTS_STORAGE_MONITOR_PORTABLE_DEVICE_WATCHER_WIN_H_ diff --git a/components/storage_monitor/removable_device_constants.cc b/components/storage_monitor/removable_device_constants.cc index 03fa0fd..ce76b23 100644 --- a/components/storage_monitor/removable_device_constants.cc +++ b/components/storage_monitor/removable_device_constants.cc @@ -4,6 +4,8 @@ #include "components/storage_monitor/removable_device_constants.h" +namespace storage_monitor { + const char kFSUniqueIdPrefix[] = "UUID:"; const char kVendorModelSerialPrefix[] = "VendorModelSerial:"; @@ -17,3 +19,5 @@ const base::char16 kWPDDevInterfaceGUID[] = #endif const base::FilePath::CharType kDCIMDirectoryName[] = FILE_PATH_LITERAL("DCIM"); + +} // namespace storage_monitor diff --git a/components/storage_monitor/removable_device_constants.h b/components/storage_monitor/removable_device_constants.h index 236b097..97a059f 100644 --- a/components/storage_monitor/removable_device_constants.h +++ b/components/storage_monitor/removable_device_constants.h @@ -9,6 +9,8 @@ #include "base/strings/string16.h" #include "build/build_config.h" +namespace storage_monitor { + // Prefix constants used in device unique id. extern const char kFSUniqueIdPrefix[]; extern const char kVendorModelSerialPrefix[]; @@ -24,4 +26,6 @@ extern const base::char16 kWPDDevInterfaceGUID[]; extern const base::FilePath::CharType kDCIMDirectoryName[]; +} // namespace storage_monitor + #endif // COMPONENTS_STORAGE_MONITOR_REMOVABLE_DEVICE_CONSTANTS_H_ diff --git a/components/storage_monitor/removable_storage_observer.h b/components/storage_monitor/removable_storage_observer.h index a5db82f..67d578e 100644 --- a/components/storage_monitor/removable_storage_observer.h +++ b/components/storage_monitor/removable_storage_observer.h @@ -7,6 +7,8 @@ #include "components/storage_monitor/storage_info.h" +namespace storage_monitor { + // Clients use this class to register for event-based notifications of // removable storage devices attached to or removed from the system. class RemovableStorageObserver { @@ -23,4 +25,6 @@ class RemovableStorageObserver { virtual ~RemovableStorageObserver() {} }; +} // namespace storage_monitor + #endif // COMPONENTS_STORAGE_MONITOR_REMOVABLE_STORAGE_OBSERVER_H_ diff --git a/components/storage_monitor/storage_info.cc b/components/storage_monitor/storage_info.cc index a389611..b9734e2 100644 --- a/components/storage_monitor/storage_info.cc +++ b/components/storage_monitor/storage_info.cc @@ -20,6 +20,8 @@ const char kIPhotoPrefix[] = "iphoto:"; } // namespace +namespace storage_monitor { + StorageInfo::StorageInfo() : total_size_in_bytes_(0) { } @@ -151,3 +153,5 @@ bool StorageInfo::IsPicasaDevice(const std::string& device_id) { Type type; return CrackDeviceId(device_id, &type, NULL) && type == PICASA; } + +} // namespace storage_monitor diff --git a/components/storage_monitor/storage_info.h b/components/storage_monitor/storage_info.h index 1afdc52..83b6d87 100644 --- a/components/storage_monitor/storage_info.h +++ b/components/storage_monitor/storage_info.h @@ -8,6 +8,8 @@ #include "base/files/file_path.h" #include "base/strings/string16.h" +namespace storage_monitor { + class StorageInfo { public: enum Type { @@ -112,4 +114,6 @@ class StorageInfo { uint64 total_size_in_bytes_; }; +} // namespace storage_monitor + #endif // COMPONENTS_STORAGE_MONITOR_STORAGE_INFO_H_ diff --git a/components/storage_monitor/storage_info_unittest.cc b/components/storage_monitor/storage_info_unittest.cc index 34959d3..e9ef378 100644 --- a/components/storage_monitor/storage_info_unittest.cc +++ b/components/storage_monitor/storage_info_unittest.cc @@ -7,6 +7,8 @@ #include "components/storage_monitor/storage_info.h" #include "testing/gtest/include/gtest/gtest.h" +namespace storage_monitor { + const char kMtpDeviceId[] = "mtp:VendorModelSerial:ABC:1233:1237912873"; const char kUniqueId[] = "VendorModelSerial:ABC:1233:1237912873"; const char kImageCaptureDeviceId[] = "ic:xyz"; @@ -36,3 +38,5 @@ TEST(StorageInfoTest, TestImageCaptureDeviceId) { EXPECT_EQ(StorageInfo::MAC_IMAGE_CAPTURE, type); EXPECT_EQ("xyz", id); } + +} // namespace storage_monitor diff --git a/components/storage_monitor/storage_monitor.cc b/components/storage_monitor/storage_monitor.cc index 5fd39a1..de2c2b7 100644 --- a/components/storage_monitor/storage_monitor.cc +++ b/components/storage_monitor/storage_monitor.cc @@ -9,6 +9,8 @@ #include "components/storage_monitor/removable_storage_observer.h" #include "components/storage_monitor/transient_device_ids.h" +namespace storage_monitor { + namespace { StorageMonitor* g_storage_monitor = NULL; @@ -192,3 +194,5 @@ void StorageMonitor::ProcessDetach(const std::string& id) { &RemovableStorageObserver::OnRemovableStorageDetached, info); } } + +} // namespace storage_monitor diff --git a/components/storage_monitor/storage_monitor.h b/components/storage_monitor/storage_monitor.h index 30c48dd..637c4ce 100644 --- a/components/storage_monitor/storage_monitor.h +++ b/components/storage_monitor/storage_monitor.h @@ -21,15 +21,18 @@ class MediaFileSystemRegistryTest; class MediaGalleriesPlatformAppBrowserTest; class MediaGalleriesPrivateApiTest; -class RemovableStorageObserver; class SystemStorageApiTest; class SystemStorageEjectApiTest; -class TransientDeviceIds; namespace device { class MediaTransferProtocolManager; } +namespace storage_monitor { + +class RemovableStorageObserver; +class TransientDeviceIds; + // Base class for platform-specific instances watching for removable storage // attachments/detachments. // Lifecycle contracts: This class is created in the browser process @@ -188,4 +191,6 @@ class StorageMonitor { scoped_ptr<TransientDeviceIds> transient_device_ids_; }; +} // namespace storage_monitor + #endif // COMPONENTS_STORAGE_MONITOR_STORAGE_MONITOR_H_ diff --git a/components/storage_monitor/storage_monitor_chromeos.cc b/components/storage_monitor/storage_monitor_chromeos.cc index 7428b1d8..ec9301c 100644 --- a/components/storage_monitor/storage_monitor_chromeos.cc +++ b/components/storage_monitor/storage_monitor_chromeos.cc @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// chromeos::StorageMonitorCros implementation. - #include "components/storage_monitor/storage_monitor_chromeos.h" #include "base/files/file_path.h" @@ -19,13 +17,15 @@ #include "content/public/browser/browser_thread.h" #include "device/media_transfer_protocol/media_transfer_protocol_manager.h" -namespace chromeos { +using chromeos::disks::DiskMountManager; + +namespace storage_monitor { namespace { // Constructs a device id using uuid or manufacturer (vendor and product) id // details. -std::string MakeDeviceUniqueId(const disks::DiskMountManager::Disk& disk) { +std::string MakeDeviceUniqueId(const DiskMountManager::Disk& disk) { std::string uuid = disk.fs_uuid(); if (!uuid.empty()) return kFSUniqueIdPrefix + uuid; @@ -44,15 +44,15 @@ std::string MakeDeviceUniqueId(const disks::DiskMountManager::Disk& disk) { // Returns true if the requested device is valid, else false. On success, fills // in |info|. -bool GetDeviceInfo(const disks::DiskMountManager::MountPointInfo& mount_info, +bool GetDeviceInfo(const DiskMountManager::MountPointInfo& mount_info, bool has_dcim, StorageInfo* info) { DCHECK(info); std::string source_path = mount_info.source_path; - const disks::DiskMountManager::Disk* disk = - disks::DiskMountManager::GetInstance()->FindDiskBySourcePath(source_path); - if (!disk || disk->device_type() == DEVICE_TYPE_UNKNOWN) + const DiskMountManager::Disk* disk = + DiskMountManager::GetInstance()->FindDiskBySourcePath(source_path); + if (!disk || disk->device_type() == chromeos::DEVICE_TYPE_UNKNOWN) return false; std::string unique_id = MakeDeviceUniqueId(*disk); @@ -79,7 +79,7 @@ bool GetDeviceInfo(const disks::DiskMountManager::MountPointInfo& mount_info, // Returns whether the mount point in |mount_info| is a media device or not. bool CheckMountedPathOnFileThread( - const disks::DiskMountManager::MountPointInfo& mount_info) { + const DiskMountManager::MountPointInfo& mount_info) { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); return MediaStorageUtil::HasDcim(base::FilePath(mount_info.mount_path)); } @@ -93,15 +93,15 @@ StorageMonitorCros::StorageMonitorCros() } StorageMonitorCros::~StorageMonitorCros() { - disks::DiskMountManager* manager = disks::DiskMountManager::GetInstance(); + DiskMountManager* manager = DiskMountManager::GetInstance(); if (manager) { manager->RemoveObserver(this); } } void StorageMonitorCros::Init() { - DCHECK(disks::DiskMountManager::GetInstance()); - disks::DiskMountManager::GetInstance()->AddObserver(this); + DCHECK(DiskMountManager::GetInstance()); + DiskMountManager::GetInstance()->AddObserver(this); CheckExistingMountPoints(); if (!media_transfer_protocol_manager_) { @@ -117,10 +117,10 @@ void StorageMonitorCros::Init() { void StorageMonitorCros::CheckExistingMountPoints() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - const disks::DiskMountManager::MountPointMap& mount_point_map = - disks::DiskMountManager::GetInstance()->mount_points(); - for (disks::DiskMountManager::MountPointMap::const_iterator it = - mount_point_map.begin(); it != mount_point_map.end(); ++it) { + const DiskMountManager::MountPointMap& mount_point_map = + DiskMountManager::GetInstance()->mount_points(); + for (DiskMountManager::MountPointMap::const_iterator it = + mount_point_map.begin(); it != mount_point_map.end(); ++it) { BrowserThread::PostTaskAndReplyWithResult( BrowserThread::FILE, FROM_HERE, base::Bind(&CheckMountedPathOnFileThread, it->second), @@ -139,33 +139,29 @@ void StorageMonitorCros::CheckExistingMountPoints() { weak_ptr_factory_.GetWeakPtr())); } -void StorageMonitorCros::OnDiskEvent( - disks::DiskMountManager::DiskEvent event, - const disks::DiskMountManager::Disk* disk) { -} +void StorageMonitorCros::OnDiskEvent(DiskMountManager::DiskEvent event, + const DiskMountManager::Disk* disk) {} -void StorageMonitorCros::OnDeviceEvent( - disks::DiskMountManager::DeviceEvent event, - const std::string& device_path) { -} +void StorageMonitorCros::OnDeviceEvent(DiskMountManager::DeviceEvent event, + const std::string& device_path) {} void StorageMonitorCros::OnMountEvent( - disks::DiskMountManager::MountEvent event, - MountError error_code, - const disks::DiskMountManager::MountPointInfo& mount_info) { + DiskMountManager::MountEvent event, + chromeos::MountError error_code, + const DiskMountManager::MountPointInfo& mount_info) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); // Ignore mount points that are not devices. - if (mount_info.mount_type != MOUNT_TYPE_DEVICE) + if (mount_info.mount_type != chromeos::MOUNT_TYPE_DEVICE) return; // Ignore errors. - if (error_code != MOUNT_ERROR_NONE) + if (error_code != chromeos::MOUNT_ERROR_NONE) return; - if (mount_info.mount_condition != disks::MOUNT_CONDITION_NONE) + if (mount_info.mount_condition != chromeos::disks::MOUNT_CONDITION_NONE) return; switch (event) { - case disks::DiskMountManager::MOUNTING: { + case DiskMountManager::MOUNTING: { if (ContainsKey(mount_map_, mount_info.mount_path)) { NOTREACHED(); return; @@ -178,7 +174,7 @@ void StorageMonitorCros::OnMountEvent( weak_ptr_factory_.GetWeakPtr(), mount_info)); break; } - case disks::DiskMountManager::UNMOUNTING: { + case DiskMountManager::UNMOUNTING: { MountMap::iterator it = mount_map_.find(mount_info.mount_path); if (it == mount_map_.end()) return; @@ -189,11 +185,9 @@ void StorageMonitorCros::OnMountEvent( } } -void StorageMonitorCros::OnFormatEvent( - disks::DiskMountManager::FormatEvent event, - FormatError error_code, - const std::string& device_path) { -} +void StorageMonitorCros::OnFormatEvent(DiskMountManager::FormatEvent event, + chromeos::FormatError error_code, + const std::string& device_path) {} void StorageMonitorCros::SetMediaTransferProtocolManagerForTest( device::MediaTransferProtocolManager* test_manager) { @@ -234,7 +228,7 @@ bool StorageMonitorCros::GetStorageInfoForPath( void NotifyUnmountResult( base::Callback<void(StorageMonitor::EjectStatus)> callback, chromeos::MountError error_code) { - if (error_code == MOUNT_ERROR_NONE) + if (error_code == chromeos::MOUNT_ERROR_NONE) callback.Run(StorageMonitor::EJECT_OK); else callback.Run(StorageMonitor::EJECT_FAILURE); @@ -266,7 +260,7 @@ void StorageMonitorCros::EjectDevice( return; } - disks::DiskMountManager* manager = disks::DiskMountManager::GetInstance(); + DiskMountManager* manager = DiskMountManager::GetInstance(); if (!manager) { callback.Run(EJECT_FAILURE); return; @@ -282,7 +276,8 @@ StorageMonitorCros::media_transfer_protocol_manager() { } void StorageMonitorCros::AddMountedPath( - const disks::DiskMountManager::MountPointInfo& mount_info, bool has_dcim) { + const DiskMountManager::MountPointInfo& mount_info, + bool has_dcim) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); if (ContainsKey(mount_map_, mount_info.mount_path)) { @@ -305,8 +300,8 @@ void StorageMonitorCros::AddMountedPath( receiver()->ProcessAttach(info); } -} // namespace chromeos - StorageMonitor* StorageMonitor::CreateInternal() { - return new chromeos::StorageMonitorCros(); + return new StorageMonitorCros(); } + +} // namespace storage_monitor diff --git a/components/storage_monitor/storage_monitor_chromeos.h b/components/storage_monitor/storage_monitor_chromeos.h index 6331753..b3deb54 100644 --- a/components/storage_monitor/storage_monitor_chromeos.h +++ b/components/storage_monitor/storage_monitor_chromeos.h @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// chromeos::StorageMonitorCros listens for mount point changes and notifies -// listeners about the addition and deletion of media devices. -// This class lives on the UI thread. +// StorageMonitorCros listens for mount point changes and notifies listeners +// about the addition and deletion of media devices. This class lives on the +// UI thread. #ifndef COMPONENTS_STORAGE_MONITOR_STORAGE_MONITOR_CHROMEOS_H_ #define COMPONENTS_STORAGE_MONITOR_STORAGE_MONITOR_CHROMEOS_H_ @@ -23,12 +23,12 @@ #include "chromeos/disks/disk_mount_manager.h" #include "components/storage_monitor/storage_monitor.h" -class MediaTransferProtocolDeviceObserverLinux; +namespace storage_monitor { -namespace chromeos { +class MediaTransferProtocolDeviceObserverLinux; class StorageMonitorCros : public StorageMonitor, - public disks::DiskMountManager::Observer { + public chromeos::disks::DiskMountManager::Observer { public: // Should only be called by browser start up code. // Use StorageMonitor::GetInstance() instead. @@ -43,18 +43,22 @@ class StorageMonitorCros : public StorageMonitor, void SetMediaTransferProtocolManagerForTest( device::MediaTransferProtocolManager* test_manager); - // disks::DiskMountManager::Observer implementation. - virtual void OnDiskEvent(disks::DiskMountManager::DiskEvent event, - const disks::DiskMountManager::Disk* disk) OVERRIDE; - virtual void OnDeviceEvent(disks::DiskMountManager::DeviceEvent event, - const std::string& device_path) OVERRIDE; + // chromeos::disks::DiskMountManager::Observer implementation. + virtual void OnDiskEvent( + chromeos::disks::DiskMountManager::DiskEvent event, + const chromeos::disks::DiskMountManager::Disk* disk) OVERRIDE; + virtual void OnDeviceEvent( + chromeos::disks::DiskMountManager::DeviceEvent event, + const std::string& device_path) OVERRIDE; virtual void OnMountEvent( - disks::DiskMountManager::MountEvent event, - MountError error_code, - const disks::DiskMountManager::MountPointInfo& mount_info) OVERRIDE; - virtual void OnFormatEvent(disks::DiskMountManager::FormatEvent event, - FormatError error_code, - const std::string& device_path) OVERRIDE; + chromeos::disks::DiskMountManager::MountEvent event, + chromeos::MountError error_code, + const chromeos::disks::DiskMountManager::MountPointInfo& mount_info) + OVERRIDE; + virtual void OnFormatEvent( + chromeos::disks::DiskMountManager::FormatEvent event, + chromeos::FormatError error_code, + const std::string& device_path) OVERRIDE; // StorageMonitor implementation. virtual bool GetStorageInfoForPath(const base::FilePath& path, @@ -76,8 +80,9 @@ class StorageMonitorCros : public StorageMonitor, // Adds the mount point in |mount_info| to |mount_map_| and send a media // device attach notification. |has_dcim| is true if the attached device has // a DCIM folder. - void AddMountedPath(const disks::DiskMountManager::MountPointInfo& mount_info, - bool has_dcim); + void AddMountedPath( + const chromeos::disks::DiskMountManager::MountPointInfo& mount_info, + bool has_dcim); // Mapping of relevant mount points and their corresponding mount devices. MountMap mount_map_; @@ -92,6 +97,6 @@ class StorageMonitorCros : public StorageMonitor, DISALLOW_COPY_AND_ASSIGN(StorageMonitorCros); }; -} // namespace chromeos +} // namespace storage_monitor #endif // COMPONENTS_STORAGE_MONITOR_STORAGE_MONITOR_CHROMEOS_H_ diff --git a/components/storage_monitor/storage_monitor_chromeos_unittest.cc b/components/storage_monitor/storage_monitor_chromeos_unittest.cc index b47cb12..60f5364 100644 --- a/components/storage_monitor/storage_monitor_chromeos_unittest.cc +++ b/components/storage_monitor/storage_monitor_chromeos_unittest.cc @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// chromeos::StorageMonitorCros unit tests. - #include "components/storage_monitor/storage_monitor_chromeos.h" #include "base/file_util.h" @@ -22,12 +20,12 @@ #include "content/public/test/test_browser_thread_bundle.h" #include "testing/gtest/include/gtest/gtest.h" -namespace chromeos { +namespace storage_monitor { namespace { using content::BrowserThread; -using disks::DiskMountManager; +using chromeos::disks::DiskMountManager; using testing::_; const char kDevice1[] = "/dev/d1"; @@ -69,10 +67,9 @@ class TestStorageMonitorCros : public StorageMonitorCros { StorageMonitorCros::Init(); } - virtual void OnMountEvent( - disks::DiskMountManager::MountEvent event, - MountError error_code, - const disks::DiskMountManager::MountPointInfo& mount_info) OVERRIDE { + virtual void OnMountEvent(DiskMountManager::MountEvent event, + chromeos::MountError error_code, + const DiskMountManager::MountPointInfo& mount_info) OVERRIDE { StorageMonitorCros::OnMountEvent(event, error_code, mount_info); } @@ -103,16 +100,16 @@ class StorageMonitorCrosTest : public testing::Test { virtual void SetUp() OVERRIDE; virtual void TearDown() OVERRIDE; - void MountDevice(MountError error_code, + void MountDevice(chromeos::MountError error_code, const DiskMountManager::MountPointInfo& mount_info, const std::string& unique_id, const std::string& device_label, const std::string& vendor_name, const std::string& product_name, - DeviceType device_type, + chromeos::DeviceType device_type, uint64 device_size_in_bytes); - void UnmountDevice(MountError error_code, + void UnmountDevice(chromeos::MountError error_code, const DiskMountManager::MountPointInfo& mount_info); uint64 GetDeviceStorageSize(const std::string& device_location); @@ -134,7 +131,7 @@ class StorageMonitorCrosTest : public testing::Test { TestStorageMonitorCros* monitor_; // Owned by DiskMountManager. - disks::MockDiskMountManager* disk_mount_manager_mock_; + chromeos::disks::MockDiskMountManager* disk_mount_manager_mock_; StorageMonitor::EjectStatus status_; @@ -163,7 +160,7 @@ StorageMonitorCrosTest::~StorageMonitorCrosTest() { void StorageMonitorCrosTest::SetUp() { ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir()); - disk_mount_manager_mock_ = new disks::MockDiskMountManager(); + disk_mount_manager_mock_ = new chromeos::disks::MockDiskMountManager(); DiskMountManager::InitializeForTesting(disk_mount_manager_mock_); disk_mount_manager_mock_->SetupDefaultReplies(); @@ -189,30 +186,28 @@ void StorageMonitorCrosTest::TearDown() { } void StorageMonitorCrosTest::MountDevice( - MountError error_code, + chromeos::MountError error_code, const DiskMountManager::MountPointInfo& mount_info, const std::string& unique_id, const std::string& device_label, const std::string& vendor_name, const std::string& product_name, - DeviceType device_type, + chromeos::DeviceType device_type, uint64 device_size_in_bytes) { - if (error_code == MOUNT_ERROR_NONE) { + if (error_code == chromeos::MOUNT_ERROR_NONE) { disk_mount_manager_mock_->CreateDiskEntryForMountDevice( mount_info, unique_id, device_label, vendor_name, product_name, device_type, device_size_in_bytes); } - monitor_->OnMountEvent(disks::DiskMountManager::MOUNTING, error_code, - mount_info); + monitor_->OnMountEvent(DiskMountManager::MOUNTING, error_code, mount_info); WaitForFileThread(); } void StorageMonitorCrosTest::UnmountDevice( - MountError error_code, + chromeos::MountError error_code, const DiskMountManager::MountPointInfo& mount_info) { - monitor_->OnMountEvent(disks::DiskMountManager::UNMOUNTING, error_code, - mount_info); - if (error_code == MOUNT_ERROR_NONE) + monitor_->OnMountEvent(DiskMountManager::UNMOUNTING, error_code, mount_info); + if (error_code == chromeos::MOUNT_ERROR_NONE) disk_mount_manager_mock_->RemoveDiskEntryForMountDevice(mount_info); WaitForFileThread(); } @@ -259,12 +254,19 @@ void StorageMonitorCrosTest::EjectNotify(StorageMonitor::EjectStatus status) { TEST_F(StorageMonitorCrosTest, BasicAttachDetach) { base::FilePath mount_path1 = CreateMountPoint(kMountPointA, true); ASSERT_FALSE(mount_path1.empty()); - DiskMountManager::MountPointInfo mount_info(kDevice1, - mount_path1.value(), - MOUNT_TYPE_DEVICE, - disks::MOUNT_CONDITION_NONE); - MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId1, kDevice1Name, - kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes); + DiskMountManager::MountPointInfo mount_info( + kDevice1, + mount_path1.value(), + chromeos::MOUNT_TYPE_DEVICE, + chromeos::disks::MOUNT_CONDITION_NONE); + MountDevice(chromeos::MOUNT_ERROR_NONE, + mount_info, + kUniqueId1, + kDevice1Name, + kVendorName, + kProductName, + chromeos::DEVICE_TYPE_USB, + kDevice1SizeInBytes); EXPECT_EQ(1, observer().attach_calls()); EXPECT_EQ(0, observer().detach_calls()); EXPECT_EQ(GetDCIMDeviceId(kUniqueId1), @@ -272,7 +274,7 @@ TEST_F(StorageMonitorCrosTest, BasicAttachDetach) { EXPECT_EQ(base::string16(), observer().last_attached().name()); EXPECT_EQ(mount_path1.value(), observer().last_attached().location()); - UnmountDevice(MOUNT_ERROR_NONE, mount_info); + UnmountDevice(chromeos::MOUNT_ERROR_NONE, mount_info); EXPECT_EQ(1, observer().attach_calls()); EXPECT_EQ(1, observer().detach_calls()); EXPECT_EQ(GetDCIMDeviceId(kUniqueId1), @@ -280,12 +282,19 @@ TEST_F(StorageMonitorCrosTest, BasicAttachDetach) { base::FilePath mount_path2 = CreateMountPoint(kMountPointB, true); ASSERT_FALSE(mount_path2.empty()); - DiskMountManager::MountPointInfo mount_info2(kDevice2, - mount_path2.value(), - MOUNT_TYPE_DEVICE, - disks::MOUNT_CONDITION_NONE); - MountDevice(MOUNT_ERROR_NONE, mount_info2, kUniqueId2, kDevice2Name, - kVendorName, kProductName, DEVICE_TYPE_USB, kDevice2SizeInBytes); + DiskMountManager::MountPointInfo mount_info2( + kDevice2, + mount_path2.value(), + chromeos::MOUNT_TYPE_DEVICE, + chromeos::disks::MOUNT_CONDITION_NONE); + MountDevice(chromeos::MOUNT_ERROR_NONE, + mount_info2, + kUniqueId2, + kDevice2Name, + kVendorName, + kProductName, + chromeos::DEVICE_TYPE_USB, + kDevice2SizeInBytes); EXPECT_EQ(2, observer().attach_calls()); EXPECT_EQ(1, observer().detach_calls()); EXPECT_EQ(GetDCIMDeviceId(kUniqueId2), @@ -293,7 +302,7 @@ TEST_F(StorageMonitorCrosTest, BasicAttachDetach) { EXPECT_EQ(base::string16(), observer().last_attached().name()); EXPECT_EQ(mount_path2.value(), observer().last_attached().location()); - UnmountDevice(MOUNT_ERROR_NONE, mount_info2); + UnmountDevice(chromeos::MOUNT_ERROR_NONE, mount_info2); EXPECT_EQ(2, observer().attach_calls()); EXPECT_EQ(2, observer().detach_calls()); EXPECT_EQ(GetDCIMDeviceId(kUniqueId2), @@ -306,15 +315,22 @@ TEST_F(StorageMonitorCrosTest, NoDCIM) { base::FilePath mount_path = CreateMountPoint(kMountPointA, false); const std::string kUniqueId = "FFFF-FFFF"; ASSERT_FALSE(mount_path.empty()); - DiskMountManager::MountPointInfo mount_info(kDevice1, - mount_path.value(), - MOUNT_TYPE_DEVICE, - disks::MOUNT_CONDITION_NONE); + DiskMountManager::MountPointInfo mount_info( + kDevice1, + mount_path.value(), + chromeos::MOUNT_TYPE_DEVICE, + chromeos::disks::MOUNT_CONDITION_NONE); const std::string device_id = StorageInfo::MakeDeviceId( StorageInfo::REMOVABLE_MASS_STORAGE_NO_DCIM, kFSUniqueIdPrefix + kUniqueId); - MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId, kDevice1Name, - kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes); + MountDevice(chromeos::MOUNT_ERROR_NONE, + mount_info, + kUniqueId, + kDevice1Name, + kVendorName, + kProductName, + chromeos::DEVICE_TYPE_USB, + kDevice1SizeInBytes); EXPECT_EQ(1, observer().attach_calls()); EXPECT_EQ(0, observer().detach_calls()); EXPECT_EQ(device_id, observer().last_attached().device_id()); @@ -330,27 +346,47 @@ TEST_F(StorageMonitorCrosTest, Ignore) { ASSERT_FALSE(mount_path.empty()); // Mount error. - DiskMountManager::MountPointInfo mount_info(kDevice1, - mount_path.value(), - MOUNT_TYPE_DEVICE, - disks::MOUNT_CONDITION_NONE); - MountDevice(MOUNT_ERROR_UNKNOWN, mount_info, kUniqueId, kDevice1Name, - kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes); + DiskMountManager::MountPointInfo mount_info( + kDevice1, + mount_path.value(), + chromeos::MOUNT_TYPE_DEVICE, + chromeos::disks::MOUNT_CONDITION_NONE); + MountDevice(chromeos::MOUNT_ERROR_UNKNOWN, + mount_info, + kUniqueId, + kDevice1Name, + kVendorName, + kProductName, + chromeos::DEVICE_TYPE_USB, + kDevice1SizeInBytes); EXPECT_EQ(0, observer().attach_calls()); EXPECT_EQ(0, observer().detach_calls()); // Not a device - mount_info.mount_type = MOUNT_TYPE_ARCHIVE; - MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId, kDevice1Name, - kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes); + mount_info.mount_type = chromeos::MOUNT_TYPE_ARCHIVE; + MountDevice(chromeos::MOUNT_ERROR_NONE, + mount_info, + kUniqueId, + kDevice1Name, + kVendorName, + kProductName, + chromeos::DEVICE_TYPE_USB, + kDevice1SizeInBytes); EXPECT_EQ(0, observer().attach_calls()); EXPECT_EQ(0, observer().detach_calls()); // Unsupported file system. - mount_info.mount_type = MOUNT_TYPE_DEVICE; - mount_info.mount_condition = disks::MOUNT_CONDITION_UNSUPPORTED_FILESYSTEM; - MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId, kDevice1Name, - kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes); + mount_info.mount_type = chromeos::MOUNT_TYPE_DEVICE; + mount_info.mount_condition = + chromeos::disks::MOUNT_CONDITION_UNSUPPORTED_FILESYSTEM; + MountDevice(chromeos::MOUNT_ERROR_NONE, + mount_info, + kUniqueId, + kDevice1Name, + kVendorName, + kProductName, + chromeos::DEVICE_TYPE_USB, + kDevice1SizeInBytes); EXPECT_EQ(0, observer().attach_calls()); EXPECT_EQ(0, observer().detach_calls()); } @@ -358,12 +394,19 @@ TEST_F(StorageMonitorCrosTest, Ignore) { TEST_F(StorageMonitorCrosTest, SDCardAttachDetach) { base::FilePath mount_path1 = CreateMountPoint(kSDCardMountPoint1, true); ASSERT_FALSE(mount_path1.empty()); - DiskMountManager::MountPointInfo mount_info1(kSDCardDeviceName1, - mount_path1.value(), - MOUNT_TYPE_DEVICE, - disks::MOUNT_CONDITION_NONE); - MountDevice(MOUNT_ERROR_NONE, mount_info1, kUniqueId2, kSDCardDeviceName1, - kVendorName, kProductName, DEVICE_TYPE_SD, kSDCardSizeInBytes); + DiskMountManager::MountPointInfo mount_info1( + kSDCardDeviceName1, + mount_path1.value(), + chromeos::MOUNT_TYPE_DEVICE, + chromeos::disks::MOUNT_CONDITION_NONE); + MountDevice(chromeos::MOUNT_ERROR_NONE, + mount_info1, + kUniqueId2, + kSDCardDeviceName1, + kVendorName, + kProductName, + chromeos::DEVICE_TYPE_SD, + kSDCardSizeInBytes); EXPECT_EQ(1, observer().attach_calls()); EXPECT_EQ(0, observer().detach_calls()); EXPECT_EQ(GetDCIMDeviceId(kUniqueId2), @@ -371,7 +414,7 @@ TEST_F(StorageMonitorCrosTest, SDCardAttachDetach) { EXPECT_EQ(base::string16(), observer().last_attached().name()); EXPECT_EQ(mount_path1.value(), observer().last_attached().location()); - UnmountDevice(MOUNT_ERROR_NONE, mount_info1); + UnmountDevice(chromeos::MOUNT_ERROR_NONE, mount_info1); EXPECT_EQ(1, observer().attach_calls()); EXPECT_EQ(1, observer().detach_calls()); EXPECT_EQ(GetDCIMDeviceId(kUniqueId2), @@ -379,12 +422,19 @@ TEST_F(StorageMonitorCrosTest, SDCardAttachDetach) { base::FilePath mount_path2 = CreateMountPoint(kSDCardMountPoint2, true); ASSERT_FALSE(mount_path2.empty()); - DiskMountManager::MountPointInfo mount_info2(kSDCardDeviceName2, - mount_path2.value(), - MOUNT_TYPE_DEVICE, - disks::MOUNT_CONDITION_NONE); - MountDevice(MOUNT_ERROR_NONE, mount_info2, kUniqueId2, kSDCardDeviceName2, - kVendorName, kProductName, DEVICE_TYPE_SD, kSDCardSizeInBytes); + DiskMountManager::MountPointInfo mount_info2( + kSDCardDeviceName2, + mount_path2.value(), + chromeos::MOUNT_TYPE_DEVICE, + chromeos::disks::MOUNT_CONDITION_NONE); + MountDevice(chromeos::MOUNT_ERROR_NONE, + mount_info2, + kUniqueId2, + kSDCardDeviceName2, + kVendorName, + kProductName, + chromeos::DEVICE_TYPE_SD, + kSDCardSizeInBytes); EXPECT_EQ(2, observer().attach_calls()); EXPECT_EQ(1, observer().detach_calls()); EXPECT_EQ(GetDCIMDeviceId(kUniqueId2), @@ -392,7 +442,7 @@ TEST_F(StorageMonitorCrosTest, SDCardAttachDetach) { EXPECT_EQ(base::string16(), observer().last_attached().name()); EXPECT_EQ(mount_path2.value(), observer().last_attached().location()); - UnmountDevice(MOUNT_ERROR_NONE, mount_info2); + UnmountDevice(chromeos::MOUNT_ERROR_NONE, mount_info2); EXPECT_EQ(2, observer().attach_calls()); EXPECT_EQ(2, observer().detach_calls()); EXPECT_EQ(GetDCIMDeviceId(kUniqueId2), @@ -402,12 +452,19 @@ TEST_F(StorageMonitorCrosTest, SDCardAttachDetach) { TEST_F(StorageMonitorCrosTest, AttachDeviceWithEmptyLabel) { base::FilePath mount_path1 = CreateMountPoint(kMountPointA, true); ASSERT_FALSE(mount_path1.empty()); - DiskMountManager::MountPointInfo mount_info(kEmptyDeviceLabel, - mount_path1.value(), - MOUNT_TYPE_DEVICE, - disks::MOUNT_CONDITION_NONE); - MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId1, kEmptyDeviceLabel, - kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes); + DiskMountManager::MountPointInfo mount_info( + kEmptyDeviceLabel, + mount_path1.value(), + chromeos::MOUNT_TYPE_DEVICE, + chromeos::disks::MOUNT_CONDITION_NONE); + MountDevice(chromeos::MOUNT_ERROR_NONE, + mount_info, + kUniqueId1, + kEmptyDeviceLabel, + kVendorName, + kProductName, + chromeos::DEVICE_TYPE_USB, + kDevice1SizeInBytes); EXPECT_EQ(1, observer().attach_calls()); EXPECT_EQ(0, observer().detach_calls()); EXPECT_EQ(GetDCIMDeviceId(kUniqueId1), @@ -415,7 +472,7 @@ TEST_F(StorageMonitorCrosTest, AttachDeviceWithEmptyLabel) { EXPECT_EQ(base::string16(), observer().last_attached().name()); EXPECT_EQ(mount_path1.value(), observer().last_attached().location()); - UnmountDevice(MOUNT_ERROR_NONE, mount_info); + UnmountDevice(chromeos::MOUNT_ERROR_NONE, mount_info); EXPECT_EQ(1, observer().attach_calls()); EXPECT_EQ(1, observer().detach_calls()); EXPECT_EQ(GetDCIMDeviceId(kUniqueId1), @@ -425,12 +482,19 @@ TEST_F(StorageMonitorCrosTest, AttachDeviceWithEmptyLabel) { TEST_F(StorageMonitorCrosTest, GetStorageSize) { base::FilePath mount_path1 = CreateMountPoint(kMountPointA, true); ASSERT_FALSE(mount_path1.empty()); - DiskMountManager::MountPointInfo mount_info(kEmptyDeviceLabel, - mount_path1.value(), - MOUNT_TYPE_DEVICE, - disks::MOUNT_CONDITION_NONE); - MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId1, kEmptyDeviceLabel, - kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes); + DiskMountManager::MountPointInfo mount_info( + kEmptyDeviceLabel, + mount_path1.value(), + chromeos::MOUNT_TYPE_DEVICE, + chromeos::disks::MOUNT_CONDITION_NONE); + MountDevice(chromeos::MOUNT_ERROR_NONE, + mount_info, + kUniqueId1, + kEmptyDeviceLabel, + kVendorName, + kProductName, + chromeos::DEVICE_TYPE_USB, + kDevice1SizeInBytes); EXPECT_EQ(1, observer().attach_calls()); EXPECT_EQ(0, observer().detach_calls()); EXPECT_EQ(GetDCIMDeviceId(kUniqueId1), @@ -439,7 +503,7 @@ TEST_F(StorageMonitorCrosTest, GetStorageSize) { EXPECT_EQ(mount_path1.value(), observer().last_attached().location()); EXPECT_EQ(kDevice1SizeInBytes, GetDeviceStorageSize(mount_path1.value())); - UnmountDevice(MOUNT_ERROR_NONE, mount_info); + UnmountDevice(chromeos::MOUNT_ERROR_NONE, mount_info); EXPECT_EQ(1, observer().attach_calls()); EXPECT_EQ(1, observer().detach_calls()); EXPECT_EQ(GetDCIMDeviceId(kUniqueId1), @@ -447,7 +511,7 @@ TEST_F(StorageMonitorCrosTest, GetStorageSize) { } void UnmountFake(const std::string& location, - UnmountOptions options, + chromeos::UnmountOptions options, const DiskMountManager::UnmountPathCallback& cb) { cb.Run(chromeos::MOUNT_ERROR_NONE); } @@ -455,12 +519,19 @@ void UnmountFake(const std::string& location, TEST_F(StorageMonitorCrosTest, EjectTest) { base::FilePath mount_path1 = CreateMountPoint(kMountPointA, true); ASSERT_FALSE(mount_path1.empty()); - DiskMountManager::MountPointInfo mount_info(kEmptyDeviceLabel, - mount_path1.value(), - MOUNT_TYPE_DEVICE, - disks::MOUNT_CONDITION_NONE); - MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId1, kEmptyDeviceLabel, - kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes); + DiskMountManager::MountPointInfo mount_info( + kEmptyDeviceLabel, + mount_path1.value(), + chromeos::MOUNT_TYPE_DEVICE, + chromeos::disks::MOUNT_CONDITION_NONE); + MountDevice(chromeos::MOUNT_ERROR_NONE, + mount_info, + kUniqueId1, + kEmptyDeviceLabel, + kVendorName, + kProductName, + chromeos::DEVICE_TYPE_USB, + kDevice1SizeInBytes); EXPECT_EQ(1, observer().attach_calls()); EXPECT_EQ(0, observer().detach_calls()); @@ -478,4 +549,4 @@ TEST_F(StorageMonitorCrosTest, EjectTest) { } // namespace -} // namespace chromeos +} // namespace storage_monitor diff --git a/components/storage_monitor/storage_monitor_linux.cc b/components/storage_monitor/storage_monitor_linux.cc index f18a133..76cfdfd 100644 --- a/components/storage_monitor/storage_monitor_linux.cc +++ b/components/storage_monitor/storage_monitor_linux.cc @@ -28,6 +28,9 @@ #include "device/media_transfer_protocol/media_transfer_protocol_manager.h" using content::BrowserThread; + +namespace storage_monitor { + typedef MtabWatcherLinux::MountPointDeviceMap MountPointDeviceMap; namespace { @@ -500,3 +503,5 @@ StorageMonitor* StorageMonitor::CreateInternal() { const base::FilePath kDefaultMtabPath("/etc/mtab"); return new StorageMonitorLinux(kDefaultMtabPath); } + +} // namespace storage_monitor diff --git a/components/storage_monitor/storage_monitor_linux.h b/components/storage_monitor/storage_monitor_linux.h index 74ee260..9bd0e13 100644 --- a/components/storage_monitor/storage_monitor_linux.h +++ b/components/storage_monitor/storage_monitor_linux.h @@ -28,6 +28,8 @@ #include "components/storage_monitor/storage_monitor.h" #include "content/public/browser/browser_thread.h" +namespace storage_monitor { + class MediaTransferProtocolDeviceObserverLinux; class StorageMonitorLinux : public StorageMonitor, @@ -139,4 +141,6 @@ class StorageMonitorLinux : public StorageMonitor, DISALLOW_COPY_AND_ASSIGN(StorageMonitorLinux); }; +} // namespace storage_monitor + #endif // COMPONENTS_STORAGE_MONITOR_STORAGE_MONITOR_LINUX_H_ diff --git a/components/storage_monitor/storage_monitor_linux_unittest.cc b/components/storage_monitor/storage_monitor_linux_unittest.cc index 3b37e0a..7949ae0 100644 --- a/components/storage_monitor/storage_monitor_linux_unittest.cc +++ b/components/storage_monitor/storage_monitor_linux_unittest.cc @@ -26,6 +26,8 @@ #include "content/public/test/test_browser_thread_bundle.h" #include "testing/gtest/include/gtest/gtest.h" +namespace storage_monitor { + namespace { const char kValidFS[] = "vfat"; @@ -679,3 +681,5 @@ TEST_F(StorageMonitorLinuxTest, DevicePartitionSize) { } } // namespace + +} // namespace storage_monitor diff --git a/components/storage_monitor/storage_monitor_mac.h b/components/storage_monitor/storage_monitor_mac.h index 7fa1231..f107058 100644 --- a/components/storage_monitor/storage_monitor_mac.h +++ b/components/storage_monitor/storage_monitor_mac.h @@ -12,6 +12,8 @@ #include "base/memory/weak_ptr.h" #include "components/storage_monitor/storage_monitor.h" +namespace storage_monitor { + class ImageCaptureDeviceManager; // This class posts notifications to listeners when a new disk @@ -69,4 +71,6 @@ class StorageMonitorMac : public StorageMonitor, DISALLOW_COPY_AND_ASSIGN(StorageMonitorMac); }; +} // namespace storage_monitor + #endif // COMPONENTS_STORAGE_MONITOR_STORAGE_MONITOR_MAC_H_ diff --git a/components/storage_monitor/storage_monitor_mac.mm b/components/storage_monitor/storage_monitor_mac.mm index b326749..a2ba2e3 100644 --- a/components/storage_monitor/storage_monitor_mac.mm +++ b/components/storage_monitor/storage_monitor_mac.mm @@ -13,6 +13,8 @@ #include "components/storage_monitor/storage_info.h" #include "content/public/browser/browser_thread.h" +namespace storage_monitor { + namespace { const char kDiskImageModelName[] = "Disk Image"; @@ -385,3 +387,5 @@ bool StorageMonitorMac::FindDiskWithMountPoint( StorageMonitor* StorageMonitor::CreateInternal() { return new StorageMonitorMac(); } + +} // namespace storage_monitor diff --git a/components/storage_monitor/storage_monitor_mac_unittest.mm b/components/storage_monitor/storage_monitor_mac_unittest.mm index 9b63601..f8d79b3 100644 --- a/components/storage_monitor/storage_monitor_mac_unittest.mm +++ b/components/storage_monitor/storage_monitor_mac_unittest.mm @@ -21,6 +21,8 @@ uint64 kTestSize = 1000000ULL; +namespace storage_monitor { + namespace { StorageInfo CreateStorageInfo( @@ -171,3 +173,5 @@ TEST_F(StorageMonitorMacTest, DMG) { UpdateDisk(info, StorageMonitorMac::UPDATE_DEVICE_ADDED); EXPECT_EQ(0, mock_storage_observer_->attach_calls()); } + +} // namespace storage_monitor diff --git a/components/storage_monitor/storage_monitor_unittest.cc b/components/storage_monitor/storage_monitor_unittest.cc index 82a6574..dd11ed7 100644 --- a/components/storage_monitor/storage_monitor_unittest.cc +++ b/components/storage_monitor/storage_monitor_unittest.cc @@ -18,6 +18,8 @@ void SetLatch(bool* called) { } // namespace +namespace storage_monitor { + TEST(StorageMonitorTest, TestInitialize) { TestStorageMonitor::Destroy(); TestStorageMonitor monitor; @@ -133,3 +135,5 @@ TEST(StorageMonitorTest, GetAllAvailableStorageAttachDetach) { devices = monitor.GetAllAvailableStorages(); EXPECT_EQ(0U, devices.size()); } + +} // namespace storage_monitor diff --git a/components/storage_monitor/storage_monitor_win.cc b/components/storage_monitor/storage_monitor_win.cc index ccc8aec..fb721bb 100644 --- a/components/storage_monitor/storage_monitor_win.cc +++ b/components/storage_monitor/storage_monitor_win.cc @@ -16,6 +16,8 @@ // StorageMonitorWin ------------------------------------------------------- +namespace storage_monitor { + StorageMonitorWin::StorageMonitorWin( VolumeMountWatcherWin* volume_mount_watcher, PortableDeviceWatcherWin* portable_device_watcher) @@ -162,3 +164,5 @@ StorageMonitor* StorageMonitor::CreateInternal() { return new StorageMonitorWin(new VolumeMountWatcherWin(), new PortableDeviceWatcherWin()); } + +} // namespace storage_monitor diff --git a/components/storage_monitor/storage_monitor_win.h b/components/storage_monitor/storage_monitor_win.h index 773c7fe..f59b3c3 100644 --- a/components/storage_monitor/storage_monitor_win.h +++ b/components/storage_monitor/storage_monitor_win.h @@ -14,6 +14,8 @@ namespace base { class FilePath; } +namespace storage_monitor { + class PortableDeviceWatcherWin; class TestStorageMonitorWin; class VolumeMountWatcherWin; @@ -78,4 +80,6 @@ class StorageMonitorWin : public StorageMonitor { DISALLOW_COPY_AND_ASSIGN(StorageMonitorWin); }; +} // namespace storage_monitor + #endif // COMPONENTS_STORAGE_MONITOR_STORAGE_MONITOR_WIN_H_ diff --git a/components/storage_monitor/storage_monitor_win_unittest.cc b/components/storage_monitor/storage_monitor_win_unittest.cc index 6ef9e0d..40645a8 100644 --- a/components/storage_monitor/storage_monitor_win_unittest.cc +++ b/components/storage_monitor/storage_monitor_win_unittest.cc @@ -34,6 +34,8 @@ typedef std::vector<int> DeviceIndices; // StorageMonitorWinTest ------------------------------------------------------- +namespace storage_monitor { + class StorageMonitorWinTest : public testing::Test { public: StorageMonitorWinTest(); @@ -544,3 +546,5 @@ TEST_F(StorageMonitorWinTest, GetMTPStorageInfoFromDeviceId) { } DoMTPDeviceTest(TestPortableDeviceWatcherWin::kMTPDeviceWithValidInfo, false); } + +} // namespace storage_monitor diff --git a/components/storage_monitor/test_media_transfer_protocol_manager_linux.cc b/components/storage_monitor/test_media_transfer_protocol_manager_linux.cc index 0fdfe50..2763d30 100644 --- a/components/storage_monitor/test_media_transfer_protocol_manager_linux.cc +++ b/components/storage_monitor/test_media_transfer_protocol_manager_linux.cc @@ -6,6 +6,8 @@ #include "device/media_transfer_protocol/mtp_file_entry.pb.h" +namespace storage_monitor { + TestMediaTransferProtocolManagerLinux:: TestMediaTransferProtocolManagerLinux() {} @@ -84,3 +86,5 @@ void TestMediaTransferProtocolManagerLinux::GetFileInfoById( const GetFileInfoCallback& callback) { callback.Run(MtpFileEntry(), true); } + +} // namespace storage_monitor diff --git a/components/storage_monitor/test_media_transfer_protocol_manager_linux.h b/components/storage_monitor/test_media_transfer_protocol_manager_linux.h index 34d163b..b2ccc4e 100644 --- a/components/storage_monitor/test_media_transfer_protocol_manager_linux.h +++ b/components/storage_monitor/test_media_transfer_protocol_manager_linux.h @@ -7,6 +7,8 @@ #include "device/media_transfer_protocol/media_transfer_protocol_manager.h" +namespace storage_monitor { + // A dummy MediaTransferProtocolManager implementation. class TestMediaTransferProtocolManagerLinux : public device::MediaTransferProtocolManager { @@ -54,4 +56,6 @@ class TestMediaTransferProtocolManagerLinux DISALLOW_COPY_AND_ASSIGN(TestMediaTransferProtocolManagerLinux); }; +} // namespace storage_monitor + #endif // COMPONENTS_STORAGE_MONITOR_TEST_MEDIA_TRANSFER_PROTOCOL_MANAGER_LINUX_H_ diff --git a/components/storage_monitor/test_portable_device_watcher_win.cc b/components/storage_monitor/test_portable_device_watcher_win.cc index 5a85a25..03ef756 100644 --- a/components/storage_monitor/test_portable_device_watcher_win.cc +++ b/components/storage_monitor/test_portable_device_watcher_win.cc @@ -10,6 +10,8 @@ #include "base/strings/utf_string_conversions.h" +namespace storage_monitor { + namespace { // Sample MTP device storage information. @@ -143,3 +145,5 @@ bool TestPortableDeviceWatcherWin::GetMTPStorageInfoFromDeviceId( return PortableDeviceWatcherWin::GetMTPStorageInfoFromDeviceId( storage_device_id, device_location, storage_object_id); } + +} // namespace storage_monitor diff --git a/components/storage_monitor/test_portable_device_watcher_win.h b/components/storage_monitor/test_portable_device_watcher_win.h index 976a5ac..ed773ed 100644 --- a/components/storage_monitor/test_portable_device_watcher_win.h +++ b/components/storage_monitor/test_portable_device_watcher_win.h @@ -13,6 +13,8 @@ #include "base/strings/string16.h" #include "components/storage_monitor/portable_device_watcher_win.h" +namespace storage_monitor { + class TestPortableDeviceWatcherWin : public PortableDeviceWatcherWin { public: // MTP device PnP identifiers. @@ -73,4 +75,6 @@ class TestPortableDeviceWatcherWin : public PortableDeviceWatcherWin { DISALLOW_COPY_AND_ASSIGN(TestPortableDeviceWatcherWin); }; +} // namespace storage_monitor + #endif // COMPONENTS_STORAGE_MONITOR_TEST_PORTABLE_DEVICE_WATCHER_WIN_H_ diff --git a/components/storage_monitor/test_storage_monitor.cc b/components/storage_monitor/test_storage_monitor.cc index 5be63dd..34cca9b 100644 --- a/components/storage_monitor/test_storage_monitor.cc +++ b/components/storage_monitor/test_storage_monitor.cc @@ -13,6 +13,8 @@ #include "device/media_transfer_protocol/media_transfer_protocol_manager.h" #endif +namespace storage_monitor { + TestStorageMonitor::TestStorageMonitor() : StorageMonitor(), init_called_(false) { @@ -116,3 +118,5 @@ void TestStorageMonitor::EjectDevice( ejected_device_ = device_id; callback.Run(EJECT_OK); } + +} // namespace storage_monitor diff --git a/components/storage_monitor/test_storage_monitor.h b/components/storage_monitor/test_storage_monitor.h index bdd0537..9b37304 100644 --- a/components/storage_monitor/test_storage_monitor.h +++ b/components/storage_monitor/test_storage_monitor.h @@ -9,6 +9,8 @@ #include "components/storage_monitor/storage_monitor.h" +namespace storage_monitor { + class TestStorageMonitor : public StorageMonitor { public: TestStorageMonitor(); @@ -72,4 +74,6 @@ class TestStorageMonitor : public StorageMonitor { #endif }; +} // namespace storage_monitor + #endif // COMPONENTS_STORAGE_MONITOR_TEST_STORAGE_MONITOR_H_ diff --git a/components/storage_monitor/test_storage_monitor_win.cc b/components/storage_monitor/test_storage_monitor_win.cc index 7e12e64..63dec3d 100644 --- a/components/storage_monitor/test_storage_monitor_win.cc +++ b/components/storage_monitor/test_storage_monitor_win.cc @@ -9,6 +9,8 @@ #include "components/storage_monitor/test_portable_device_watcher_win.h" #include "components/storage_monitor/test_volume_mount_watcher_win.h" +namespace storage_monitor { + TestStorageMonitorWin::TestStorageMonitorWin( TestVolumeMountWatcherWin* volume_mount_watcher, TestPortableDeviceWatcherWin* portable_device_watcher) @@ -32,3 +34,5 @@ TestStorageMonitorWin::volume_mount_watcher() { StorageMonitor::Receiver* TestStorageMonitorWin::receiver() const { return StorageMonitor::receiver(); } + +} // namespace storage_monitor diff --git a/components/storage_monitor/test_storage_monitor_win.h b/components/storage_monitor/test_storage_monitor_win.h index dd14a76..1280a7a 100644 --- a/components/storage_monitor/test_storage_monitor_win.h +++ b/components/storage_monitor/test_storage_monitor_win.h @@ -13,6 +13,8 @@ #include "base/memory/ref_counted.h" #include "components/storage_monitor/storage_monitor_win.h" +namespace storage_monitor { + class TestPortableDeviceWatcherWin; class TestVolumeMountWatcherWin; @@ -34,4 +36,6 @@ class TestStorageMonitorWin: public StorageMonitorWin { DISALLOW_COPY_AND_ASSIGN(TestStorageMonitorWin); }; +} // namespace storage_monitor + #endif // COMPONENTS_STORAGE_MONITOR_TEST_STORAGE_MONITOR_WIN_H_ diff --git a/components/storage_monitor/test_volume_mount_watcher_win.cc b/components/storage_monitor/test_volume_mount_watcher_win.cc index f5591f5..50c22b5 100644 --- a/components/storage_monitor/test_volume_mount_watcher_win.cc +++ b/components/storage_monitor/test_volume_mount_watcher_win.cc @@ -12,6 +12,8 @@ #include "base/strings/utf_string_conversions.h" #include "components/storage_monitor/storage_info.h" +namespace storage_monitor { + namespace { base::FilePath GetTempRoot() { @@ -151,3 +153,5 @@ VolumeMountWatcherWin::GetAttachedDevicesCallbackType void TestVolumeMountWatcherWin::ShutdownWorkerPool() { device_info_worker_pool_->Shutdown(); } + +} // namespace storage_monitor diff --git a/components/storage_monitor/test_volume_mount_watcher_win.h b/components/storage_monitor/test_volume_mount_watcher_win.h index 35060db..280a034 100644 --- a/components/storage_monitor/test_volume_mount_watcher_win.h +++ b/components/storage_monitor/test_volume_mount_watcher_win.h @@ -19,6 +19,8 @@ namespace base { class FilePath; } +namespace storage_monitor { + class TestVolumeMountWatcherWin : public VolumeMountWatcherWin { public: TestVolumeMountWatcherWin(); @@ -64,4 +66,6 @@ class TestVolumeMountWatcherWin : public VolumeMountWatcherWin { DISALLOW_COPY_AND_ASSIGN(TestVolumeMountWatcherWin); }; +} // namespace storage_monitor + #endif // COMPONENTS_STORAGE_MONITOR_TEST_VOLUME_MOUNT_WATCHER_WIN_H_ diff --git a/components/storage_monitor/transient_device_ids.cc b/components/storage_monitor/transient_device_ids.cc index c69d251..3f19302 100644 --- a/components/storage_monitor/transient_device_ids.cc +++ b/components/storage_monitor/transient_device_ids.cc @@ -11,6 +11,8 @@ #include "base/stl_util.h" #include "components/storage_monitor/storage_info.h" +namespace storage_monitor { + TransientDeviceIds::TransientDeviceIds() {} TransientDeviceIds::~TransientDeviceIds() {} @@ -39,3 +41,5 @@ std::string TransientDeviceIds::DeviceIdFromTransientId( return std::string(); return it->second; } + +} // namespace storage_monitor diff --git a/components/storage_monitor/transient_device_ids.h b/components/storage_monitor/transient_device_ids.h index 7ebf0a2..53227a9 100644 --- a/components/storage_monitor/transient_device_ids.h +++ b/components/storage_monitor/transient_device_ids.h @@ -16,6 +16,8 @@ #include "base/basictypes.h" #include "base/threading/thread_checker.h" +namespace storage_monitor { + class TransientDeviceIds { public: TransientDeviceIds(); @@ -42,4 +44,6 @@ class TransientDeviceIds { DISALLOW_COPY_AND_ASSIGN(TransientDeviceIds); }; +} // namespace storage_monitor + #endif // COMPONENTS_STORAGE_MONITOR_TRANSIENT_DEVICE_IDS_H_ diff --git a/components/storage_monitor/udev_util_linux.cc b/components/storage_monitor/udev_util_linux.cc index db32f82..142a54e 100644 --- a/components/storage_monitor/udev_util_linux.cc +++ b/components/storage_monitor/udev_util_linux.cc @@ -6,6 +6,8 @@ #include "base/files/file_path.h" +namespace storage_monitor { + void UdevDeleter::operator()(struct udev* udev) { udev_unref(udev); } @@ -33,3 +35,5 @@ bool GetUdevDevicePropertyValueByPath(const base::FilePath& device_path, *result = GetUdevDevicePropertyValue(device.get(), key); return true; } + +} // namespace storage_monitor diff --git a/components/storage_monitor/udev_util_linux.h b/components/storage_monitor/udev_util_linux.h index 203f282..108816b 100644 --- a/components/storage_monitor/udev_util_linux.h +++ b/components/storage_monitor/udev_util_linux.h @@ -15,6 +15,8 @@ namespace base { class FilePath; } +namespace storage_monitor { + // Deleter for ScopedUdevObject. struct UdevDeleter { void operator()(struct udev* udev); @@ -39,4 +41,6 @@ bool GetUdevDevicePropertyValueByPath(const base::FilePath& device_path, const char* key, std::string* result); +} // namespace storage_monitor + #endif // COMPONENTS_STORAGE_MONITOR_UDEV_UTIL_LINUX_H_ diff --git a/components/storage_monitor/volume_mount_watcher_win.cc b/components/storage_monitor/volume_mount_watcher_win.cc index fe82720..101cbda 100644 --- a/components/storage_monitor/volume_mount_watcher_win.cc +++ b/components/storage_monitor/volume_mount_watcher_win.cc @@ -27,6 +27,8 @@ using content::BrowserThread; +namespace storage_monitor { + namespace { const DWORD kMaxPathBufLen = MAX_PATH + 1; @@ -526,3 +528,5 @@ void VolumeMountWatcherWin::EjectDevice( FROM_HERE, base::Bind(&EjectDeviceInThreadPool, device, callback, task_runner_, 0)); } + +} // namespace storage_monitor diff --git a/components/storage_monitor/volume_mount_watcher_win.h b/components/storage_monitor/volume_mount_watcher_win.h index 5168671..0940d5c 100644 --- a/components/storage_monitor/volume_mount_watcher_win.h +++ b/components/storage_monitor/volume_mount_watcher_win.h @@ -20,6 +20,8 @@ #include "components/storage_monitor/storage_info.h" #include "components/storage_monitor/storage_monitor.h" +namespace storage_monitor { + class TestVolumeMountWatcherWin; // This class watches the volume mount points and sends notifications to @@ -116,4 +118,6 @@ class VolumeMountWatcherWin { DISALLOW_COPY_AND_ASSIGN(VolumeMountWatcherWin); }; +} // namespace storage_monitor + #endif // COMPONENTS_STORAGE_MONITOR_VOLUME_MOUNT_WATCHER_WIN_H_ |