Commit c40df01c authored by thestig@chromium.org's avatar thestig@chromium.org

Cleanup: Remove ScopedGenericObj usage in chrome/.

Review URL: https://chromiumcodereview.appspot.com/16041004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202754 0039d316-1c4b-4281-b951-d872f2087c98
parent 0ddde4be
...@@ -11,6 +11,7 @@ namespace extensions { ...@@ -11,6 +11,7 @@ namespace extensions {
using api::experimental_system_info_storage::StorageUnitInfo; using api::experimental_system_info_storage::StorageUnitInfo;
using api::experimental_system_info_storage::ParseStorageUnitType; using api::experimental_system_info_storage::ParseStorageUnitType;
using chrome::GetUdevDevicePropertyValue;
using chrome::ScopedUdevDeviceObject; using chrome::ScopedUdevDeviceObject;
namespace { namespace {
...@@ -84,12 +85,12 @@ bool StorageInfoProviderLinux::QueryStorageType(const std::string& mount_path, ...@@ -84,12 +85,12 @@ bool StorageInfoProviderLinux::QueryStorageType(const std::string& mount_path,
// Create a udev device from a block device number. // Create a udev device from a block device number.
ScopedUdevDeviceObject device(udev_device_new_from_devnum( ScopedUdevDeviceObject device(udev_device_new_from_devnum(
udev_context_, 'b', stat_info.st_dev)); udev_context_.get(), 'b', stat_info.st_dev));
if (!device) if (!device)
return false; return false;
if (GetUdevDevicePropertyValue(device, "ID_BUS") == "usb") { if (GetUdevDevicePropertyValue(device.get(), "ID_BUS") == "usb") {
*type = systeminfo::kStorageTypeRemovable; *type = systeminfo::kStorageTypeRemovable;
} else if (GetUdevDevicePropertyValue(device, "ID_TYPE") == "disk") { } else if (GetUdevDevicePropertyValue(device.get(), "ID_TYPE") == "disk") {
*type = systeminfo::kStorageTypeFixed; *type = systeminfo::kStorageTypeFixed;
} else { } else {
*type = systeminfo::kStorageTypeUnknown; *type = systeminfo::kStorageTypeUnknown;
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "chrome/browser/media_galleries/fileapi/native_media_file_util.h" #include "chrome/browser/media_galleries/fileapi/native_media_file_util.h"
#include "base/file_util.h" #include "base/file_util.h"
#include "base/memory/scoped_generic_obj.h"
#include "base/string_util.h" #include "base/string_util.h"
#include "chrome/browser/media_galleries/fileapi/filtering_file_enumerator.h" #include "chrome/browser/media_galleries/fileapi/filtering_file_enumerator.h"
#include "chrome/browser/media_galleries/fileapi/media_file_system_mount_point_provider.h" #include "chrome/browser/media_galleries/fileapi/media_file_system_mount_point_provider.h"
...@@ -29,16 +28,15 @@ namespace chrome { ...@@ -29,16 +28,15 @@ namespace chrome {
namespace { namespace {
// Modelled after ScopedFILEClose. // Modelled after ScopedFILEClose.
class ScopedPlatformFileClose { struct ScopedPlatformFileClose {
public: void operator()(base::PlatformFile* file) {
void operator()(base::PlatformFile file) const { if (file && *file != base::kInvalidPlatformFileValue)
if (file != base::kInvalidPlatformFileValue) base::ClosePlatformFile(*file);
base::ClosePlatformFile(file);
} }
}; };
typedef ScopedGenericObj<base::PlatformFile, typedef scoped_ptr<base::PlatformFile, ScopedPlatformFileClose>
ScopedPlatformFileClose> ScopedPlatformFile; ScopedPlatformFile;
// Returns true if the current thread is capable of doing IO. // Returns true if the current thread is capable of doing IO.
bool IsOnTaskRunnerThread(fileapi::FileSystemOperationContext* context) { bool IsOnTaskRunnerThread(fileapi::FileSystemOperationContext* context) {
...@@ -279,7 +277,7 @@ base::PlatformFileError NativeMediaFileUtil::IsMediaFile( ...@@ -279,7 +277,7 @@ base::PlatformFileError NativeMediaFileUtil::IsMediaFile(
if (error != base::PLATFORM_FILE_OK) if (error != base::PLATFORM_FILE_OK)
return error; return error;
ScopedPlatformFile scoped_platform_file(file_handle); ScopedPlatformFile scoped_platform_file(&file_handle);
char buffer[net::kMaxBytesToSniff]; char buffer[net::kMaxBytesToSniff];
// Read as much as net::SniffMimeTypeFromLocalData() will bother looking at. // Read as much as net::SniffMimeTypeFromLocalData() will bother looking at.
......
...@@ -160,27 +160,30 @@ scoped_ptr<StorageInfo> GetDeviceInfo(const base::FilePath& device_path, ...@@ -160,27 +160,30 @@ scoped_ptr<StorageInfo> GetDeviceInfo(const base::FilePath& device_path,
return storage_info.Pass(); // Not a supported type. return storage_info.Pass(); // Not a supported type.
ScopedUdevDeviceObject device( ScopedUdevDeviceObject device(
udev_device_new_from_devnum(udev_obj, device_type, device_stat.st_rdev)); udev_device_new_from_devnum(udev_obj.get(), device_type,
device_stat.st_rdev));
if (!device.get()) if (!device.get())
return storage_info.Pass(); return storage_info.Pass();
string16 volume_label = UTF8ToUTF16(GetUdevDevicePropertyValue(device, string16 volume_label = UTF8ToUTF16(GetUdevDevicePropertyValue(device.get(),
kLabel)); kLabel));
string16 vendor_name = UTF8ToUTF16(GetUdevDevicePropertyValue(device, string16 vendor_name = UTF8ToUTF16(GetUdevDevicePropertyValue(device.get(),
kVendor)); kVendor));
string16 model_name = UTF8ToUTF16(GetUdevDevicePropertyValue(device, kModel)); string16 model_name = UTF8ToUTF16(GetUdevDevicePropertyValue(device.get(),
kModel));
std::string unique_id = MakeDeviceUniqueId(device); std::string unique_id = MakeDeviceUniqueId(device.get());
// Keep track of device info details to see how often we get invalid values. // Keep track of device info details to see how often we get invalid values.
MediaStorageUtil::RecordDeviceInfoHistogram(true, unique_id, volume_label); MediaStorageUtil::RecordDeviceInfoHistogram(true, unique_id, volume_label);
const char* value = udev_device_get_sysattr_value(device, kRemovableSysAttr); const char* value =
udev_device_get_sysattr_value(device.get(), kRemovableSysAttr);
if (!value) { if (!value) {
// |parent_device| is owned by |device| and does not need to be cleaned // |parent_device| is owned by |device| and does not need to be cleaned
// up. // up.
struct udev_device* parent_device = struct udev_device* parent_device =
udev_device_get_parent_with_subsystem_devtype(device, udev_device_get_parent_with_subsystem_devtype(device.get(),
kBlockSubsystemKey, kBlockSubsystemKey,
kDiskDeviceTypeKey); kDiskDeviceTypeKey);
value = udev_device_get_sysattr_value(parent_device, kRemovableSysAttr); value = udev_device_get_sysattr_value(parent_device, kRemovableSysAttr);
...@@ -204,7 +207,7 @@ scoped_ptr<StorageInfo> GetDeviceInfo(const base::FilePath& device_path, ...@@ -204,7 +207,7 @@ scoped_ptr<StorageInfo> GetDeviceInfo(const base::FilePath& device_path,
volume_label, volume_label,
vendor_name, vendor_name,
model_name, model_name,
GetDeviceStorageSize(device_path, device))); GetDeviceStorageSize(device_path, device.get())));
return storage_info.Pass(); return storage_info.Pass();
} }
......
...@@ -8,6 +8,14 @@ ...@@ -8,6 +8,14 @@
namespace chrome { namespace chrome {
void UdevDeleter::operator()(struct udev* udev) {
udev_unref(udev);
}
void UdevDeviceDeleter::operator()(struct udev_device* device) {
udev_device_unref(device);
}
std::string GetUdevDevicePropertyValue(struct udev_device* udev_device, std::string GetUdevDevicePropertyValue(struct udev_device* udev_device,
const char* key) { const char* key) {
const char* value = udev_device_get_property_value(udev_device, key); const char* value = udev_device_get_property_value(udev_device, key);
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include <string> #include <string>
#include "base/memory/scoped_generic_obj.h" #include "base/memory/scoped_ptr.h"
namespace base { namespace base {
class FilePath; class FilePath;
...@@ -17,25 +17,18 @@ class FilePath; ...@@ -17,25 +17,18 @@ class FilePath;
namespace chrome { namespace chrome {
// ScopedGenericObj functor for UdevObjectRelease(). // Deleter for ScopedUdevObject.
class ScopedReleaseUdevObject { struct UdevDeleter {
public: void operator()(struct udev* udev);
void operator()(struct udev* udev) const {
udev_unref(udev);
}
}; };
typedef ScopedGenericObj<struct udev*, typedef scoped_ptr<struct udev, UdevDeleter> ScopedUdevObject;
ScopedReleaseUdevObject> ScopedUdevObject;
// Deleter for ScopedUdevDeviceObject().
// ScopedGenericObj functor for UdevDeviceObjectRelease(). struct UdevDeviceDeleter {
class ScopedReleaseUdevDeviceObject { void operator()(struct udev_device* device);
public:
void operator()(struct udev_device* device) const {
udev_device_unref(device);
}
}; };
typedef ScopedGenericObj<struct udev_device*, typedef scoped_ptr<struct udev_device, UdevDeviceDeleter>
ScopedReleaseUdevDeviceObject> ScopedUdevDeviceObject; ScopedUdevDeviceObject;
// Wrapper function for udev_device_get_property_value() that also checks for // Wrapper function for udev_device_get_property_value() that also checks for
// valid but empty values. // valid but empty values.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment