GPU workaround to simulate Out of Memory errors with large textures
[chromium-blink-merge.git] / device / serial / serial_device_enumerator_mac.cc
blob2de2ae5ee466fd444ded02d614728edc1cfea51c
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
3 // found in the LICENSE file.
5 #include "device/serial/serial_device_enumerator_mac.h"
7 #include "base/files/file_enumerator.h"
8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/strings/string_util.h"
13 namespace device {
15 // static
16 scoped_ptr<SerialDeviceEnumerator> SerialDeviceEnumerator::Create() {
17 return scoped_ptr<SerialDeviceEnumerator>(new SerialDeviceEnumeratorMac());
20 SerialDeviceEnumeratorMac::SerialDeviceEnumeratorMac() {}
22 SerialDeviceEnumeratorMac::~SerialDeviceEnumeratorMac() {}
24 // TODO(rockot): Use IOKit to enumerate serial interfaces.
25 mojo::Array<serial::DeviceInfoPtr> SerialDeviceEnumeratorMac::GetDevices() {
26 const base::FilePath kDevRoot("/dev");
27 const int kFilesAndSymLinks =
28 base::FileEnumerator::FILES | base::FileEnumerator::SHOW_SYM_LINKS;
30 std::set<std::string> valid_patterns;
31 valid_patterns.insert("/dev/*Bluetooth*");
32 valid_patterns.insert("/dev/*Modem*");
33 valid_patterns.insert("/dev/*bluetooth*");
34 valid_patterns.insert("/dev/*modem*");
35 valid_patterns.insert("/dev/*serial*");
36 valid_patterns.insert("/dev/tty.*");
37 valid_patterns.insert("/dev/cu.*");
39 mojo::Array<serial::DeviceInfoPtr> devices(0);
40 base::FileEnumerator enumerator(kDevRoot, false, kFilesAndSymLinks);
41 do {
42 const base::FilePath next_device_path(enumerator.Next());
43 const std::string next_device = next_device_path.value();
44 if (next_device.empty())
45 break;
47 std::set<std::string>::const_iterator i = valid_patterns.begin();
48 for (; i != valid_patterns.end(); ++i) {
49 if (MatchPattern(next_device, *i)) {
50 serial::DeviceInfoPtr info(serial::DeviceInfo::New());
51 info->path = next_device;
52 devices.push_back(info.Pass());
53 break;
56 } while (true);
57 return devices.Pass();
60 } // namespace device