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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_PORT_ENUMERATOR_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_PORT_ENUMERATOR_H_
11 #include "base/gtest_prod_util.h"
13 FORWARD_DECLARE_TEST(SerialPortEnumeratorTest, ValidPortNamePatterns);
14 FORWARD_DECLARE_TEST(SerialPortEnumeratorTest, InvalidPortNamePatterns);
16 namespace extensions {
18 class APIResourceEventNotifier;
20 // Discovers and enumerates likely serial ports on the current machine.
21 class SerialPortEnumerator {
23 typedef std::set<std::string> StringSet;
25 // Returns true if the given port name (e.g., "/dev/tty.usbmodemXXX") is in
26 // the supplied set of names of serial ports that exist on this machine.
27 static bool DoesPortExist(const StringSet& name_set,
28 const std::string& port_name);
30 static StringSet GenerateValidSerialPortNames();
33 // Returns a StringSet of patterns to be used with MatchPattern.
34 static StringSet GenerateValidPatterns();
36 FRIEND_TEST_ALL_PREFIXES(::SerialPortEnumeratorTest, ValidPortNamePatterns);
37 FRIEND_TEST_ALL_PREFIXES(::SerialPortEnumeratorTest, InvalidPortNamePatterns);
40 } // namespace extensions
42 #endif // CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_PORT_ENUMERATOR_H_