summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-10 06:30:01 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-10 06:30:01 +0000
commit35fadaa2b8a451042bcef22b6f2993cbc6855d94 (patch)
treee9129716f6bce5b0657ddd35d232b62f48eee54d
parent441f9a87d44ab2e3c3875eb2d1d031a5c4a904c3 (diff)
downloadchromium_src-35fadaa2b8a451042bcef22b6f2993cbc6855d94.zip
chromium_src-35fadaa2b8a451042bcef22b6f2993cbc6855d94.tar.gz
chromium_src-35fadaa2b8a451042bcef22b6f2993cbc6855d94.tar.bz2
Cleanup: Move DCIM constants to chrome/browser/system_monitor/removable_device_constants.h.
Review URL: https://chromiumcodereview.appspot.com/11359126 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167070 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/system_monitor/media_device_notifications_utils.cc13
-rw-r--r--chrome/browser/system_monitor/media_device_notifications_utils_unittest.cc13
-rw-r--r--chrome/browser/system_monitor/removable_device_constants.cc2
-rw-r--r--chrome/browser/system_monitor/removable_device_constants.h3
-rw-r--r--chrome/browser/system_monitor/removable_device_notifications_chromeos_unittest.cc2
-rw-r--r--chrome/browser/system_monitor/removable_device_notifications_linux_unittest.cc32
-rw-r--r--chrome/browser/system_monitor/removable_device_notifications_mac_unittest.mm3
7 files changed, 28 insertions, 40 deletions
diff --git a/chrome/browser/system_monitor/media_device_notifications_utils.cc b/chrome/browser/system_monitor/media_device_notifications_utils.cc
index 5453eb6..4054c2d 100644
--- a/chrome/browser/system_monitor/media_device_notifications_utils.cc
+++ b/chrome/browser/system_monitor/media_device_notifications_utils.cc
@@ -6,25 +6,16 @@
#include "base/file_util.h"
#include "base/string_util.h"
+#include "chrome/browser/system_monitor/removable_device_constants.h"
#include "content/public/browser/browser_thread.h"
-namespace {
-
-#if defined(OS_WIN)
-const wchar_t kDCIMDirName[] = L"DCIM";
-#else
-const char kDCIMDirName[] = "DCIM";
-#endif
-
-} // namespace
-
namespace chrome {
bool IsMediaDevice(const FilePath::StringType& mount_point) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
FilePath dcim_path(mount_point);
- FilePath::StringType dcim_dir = kDCIMDirName;
+ FilePath::StringType dcim_dir(kDCIMDirectoryName);
if (!file_util::DirectoryExists(dcim_path.Append(dcim_dir))) {
// Check for lowercase 'dcim' as well.
FilePath dcim_path_lower(dcim_path.Append(StringToLowerASCII(dcim_dir)));
diff --git a/chrome/browser/system_monitor/media_device_notifications_utils_unittest.cc b/chrome/browser/system_monitor/media_device_notifications_utils_unittest.cc
index d38b283..389f157 100644
--- a/chrome/browser/system_monitor/media_device_notifications_utils_unittest.cc
+++ b/chrome/browser/system_monitor/media_device_notifications_utils_unittest.cc
@@ -8,21 +8,12 @@
#include "base/file_util.h"
#include "base/message_loop.h"
#include "base/scoped_temp_dir.h"
+#include "chrome/browser/system_monitor/removable_device_constants.h"
#include "content/public/test/test_browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chrome {
-namespace {
-
-#if defined(OS_WIN)
-const wchar_t kDCIMDirName[] = L"DCIM";
-#else
-const char kDCIMDirName[] = "DCIM";
-#endif
-
-} // namespace
-
using content::BrowserThread;
class MediaDeviceNotificationUtilsTest : public testing::Test {
@@ -46,7 +37,7 @@ class MediaDeviceNotificationUtilsTest : public testing::Test {
FilePath CreateMountPoint(bool create_dcim_dir) {
FilePath path(scoped_temp_dir_.path());
if (create_dcim_dir)
- path = path.Append(kDCIMDirName);
+ path = path.Append(kDCIMDirectoryName);
if (!file_util::CreateDirectory(path))
return FilePath();
return scoped_temp_dir_.path();
diff --git a/chrome/browser/system_monitor/removable_device_constants.cc b/chrome/browser/system_monitor/removable_device_constants.cc
index df2083c..7f39d853 100644
--- a/chrome/browser/system_monitor/removable_device_constants.cc
+++ b/chrome/browser/system_monitor/removable_device_constants.cc
@@ -17,4 +17,6 @@ const char kVendorModelVolumeStoragePrefix[] = "VendorModelVolumeStorage:";
const char16 kWPDDevInterfaceGUID[] = L"{6ac27878-a6fa-4155-ba85-f98f491d4f33}";
#endif
+const FilePath::CharType kDCIMDirectoryName[] = FILE_PATH_LITERAL("DCIM");
+
} // namespace chrome
diff --git a/chrome/browser/system_monitor/removable_device_constants.h b/chrome/browser/system_monitor/removable_device_constants.h
index 903043f..91e986b 100644
--- a/chrome/browser/system_monitor/removable_device_constants.h
+++ b/chrome/browser/system_monitor/removable_device_constants.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_CONSTANTS_H_
#define CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_CONSTANTS_H_
+#include "base/file_path.h"
#include "base/string16.h"
#include "build/build_config.h"
@@ -23,6 +24,8 @@ extern const char kVendorModelVolumeStoragePrefix[];
extern const char16 kWPDDevInterfaceGUID[];
#endif
+extern const FilePath::CharType kDCIMDirectoryName[];
+
} // namespace chrome
#endif // CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_CONSTANTS_H_
diff --git a/chrome/browser/system_monitor/removable_device_notifications_chromeos_unittest.cc b/chrome/browser/system_monitor/removable_device_notifications_chromeos_unittest.cc
index 753854c..29abf36 100644
--- a/chrome/browser/system_monitor/removable_device_notifications_chromeos_unittest.cc
+++ b/chrome/browser/system_monitor/removable_device_notifications_chromeos_unittest.cc
@@ -116,7 +116,7 @@ class RemovableDeviceNotificationsCrosTest : public testing::Test {
return_path = return_path.AppendASCII(dir);
FilePath path(return_path);
if (with_dcim_dir)
- path = path.AppendASCII("DCIM");
+ path = path.Append(chrome::kDCIMDirectoryName);
if (!file_util::CreateDirectory(path))
return FilePath();
return return_path;
diff --git a/chrome/browser/system_monitor/removable_device_notifications_linux_unittest.cc b/chrome/browser/system_monitor/removable_device_notifications_linux_unittest.cc
index fc1b837..538f180 100644
--- a/chrome/browser/system_monitor/removable_device_notifications_linux_unittest.cc
+++ b/chrome/browser/system_monitor/removable_device_notifications_linux_unittest.cc
@@ -20,6 +20,7 @@
#include "base/test/mock_devices_changed_observer.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/system_monitor/media_storage_util.h"
+#include "chrome/browser/system_monitor/removable_device_constants.h"
#include "content/public/test/test_browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -46,8 +47,6 @@ const char kMountPointA[] = "mnt_a";
const char kMountPointB[] = "mnt_b";
const char kMountPointC[] = "mnt_c";
-const char kDCIM[] = "DCIM";
-
struct TestDeviceData {
const char* device_path;
const char* unique_id;
@@ -56,16 +55,16 @@ struct TestDeviceData {
};
const TestDeviceData kTestDeviceData[] = {
- {kDeviceDCIM1, "UUID:FFF0-000F", "TEST_USB_MODEL_1",
- MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM},
- {kDeviceDCIM2, "VendorModelSerial:ComName:Model2010:8989", "TEST_USB_MODEL_2",
- MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM},
- {kDeviceDCIM3, "VendorModelSerial:::WEM319X792", "TEST_USB_MODEL_3",
- MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM},
- {kDeviceNoDCIM, "UUID:ABCD-1234", "TEST_USB_MODEL_4",
- MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM},
- {kDeviceFixed, "UUID:743A91FD2349", "TEST_USB_MODEL_5",
- MediaStorageUtil::FIXED_MASS_STORAGE},
+ { kDeviceDCIM1, "UUID:FFF0-000F", "TEST_USB_MODEL_1",
+ MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM},
+ { kDeviceDCIM2, "VendorModelSerial:ComName:Model2010:8989",
+ "TEST_USB_MODEL_2", MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM},
+ { kDeviceDCIM3, "VendorModelSerial:::WEM319X792", "TEST_USB_MODEL_3",
+ MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM},
+ { kDeviceNoDCIM, "UUID:ABCD-1234", "TEST_USB_MODEL_4",
+ MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM},
+ { kDeviceFixed, "UUID:743A91FD2349", "TEST_USB_MODEL_5",
+ MediaStorageUtil::FIXED_MASS_STORAGE},
};
void GetDeviceInfo(const FilePath& device_path, std::string* id,
@@ -110,7 +109,7 @@ string16 GetDeviceName(const std::string& device) {
}
class RemovableDeviceNotificationsLinuxTestWrapper
- : public RemovableDeviceNotificationsLinux {
+ : public RemovableDeviceNotificationsLinux {
public:
RemovableDeviceNotificationsLinuxTestWrapper(const FilePath& path,
MessageLoop* message_loop)
@@ -224,7 +223,8 @@ class RemovableDeviceNotificationLinuxTest : public testing::Test {
}
void RemoveDCIMDirFromMountPoint(const std::string& dir) {
- FilePath dcim(scoped_temp_dir_.path().AppendASCII(dir).AppendASCII(kDCIM));
+ FilePath dcim =
+ scoped_temp_dir_.path().AppendASCII(dir).Append(kDCIMDirectoryName);
file_util::Delete(dcim, false);
}
@@ -247,7 +247,7 @@ class RemovableDeviceNotificationLinuxTest : public testing::Test {
return_path = return_path.AppendASCII(dir);
FilePath path(return_path);
if (with_dcim_dir)
- path = path.AppendASCII(kDCIM);
+ path = path.Append(kDCIMDirectoryName);
if (!file_util::CreateDirectory(path))
return FilePath();
return return_path;
@@ -537,7 +537,7 @@ TEST_F(RemovableDeviceNotificationLinuxTest,
};
EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(2);
EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(1);
- file_util::Delete(test_path_b.Append("DCIM"), false);
+ file_util::Delete(test_path_b.Append(kDCIMDirectoryName), false);
AppendToMtabAndRunLoop(test_data5, arraysize(test_data5));
// Detach |kDeviceNoDCIM|.
diff --git a/chrome/browser/system_monitor/removable_device_notifications_mac_unittest.mm b/chrome/browser/system_monitor/removable_device_notifications_mac_unittest.mm
index 556e1f1..b7c9e8d 100644
--- a/chrome/browser/system_monitor/removable_device_notifications_mac_unittest.mm
+++ b/chrome/browser/system_monitor/removable_device_notifications_mac_unittest.mm
@@ -13,6 +13,7 @@
#include "base/test/mock_devices_changed_observer.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/system_monitor/media_storage_util.h"
+#include "chrome/browser/system_monitor/removable_device_constants.h"
#include "content/public/test/test_browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -139,7 +140,7 @@ TEST_F(RemovableDeviceNotificationsMacTest, UpdateVolumeName) {
TEST_F(RemovableDeviceNotificationsMacTest, DCIM) {
ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- file_util::CreateDirectory(temp_dir.path().AppendASCII("DCIM"));
+ file_util::CreateDirectory(temp_dir.path().Append(kDCIMDirectoryName));
FilePath mount_point = temp_dir.path();
DiskInfoMac info = CreateDiskInfoMac(