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

Side by Side Diff: content/browser/gamepad/xbox_data_fetcher_mac.cc

Issue 16917011: mac: Replace base::mac::ScopedCFTypeRef with base::ScopedCFTypeRef. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: with fixed off-by-1 in git-clang-format Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/browser/gamepad/xbox_data_fetcher_mac.h" 5 #include "content/browser/gamepad/xbox_data_fetcher_mac.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 10
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 } 488 }
489 } 489 }
490 } 490 }
491 491
492 void XboxDataFetcher::DeviceRemoved(void* context, io_iterator_t iterator) { 492 void XboxDataFetcher::DeviceRemoved(void* context, io_iterator_t iterator) {
493 DCHECK(context); 493 DCHECK(context);
494 XboxDataFetcher* fetcher = static_cast<XboxDataFetcher*>(context); 494 XboxDataFetcher* fetcher = static_cast<XboxDataFetcher*>(context);
495 io_service_t ref; 495 io_service_t ref;
496 while ((ref = IOIteratorNext(iterator))) { 496 while ((ref = IOIteratorNext(iterator))) {
497 base::mac::ScopedIOObject<io_service_t> scoped_ref(ref); 497 base::mac::ScopedIOObject<io_service_t> scoped_ref(ref);
498 base::mac::ScopedCFTypeRef<CFNumberRef> number( 498 base::ScopedCFTypeRef<CFNumberRef> number(
499 base::mac::CFCastStrict<CFNumberRef>(IORegistryEntryCreateCFProperty( 499 base::mac::CFCastStrict<CFNumberRef>(
500 ref, 500 IORegistryEntryCreateCFProperty(ref,
501 CFSTR(kUSBDevicePropertyLocationID), 501 CFSTR(kUSBDevicePropertyLocationID),
502 kCFAllocatorDefault, 502 kCFAllocatorDefault,
503 kNilOptions))); 503 kNilOptions)));
504 UInt32 location_id = 0; 504 UInt32 location_id = 0;
505 CFNumberGetValue(number, kCFNumberSInt32Type, &location_id); 505 CFNumberGetValue(number, kCFNumberSInt32Type, &location_id);
506 fetcher->RemoveControllerByLocationID(location_id); 506 fetcher->RemoveControllerByLocationID(location_id);
507 } 507 }
508 } 508 }
509 509
510 bool XboxDataFetcher::RegisterForNotifications() { 510 bool XboxDataFetcher::RegisterForNotifications() {
511 if (listening_) 511 if (listening_)
512 return true; 512 return true;
513 base::mac::ScopedCFTypeRef<CFNumberRef> vendor_cf( 513 base::ScopedCFTypeRef<CFNumberRef> vendor_cf(CFNumberCreate(
514 CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, 514 kCFAllocatorDefault, kCFNumberSInt32Type, &kVendorMicrosoft));
515 &kVendorMicrosoft)); 515 base::ScopedCFTypeRef<CFNumberRef> product_cf(CFNumberCreate(
516 base::mac::ScopedCFTypeRef<CFNumberRef> product_cf( 516 kCFAllocatorDefault, kCFNumberSInt32Type, &kProduct360Controller));
517 CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, 517 base::ScopedCFTypeRef<CFMutableDictionaryRef> matching_dict(
518 &kProduct360Controller));
519 base::mac::ScopedCFTypeRef<CFMutableDictionaryRef> matching_dict(
520 IOServiceMatching(kIOUSBDeviceClassName)); 518 IOServiceMatching(kIOUSBDeviceClassName));
521 if (!matching_dict) 519 if (!matching_dict)
522 return false; 520 return false;
523 CFDictionarySetValue(matching_dict, CFSTR(kUSBVendorID), vendor_cf); 521 CFDictionarySetValue(matching_dict, CFSTR(kUSBVendorID), vendor_cf);
524 CFDictionarySetValue(matching_dict, CFSTR(kUSBProductID), product_cf); 522 CFDictionarySetValue(matching_dict, CFSTR(kUSBProductID), product_cf);
525 port_ = IONotificationPortCreate(kIOMasterPortDefault); 523 port_ = IONotificationPortCreate(kIOMasterPortDefault);
526 if (!port_) 524 if (!port_)
527 return false; 525 return false;
528 source_ = IONotificationPortGetRunLoopSource(port_); 526 source_ = IONotificationPortGetRunLoopSource(port_);
529 if (!source_) 527 if (!source_)
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 } 616 }
619 617
620 void XboxDataFetcher::XboxControllerGotData(XboxController* controller, 618 void XboxDataFetcher::XboxControllerGotData(XboxController* controller,
621 const XboxController::Data& data) { 619 const XboxController::Data& data) {
622 delegate_->XboxValueChanged(controller, data); 620 delegate_->XboxValueChanged(controller, data);
623 } 621 }
624 622
625 void XboxDataFetcher::XboxControllerError(XboxController* controller) { 623 void XboxDataFetcher::XboxControllerError(XboxController* controller) {
626 RemoveController(controller); 624 RemoveController(controller);
627 } 625 }
OLDNEW
« no previous file with comments | « content/browser/gamepad/xbox_data_fetcher_mac.h ('k') | content/browser/power_save_blocker_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698