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

Side by Side Diff: chrome/browser/extensions/api/serial/serial_port_enumerator_win.cc

Issue 11474005: Current Serial port pattern in source cannot find proper port name. (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years 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 | « AUTHORS ('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 (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 #include "chrome/browser/extensions/api/serial/serial_port_enumerator.h" 5 #include "chrome/browser/extensions/api/serial/serial_port_enumerator.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 10
(...skipping 26 matching lines...) Expand all
37 // static 37 // static
38 SerialPortEnumerator::StringSet 38 SerialPortEnumerator::StringSet
39 SerialPortEnumerator::GenerateValidSerialPortNames() { 39 SerialPortEnumerator::GenerateValidSerialPortNames() {
40 StringSet name_set; 40 StringSet name_set;
41 int max_port_number = 16; 41 int max_port_number = 16;
42 42
43 // We ended up not using valid_patterns. TODO(miket): we might want 43 // We ended up not using valid_patterns. TODO(miket): we might want
44 // to refactor this interface to make it more platform-independent. 44 // to refactor this interface to make it more platform-independent.
45 for (int port_number = 0; port_number < max_port_number; ++port_number) { 45 for (int port_number = 0; port_number < max_port_number; ++port_number) {
46 string16 device_string16; 46 string16 device_string16;
47 device_string16 = base::StringPrintf(L"\\\\.\\COM%d", port_number); 47 device_string16 = base::StringPrintf(L"COM%d", port_number);
48 if (PassesCommConfigTest(device_string16)) { 48 if (PassesCommConfigTest(device_string16)) {
49 // Keep looking for new ports as long as we're finding them. 49 // Keep looking for new ports as long as we're finding them.
50 int new_max_port_number = (port_number + 1) * 2; 50 int new_max_port_number = (port_number + 1) * 2;
51 if (new_max_port_number > max_port_number) 51 if (new_max_port_number > max_port_number)
52 max_port_number = new_max_port_number; 52 max_port_number = new_max_port_number;
53 53
54 std::string device_string(WideToASCII(device_string16)); 54 std::string device_string(WideToASCII(device_string16));
55 name_set.insert(device_string); 55 name_set.insert(device_string);
56 } 56 }
57 } 57 }
58 return name_set; 58 return name_set;
59 } 59 }
60 60
61 } // namespace extensions 61 } // namespace extensions
OLDNEW
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698