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

Side by Side Diff: third_party/sudden_motion_sensor/sudden_motion_sensor_mac.cc

Issue 16917011: mac: Replace base::mac::ScopedCFTypeRef with base::ScopedCFTypeRef. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This file is based on the SMSLib library. 5 // This file is based on the SMSLib library.
6 // 6 //
7 // SMSLib Sudden Motion Sensor Access Library 7 // SMSLib Sudden Motion Sensor Access Library
8 // Copyright (c) 2010 Suitable Systems 8 // Copyright (c) 2010 Suitable Systems
9 // All rights reserved. 9 // All rights reserved.
10 // 10 //
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 // Request model name from the kernel. 303 // Request model name from the kernel.
304 char local_model[32]; // size from SMSLib 304 char local_model[32]; // size from SMSLib
305 size_t local_model_size = sizeof(local_model); 305 size_t local_model_size = sizeof(local_model);
306 int params[2] = { CTL_HW, HW_MODEL }; 306 int params[2] = { CTL_HW, HW_MODEL };
307 if (sysctl(params, 2, local_model, &local_model_size, NULL, 0) != 0) 307 if (sysctl(params, 2, local_model, &local_model_size, NULL, 0) != 0)
308 return false; 308 return false;
309 309
310 const SensorDescriptor* sensor_candidate = NULL; 310 const SensorDescriptor* sensor_candidate = NULL;
311 311
312 // Look for the current model in the supported sensor list. 312 // Look for the current model in the supported sensor list.
313 base::mac::ScopedCFTypeRef<CFDataRef> board_id_data; 313 base::ScopedCFTypeRef<CFDataRef> board_id_data;
314 const int kNumSensors = arraysize(kSupportedSensors); 314 const int kNumSensors = arraysize(kSupportedSensors);
315 315
316 for (int i = 0; i < kNumSensors; ++i) { 316 for (int i = 0; i < kNumSensors; ++i) {
317 // Check if the supported sensor model name is a prefix 317 // Check if the supported sensor model name is a prefix
318 // of the local hardware model (empty names are accepted). 318 // of the local hardware model (empty names are accepted).
319 const char* p1 = kSupportedSensors[i].model_name; 319 const char* p1 = kSupportedSensors[i].model_name;
320 for (const char* p2 = local_model; *p1 != '\0' && *p1 == *p2; ++p1, ++p2) 320 for (const char* p2 = local_model; *p1 != '\0' && *p1 == *p2; ++p1, ++p2)
321 continue; 321 continue;
322 if (*p1 != '\0') 322 if (*p1 != '\0')
323 continue; 323 continue;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 if (value & 0x00800000) 407 if (value & 0x00800000)
408 return value | 0xff000000; 408 return value | 0xff000000;
409 break; 409 break;
410 410
411 default: 411 default:
412 LOG(FATAL) << "Invalid integer size for sign extension: " << size; 412 LOG(FATAL) << "Invalid integer size for sign extension: " << size;
413 } 413 }
414 414
415 return value; 415 return value;
416 } 416 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698