Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: components/storage_monitor/storage_monitor_mac.mm

Issue 1043013002: favor DCHECK_CURRENTLY_ON for better logs in components/ (part 2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: content namespace needed after all Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/storage_monitor/storage_monitor_chromeos.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/storage_monitor/storage_monitor_mac.h" 5 #include "components/storage_monitor/storage_monitor_mac.h"
6 6
7 #include "base/mac/foundation_util.h" 7 #include "base/mac/foundation_util.h"
8 #include "base/mac/mac_util.h" 8 #include "base/mac/mac_util.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 29 matching lines...) Expand all
40 StorageInfo::Type GetDeviceType(bool is_removable, bool has_dcim) { 40 StorageInfo::Type GetDeviceType(bool is_removable, bool has_dcim) {
41 if (!is_removable) 41 if (!is_removable)
42 return StorageInfo::FIXED_MASS_STORAGE; 42 return StorageInfo::FIXED_MASS_STORAGE;
43 if (has_dcim) 43 if (has_dcim)
44 return StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM; 44 return StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM;
45 return StorageInfo::REMOVABLE_MASS_STORAGE_NO_DCIM; 45 return StorageInfo::REMOVABLE_MASS_STORAGE_NO_DCIM;
46 } 46 }
47 47
48 StorageInfo BuildStorageInfo( 48 StorageInfo BuildStorageInfo(
49 CFDictionaryRef dict, std::string* bsd_name) { 49 CFDictionaryRef dict, std::string* bsd_name) {
50 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); 50 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
51 51
52 CFStringRef device_bsd_name = base::mac::GetValueFromDictionary<CFStringRef>( 52 CFStringRef device_bsd_name = base::mac::GetValueFromDictionary<CFStringRef>(
53 dict, kDADiskDescriptionMediaBSDNameKey); 53 dict, kDADiskDescriptionMediaBSDNameKey);
54 if (device_bsd_name && bsd_name) 54 if (device_bsd_name && bsd_name)
55 *bsd_name = base::SysCFStringRefToUTF8(device_bsd_name); 55 *bsd_name = base::SysCFStringRefToUTF8(device_bsd_name);
56 56
57 CFURLRef url = base::mac::GetValueFromDictionary<CFURLRef>( 57 CFURLRef url = base::mac::GetValueFromDictionary<CFURLRef>(
58 dict, kDADiskDescriptionVolumePathKey); 58 dict, kDADiskDescriptionVolumePathKey);
59 NSURL* nsurl = base::mac::CFToNSCast(url); 59 NSURL* nsurl = base::mac::CFToNSCast(url);
60 base::FilePath location = base::mac::NSStringToFilePath([nsurl path]); 60 base::FilePath location = base::mac::NSStringToFilePath([nsurl path]);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 device_id = StorageInfo::MakeDeviceId(device_type, unique_id); 102 device_id = StorageInfo::MakeDeviceId(device_type, unique_id);
103 103
104 return StorageInfo(device_id, location.value(), label, vendor, model, 104 return StorageInfo(device_id, location.value(), label, vendor, model,
105 size_in_bytes); 105 size_in_bytes);
106 } 106 }
107 107
108 void GetDiskInfoAndUpdateOnFileThread( 108 void GetDiskInfoAndUpdateOnFileThread(
109 const base::WeakPtr<StorageMonitorMac>& monitor, 109 const base::WeakPtr<StorageMonitorMac>& monitor,
110 base::ScopedCFTypeRef<CFDictionaryRef> dict, 110 base::ScopedCFTypeRef<CFDictionaryRef> dict,
111 StorageMonitorMac::UpdateType update_type) { 111 StorageMonitorMac::UpdateType update_type) {
112 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); 112 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
113 113
114 std::string bsd_name; 114 std::string bsd_name;
115 StorageInfo info = BuildStorageInfo(dict, &bsd_name); 115 StorageInfo info = BuildStorageInfo(dict, &bsd_name);
116 116
117 content::BrowserThread::PostTask( 117 content::BrowserThread::PostTask(
118 content::BrowserThread::UI, 118 content::BrowserThread::UI,
119 FROM_HERE, 119 FROM_HERE,
120 base::Bind(&StorageMonitorMac::UpdateDisk, 120 base::Bind(&StorageMonitorMac::UpdateDisk,
121 monitor, 121 monitor,
122 bsd_name, 122 bsd_name,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 if (base::mac::IsOSLionOrLater()) { 202 if (base::mac::IsOSLionOrLater()) {
203 image_capture_device_manager_.reset(new ImageCaptureDeviceManager); 203 image_capture_device_manager_.reset(new ImageCaptureDeviceManager);
204 image_capture_device_manager_->SetNotifications(receiver()); 204 image_capture_device_manager_->SetNotifications(receiver());
205 } 205 }
206 } 206 }
207 207
208 void StorageMonitorMac::UpdateDisk( 208 void StorageMonitorMac::UpdateDisk(
209 const std::string& bsd_name, 209 const std::string& bsd_name,
210 const StorageInfo& info, 210 const StorageInfo& info,
211 UpdateType update_type) { 211 UpdateType update_type) {
212 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 212 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
213 213
214 pending_disk_updates_--; 214 pending_disk_updates_--;
215 bool initialization_complete = false; 215 bool initialization_complete = false;
216 if (!IsInitialized() && pending_disk_updates_ == 0) 216 if (!IsInitialized() && pending_disk_updates_ == 0)
217 initialization_complete = true; 217 initialization_complete = true;
218 218
219 if (info.device_id().empty() || bsd_name.empty()) { 219 if (info.device_id().empty() || bsd_name.empty()) {
220 if (initialization_complete) 220 if (initialization_complete)
221 MarkInitialized(); 221 MarkInitialized();
222 return; 222 return;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 void StorageMonitorMac::DiskDescriptionChangedCallback(DADiskRef disk, 341 void StorageMonitorMac::DiskDescriptionChangedCallback(DADiskRef disk,
342 CFArrayRef keys, 342 CFArrayRef keys,
343 void *context) { 343 void *context) {
344 StorageMonitorMac* monitor = static_cast<StorageMonitorMac*>(context); 344 StorageMonitorMac* monitor = static_cast<StorageMonitorMac*>(context);
345 monitor->GetDiskInfoAndUpdate(disk, UPDATE_DEVICE_CHANGED); 345 monitor->GetDiskInfoAndUpdate(disk, UPDATE_DEVICE_CHANGED);
346 } 346 }
347 347
348 void StorageMonitorMac::GetDiskInfoAndUpdate( 348 void StorageMonitorMac::GetDiskInfoAndUpdate(
349 DADiskRef disk, 349 DADiskRef disk,
350 StorageMonitorMac::UpdateType update_type) { 350 StorageMonitorMac::UpdateType update_type) {
351 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 351 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
352 352
353 pending_disk_updates_++; 353 pending_disk_updates_++;
354 354
355 base::ScopedCFTypeRef<CFDictionaryRef> dict(DADiskCopyDescription(disk)); 355 base::ScopedCFTypeRef<CFDictionaryRef> dict(DADiskCopyDescription(disk));
356 content::BrowserThread::PostTask( 356 content::BrowserThread::PostTask(
357 content::BrowserThread::FILE, 357 content::BrowserThread::FILE,
358 FROM_HERE, 358 FROM_HERE,
359 base::Bind(GetDiskInfoAndUpdateOnFileThread, 359 base::Bind(GetDiskInfoAndUpdateOnFileThread,
360 AsWeakPtr(), dict, update_type)); 360 AsWeakPtr(), dict, update_type));
361 } 361 }
(...skipping 20 matching lines...) Expand all
382 } 382 }
383 } 383 }
384 return false; 384 return false;
385 } 385 }
386 386
387 StorageMonitor* StorageMonitor::CreateInternal() { 387 StorageMonitor* StorageMonitor::CreateInternal() {
388 return new StorageMonitorMac(); 388 return new StorageMonitorMac();
389 } 389 }
390 390
391 } // namespace storage_monitor 391 } // namespace storage_monitor
OLDNEW
« no previous file with comments | « components/storage_monitor/storage_monitor_chromeos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698