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

Side by Side Diff: net/base/host_mapping_rules.h

Issue 3412016: FBTF: Move a bunch of code to the headers and remove includes. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Rebase + fixed windows issues locally Created 10 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
« no previous file with comments | « net/base/ev_root_ca_metadata.cc ('k') | net/base/host_mapping_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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_BASE_HOST_MAPPING_RULES_H_ 5 #ifndef NET_BASE_HOST_MAPPING_RULES_H_
6 #define NET_BASE_HOST_MAPPING_RULES_H_ 6 #define NET_BASE_HOST_MAPPING_RULES_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 12
13 namespace net { 13 namespace net {
14 14
15 class HostPortPair; 15 class HostPortPair;
16 16
17 class HostMappingRules { 17 class HostMappingRules {
18 public: 18 public:
19 HostMappingRules(); 19 HostMappingRules();
20 ~HostMappingRules();
20 21
21 // Modifies |*host_port| based on the current rules. Returns true if the 22 // Modifies |*host_port| based on the current rules. Returns true if the
22 // RequestInfo was modified, false otherwise. 23 // RequestInfo was modified, false otherwise.
23 bool RewriteHost(HostPortPair* host_port) const; 24 bool RewriteHost(HostPortPair* host_port) const;
24 25
25 // Adds a rule to this mapper. The format of the rule can be one of: 26 // Adds a rule to this mapper. The format of the rule can be one of:
26 // 27 //
27 // "MAP" <hostname_pattern> <replacement_host> [":" <replacement_port>] 28 // "MAP" <hostname_pattern> <replacement_host> [":" <replacement_port>]
28 // "EXCLUDE" <hostname_pattern> 29 // "EXCLUDE" <hostname_pattern>
29 // 30 //
30 // The <replacement_host> can be either a hostname, or an IP address literal. 31 // The <replacement_host> can be either a hostname, or an IP address literal.
31 // 32 //
32 // Returns true if the rule was successfully parsed and added. 33 // Returns true if the rule was successfully parsed and added.
33 bool AddRuleFromString(const std::string& rule_string); 34 bool AddRuleFromString(const std::string& rule_string);
34 35
35 // Sets the rules from a comma separated list of rules. 36 // Sets the rules from a comma separated list of rules.
36 void SetRulesFromString(const std::string& rules_string); 37 void SetRulesFromString(const std::string& rules_string);
37 38
38 private: 39 private:
39 struct MapRule { 40 struct MapRule;
40 MapRule() : replacement_port(-1) {} 41 struct ExclusionRule;
41
42 std::string hostname_pattern;
43 std::string replacement_hostname;
44 int replacement_port;
45 };
46
47 struct ExclusionRule {
48 std::string hostname_pattern;
49 };
50 42
51 typedef std::vector<MapRule> MapRuleList; 43 typedef std::vector<MapRule> MapRuleList;
52 typedef std::vector<ExclusionRule> ExclusionRuleList; 44 typedef std::vector<ExclusionRule> ExclusionRuleList;
53 45
54 MapRuleList map_rules_; 46 MapRuleList map_rules_;
55 ExclusionRuleList exclusion_rules_; 47 ExclusionRuleList exclusion_rules_;
56 48
57 DISALLOW_COPY_AND_ASSIGN(HostMappingRules); 49 DISALLOW_COPY_AND_ASSIGN(HostMappingRules);
58 }; 50 };
59 51
60 } // namespace net 52 } // namespace net
61 53
62 #endif // NET_BASE_HOST_MAPPING_RULES_H_ 54 #endif // NET_BASE_HOST_MAPPING_RULES_H_
OLDNEW
« no previous file with comments | « net/base/ev_root_ca_metadata.cc ('k') | net/base/host_mapping_rules.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698