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

Side by Side Diff: net/proxy/proxy_bypass_rules.h

Issue 2391453002: Remove stl_util's deletion functions from net/proxy/. (Closed)
Patch Set: fixes Created 4 years, 2 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
« no previous file with comments | « net/proxy/mojo_proxy_resolver_impl.cc ('k') | net/proxy/proxy_bypass_rules.cc » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 NET_PROXY_PROXY_BYPASS_RULES_H_ 5 #ifndef NET_PROXY_PROXY_BYPASS_RULES_H_
6 #define NET_PROXY_PROXY_BYPASS_RULES_H_ 6 #define NET_PROXY_PROXY_BYPASS_RULES_H_
7 7
8 #include <memory>
8 #include <string> 9 #include <string>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "net/base/net_export.h" 13 #include "net/base/net_export.h"
13 #include "url/gurl.h" 14 #include "url/gurl.h"
14 15
15 namespace net { 16 namespace net {
16 17
17 // ProxyBypassRules describes the set of URLs that should bypass the proxy 18 // ProxyBypassRules describes the set of URLs that should bypass the proxy
18 // settings, as a list of rules. A URL is said to match the bypass rules 19 // settings, as a list of rules. A URL is said to match the bypass rules
19 // if it matches any one of these rules. 20 // if it matches any one of these rules.
20 class NET_EXPORT ProxyBypassRules { 21 class NET_EXPORT ProxyBypassRules {
21 public: 22 public:
22 // Interface for an individual proxy bypass rule. 23 // Interface for an individual proxy bypass rule.
23 class NET_EXPORT Rule { 24 class NET_EXPORT Rule {
24 public: 25 public:
25 Rule(); 26 Rule();
26 virtual ~Rule(); 27 virtual ~Rule();
27 28
28 // Returns true if |url| matches the rule. 29 // Returns true if |url| matches the rule.
29 virtual bool Matches(const GURL& url) const = 0; 30 virtual bool Matches(const GURL& url) const = 0;
30 31
31 // Returns a string representation of this rule. This is used both for 32 // Returns a string representation of this rule. This is used both for
32 // visualizing the rules, and also to test equality of a rules list. 33 // visualizing the rules, and also to test equality of a rules list.
33 virtual std::string ToString() const = 0; 34 virtual std::string ToString() const = 0;
34 35
35 // Creates a copy of this rule. (Caller is responsible for deleting it) 36 // Creates a copy of this rule.
36 virtual Rule* Clone() const = 0; 37 virtual std::unique_ptr<Rule> Clone() const = 0;
37 38
38 bool Equals(const Rule& rule) const; 39 bool Equals(const Rule& rule) const;
39 40
40 private: 41 private:
41 DISALLOW_COPY_AND_ASSIGN(Rule); 42 DISALLOW_COPY_AND_ASSIGN(Rule);
42 }; 43 };
43 44
44 typedef std::vector<const Rule*> RuleList; 45 typedef std::vector<std::unique_ptr<Rule>> RuleList;
45 46
46 // Note: This class supports copy constructor and assignment. 47 // Note: This class supports copy constructor and assignment.
47 ProxyBypassRules(); 48 ProxyBypassRules();
48 ProxyBypassRules(const ProxyBypassRules& rhs); 49 ProxyBypassRules(const ProxyBypassRules& rhs);
49 ~ProxyBypassRules(); 50 ~ProxyBypassRules();
50 ProxyBypassRules& operator=(const ProxyBypassRules& rhs); 51 ProxyBypassRules& operator=(const ProxyBypassRules& rhs);
51 52
52 // Returns the current list of rules. The rules list contains pointers 53 // Returns the current list of rules. The rules list contains pointers
53 // which are owned by this class, callers should NOT keep references 54 // which are owned by this class, callers should NOT keep references
54 // or delete them. 55 // or delete them.
55 const RuleList& rules() const { return rules_; } 56 const RuleList& rules() const { return rules_; }
56 57
57 // Returns true if |url| matches any of the proxy bypass rules. 58 // Returns true if |url| matches any of the proxy bypass rules.
58 bool Matches(const GURL& url) const; 59 bool Matches(const GURL& url) const;
59 60
60 // Returns true if |*this| is equal to |other|; in other words, whether they 61 // Returns true if |*this| is equal to |other|; in other words, whether they
61 // describe the same set of rules. 62 // describe the same set of rules.
62 bool Equals(const ProxyBypassRules& other) const; 63 bool Equals(const ProxyBypassRules& other) const;
63 64
64 // Initializes the list of rules by parsing the string |raw|. |raw| is a 65 // Initializes the list of rules by parsing the string |raw|. |raw| is a
65 // comma separated list of rules. See AddRuleFromString() to see the list 66 // comma separated list of rules. See AddRuleFromString() to see the list
66 // of supported formats. 67 // of supported formats.
67 void ParseFromString(const std::string& raw); 68 void ParseFromString(const std::string& raw);
68 69
69 // This is a variant of ParseFromString, which interprets hostname patterns 70 // This is a variant of ParseFromString, which interprets hostname patterns
70 // as suffix tests rather than hostname tests (so "google.com" would actually 71 // as suffix tests rather than hostname tests (so "google.com" would actually
71 // match "*google.com"). This is only currently used for the linux no_proxy 72 // match "*google.com"). This is only currently used for the linux no_proxy
72 // evironment variable. It is less flexible, since with the suffix matching 73 // environment variable. It is less flexible, since with the suffix matching
73 // format you can't match an individual host. 74 // format you can't match an individual host.
74 // NOTE: Use ParseFromString() unless you truly need this behavior. 75 // NOTE: Use ParseFromString() unless you truly need this behavior.
75 void ParseFromStringUsingSuffixMatching(const std::string& raw); 76 void ParseFromStringUsingSuffixMatching(const std::string& raw);
76 77
77 // Adds a rule that matches a URL when all of the following are true: 78 // Adds a rule that matches a URL when all of the following are true:
78 // (a) The URL's scheme matches |optional_scheme|, if 79 // (a) The URL's scheme matches |optional_scheme|, if
79 // |!optional_scheme.empty()| 80 // |!optional_scheme.empty()|
80 // (b) The URL's hostname matches |hostname_pattern|. 81 // (b) The URL's hostname matches |hostname_pattern|.
81 // (c) The URL's (effective) port number matches |optional_port| if 82 // (c) The URL's (effective) port number matches |optional_port| if
82 // |optional_port != -1| 83 // |optional_port != -1|
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 bool use_hostname_suffix_matching); 172 bool use_hostname_suffix_matching);
172 bool AddRuleFromStringInternalWithLogging(const std::string& raw, 173 bool AddRuleFromStringInternalWithLogging(const std::string& raw,
173 bool use_hostname_suffix_matching); 174 bool use_hostname_suffix_matching);
174 175
175 RuleList rules_; 176 RuleList rules_;
176 }; 177 };
177 178
178 } // namespace net 179 } // namespace net
179 180
180 #endif // NET_PROXY_PROXY_BYPASS_RULES_H_ 181 #endif // NET_PROXY_PROXY_BYPASS_RULES_H_
OLDNEW
« no previous file with comments | « net/proxy/mojo_proxy_resolver_impl.cc ('k') | net/proxy/proxy_bypass_rules.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698