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

Side by Side Diff: chromeos/network/shill_property_util.h

Issue 23712002: Cleanup network type matching. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Generalized network type matching. Created 7 years, 3 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 #ifndef CHROMEOS_NETWORK_SHILL_PROPERTY_UTIL_H_ 5 #ifndef CHROMEOS_NETWORK_SHILL_PROPERTY_UTIL_H_
6 #define CHROMEOS_NETWORK_SHILL_PROPERTY_UTIL_H_ 6 #define CHROMEOS_NETWORK_SHILL_PROPERTY_UTIL_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "chromeos/chromeos_export.h"
11 12
12 namespace base { 13 namespace base {
13 class DictionaryValue; 14 class DictionaryValue;
14 class Value; 15 class Value;
15 } 16 }
16 17
17 namespace chromeos { 18 namespace chromeos {
18 19
19 class NetworkUIData; 20 class NetworkUIData;
20 21
(...skipping 21 matching lines...) Expand all
42 43
43 // Copy configuration properties required by Shill to identify a network. 44 // Copy configuration properties required by Shill to identify a network.
44 // Only WiFi, VPN, Ethernet and EthernetEAP are supported. WiMax and Cellular 45 // Only WiFi, VPN, Ethernet and EthernetEAP are supported. WiMax and Cellular
45 // are not supported. Returns true only if all required properties could be 46 // are not supported. Returns true only if all required properties could be
46 // copied. 47 // copied.
47 bool CopyIdentifyingProperties(const base::DictionaryValue& service_properties, 48 bool CopyIdentifyingProperties(const base::DictionaryValue& service_properties,
48 base::DictionaryValue* dest); 49 base::DictionaryValue* dest);
49 50
50 } // namespace shill_property_util 51 } // namespace shill_property_util
51 52
53 class CHROMEOS_EXPORT NetworkTypePattern {
54 public:
55 // Matches any network.
56 static NetworkTypePattern Default();
57
58 // Matches wireless networks
59 static NetworkTypePattern Wireless();
60
61 // Matches cellular or wimax networks.
62 static NetworkTypePattern Mobile();
63
64 // Matches non virtual networks.
65 static NetworkTypePattern NonVirtual();
66
67 // Matches ethernet networks (with or without EAP).
68 static NetworkTypePattern Ethernet();
69
70 static NetworkTypePattern WiFi();
71 static NetworkTypePattern Cellular();
72 static NetworkTypePattern VPN();
73 static NetworkTypePattern Wimax();
74
75 // Matches only networks of exactly the type |shill_network_type|, which must
76 // be one of the types defined in service_constants.h (e.g.
77 // flimflam::kTypeWifi).
78 // Note: Shill distinguishes Ethernet without EAP from Ethernet with EAP. If
79 // unsure, better use one of the matchers above.
80 static NetworkTypePattern Primitive(const std::string& shill_network_type);
81
82 bool Equals(const NetworkTypePattern& other) const;
83 bool Matches(const std::string& shill_network_type) const;
84
85 // Returns true if this pattern matches every network type that |subpattern|
86 // matches.
87 bool ContainsPattern(const NetworkTypePattern& subpattern) const;
88
89 std::string ToDebugString() const;
90
91 private:
92 explicit NetworkTypePattern(int pattern);
93
94 // The bit array of the matching network types.
95 int pattern_;
96
97 DISALLOW_ASSIGN(NetworkTypePattern);
98 };
99
52 } // namespace chromeos 100 } // namespace chromeos
53 101
54 #endif // CHROMEOS_NETWORK_SHILL_PROPERTY_UTIL_H_ 102 #endif // CHROMEOS_NETWORK_SHILL_PROPERTY_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698