[M120 Migration][VD] Enable direct rendering for TVPlus
[platform/framework/web/chromium-efl.git] / components / storage_monitor / storage_monitor_mac.mm
index 903de48..d2bcea1 100644 (file)
@@ -8,8 +8,9 @@
 
 #include <memory>
 
-#include "base/bind.h"
-#include "base/mac/foundation_util.h"
+#include "base/apple/bridging.h"
+#include "base/apple/foundation_util.h"
+#include "base/functional/bind.h"
 #include "base/mac/mac_util.h"
 #include "base/strings/sys_string_conversions.h"
 #include "base/strings/utf_string_conversions.h"
@@ -31,7 +32,7 @@ const char16_t kDiskImageModelName[] = u"Disk Image";
 std::u16string GetUTF16FromDictionary(CFDictionaryRef dictionary,
                                       CFStringRef key) {
   CFStringRef value =
-      base::mac::GetValueFromDictionary<CFStringRef>(dictionary, key);
+      base::apple::GetValueFromDictionary<CFStringRef>(dictionary, key);
   if (!value)
     return std::u16string();
   return base::SysCFStringRefToUTF16(value);
@@ -59,18 +60,18 @@ StorageInfo BuildStorageInfo(
   base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
                                                 base::BlockingType::MAY_BLOCK);
 
-  CFStringRef device_bsd_name = base::mac::GetValueFromDictionary<CFStringRef>(
-      dict, kDADiskDescriptionMediaBSDNameKey);
+  CFStringRef device_bsd_name =
+      base::apple::GetValueFromDictionary<CFStringRef>(
+          dict, kDADiskDescriptionMediaBSDNameKey);
   if (device_bsd_name && bsd_name)
     *bsd_name = base::SysCFStringRefToUTF8(device_bsd_name);
 
-  CFURLRef url = base::mac::GetValueFromDictionary<CFURLRef>(
+  CFURLRef url = base::apple::GetValueFromDictionary<CFURLRef>(
       dict, kDADiskDescriptionVolumePathKey);
-  NSURL* nsurl = base::mac::CFToNSCast(url);
-  base::FilePath location = base::mac::NSStringToFilePath([nsurl path]);
-  CFNumberRef size_number =
-      base::mac::GetValueFromDictionary<CFNumberRef>(
-          dict, kDADiskDescriptionMediaSizeKey);
+  base::FilePath location =
+      base::apple::NSURLToFilePath(base::apple::CFToNSPtrCast(url));
+  CFNumberRef size_number = base::apple::GetValueFromDictionary<CFNumberRef>(
+      dict, kDADiskDescriptionMediaSizeKey);
   uint64_t size_in_bytes = 0;
   if (size_number)
     CFNumberGetValue(size_number, kCFNumberLongLongType, &size_in_bytes);
@@ -82,12 +83,12 @@ StorageInfo BuildStorageInfo(
   std::u16string label =
       GetUTF16FromDictionary(dict, kDADiskDescriptionVolumeNameKey);
 
-  CFUUIDRef uuid = base::mac::GetValueFromDictionary<CFUUIDRef>(
+  CFUUIDRef uuid = base::apple::GetValueFromDictionary<CFUUIDRef>(
       dict, kDADiskDescriptionVolumeUUIDKey);
   std::string unique_id;
   if (uuid) {
-    base::ScopedCFTypeRef<CFStringRef> uuid_string(
-        CFUUIDCreateString(NULL, uuid));
+    base::apple::ScopedCFTypeRef<CFStringRef> uuid_string(
+        CFUUIDCreateString(nullptr, uuid));
     if (uuid_string.get())
       unique_id = base::SysCFStringRefToUTF8(uuid_string);
   }
@@ -101,7 +102,7 @@ StorageInfo BuildStorageInfo(
   }
 
   CFBooleanRef is_removable_ref =
-      base::mac::GetValueFromDictionary<CFBooleanRef>(
+      base::apple::GetValueFromDictionary<CFBooleanRef>(
           dict, kDADiskDescriptionMediaRemovableKey);
   bool is_removable = is_removable_ref && CFBooleanGetValue(is_removable_ref);
   // Checking for DCIM only matters on removable devices.
@@ -118,7 +119,7 @@ StorageInfo BuildStorageInfo(
 struct EjectDiskOptions {
   std::string bsd_name;
   base::OnceCallback<void(StorageMonitor::EjectStatus)> callback;
-  base::ScopedCFTypeRef<DADiskRef> disk;
+  base::apple::ScopedCFTypeRef<DADiskRef> disk;
 };
 
 void PostEjectCallback(DADiskRef disk,
@@ -155,8 +156,7 @@ void EjectDisk(EjectDiskOptions* options) {
 
 }  // namespace
 
-StorageMonitorMac::StorageMonitorMac() : pending_disk_updates_(0) {
-}
+StorageMonitorMac::StorageMonitorMac() = default;
 
 StorageMonitorMac::~StorageMonitorMac() {
   if (session_.get()) {
@@ -166,7 +166,7 @@ StorageMonitorMac::~StorageMonitorMac() {
 }
 
 void StorageMonitorMac::Init() {
-  session_.reset(DASessionCreate(NULL));
+  session_.reset(DASessionCreate(nullptr));
 
   // Register for callbacks for attached, changed, and removed devices.
   // This will send notifications for existing devices too.
@@ -291,8 +291,8 @@ void StorageMonitorMac::EjectDevice(
 
   receiver()->ProcessDetach(device_id);
 
-  base::ScopedCFTypeRef<DADiskRef> disk(
-      DADiskCreateFromBSDName(NULL, session_, bsd_name.c_str()));
+  base::apple::ScopedCFTypeRef<DADiskRef> disk(
+      DADiskCreateFromBSDName(nullptr, session_, bsd_name.c_str()));
   if (!disk.get()) {
     std::move(callback).Run(StorageMonitor::EJECT_FAILURE);
     return;
@@ -339,7 +339,8 @@ void StorageMonitorMac::GetDiskInfoAndUpdate(
 
   pending_disk_updates_++;
 
-  base::ScopedCFTypeRef<CFDictionaryRef> dict(DADiskCopyDescription(disk));
+  base::apple::ScopedCFTypeRef<CFDictionaryRef> dict(
+      DADiskCopyDescription(disk));
   std::string* bsd_name = new std::string;
   base::ThreadPool::PostTaskAndReplyWithResult(
       FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
@@ -361,10 +362,9 @@ bool StorageMonitorMac::ShouldPostNotificationForDisk(
 bool StorageMonitorMac::FindDiskWithMountPoint(
     const base::FilePath& mount_point,
     StorageInfo* info) const {
-  for (std::map<std::string, StorageInfo>::const_iterator
-      it = disk_info_map_.begin(); it != disk_info_map_.end(); ++it) {
-    if (it->second.location() == mount_point.value()) {
-      *info = it->second;
+  for (const auto& disk_info : disk_info_map_) {
+    if (disk_info.second.location() == mount_point.value()) {
+      *info = disk_info.second;
       return true;
     }
   }