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

Unified Diff: net/dns/mock_host_resolver.h

Issue 2837813004: Sync the browser test host resolver with the network process before a test runs. (Closed)
Patch Set: review comments Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/utility/utility_service_factory.cc ('k') | net/dns/mock_host_resolver.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/mock_host_resolver.h
diff --git a/net/dns/mock_host_resolver.h b/net/dns/mock_host_resolver.h
index cca300acbc69c90e93bfa0772f27646533f0670f..d61002c56e543b5932658bcf3b95073a5786a90d 100644
--- a/net/dns/mock_host_resolver.h
+++ b/net/dns/mock_host_resolver.h
@@ -9,6 +9,7 @@
#include <list>
#include <map>
+#include <string>
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
@@ -212,6 +213,11 @@ class RuleBasedHostResolverProc : public HostResolverProc {
// Deletes all the rules that have been added.
void ClearRules();
+ // Causes method calls that add or delete rules to assert.
+ // TODO(jam): once this class isn't used by tests that use an out of process
+ // network service, remove this method and make Rule private.
+ void DisableModifications();
+
// HostResolverProc methods:
int Resolve(const std::string& host,
AddressFamily address_family,
@@ -219,10 +225,36 @@ class RuleBasedHostResolverProc : public HostResolverProc {
AddressList* addrlist,
int* os_error) override;
- private:
- struct Rule;
+ struct Rule {
+ enum ResolverType {
+ kResolverTypeFail,
+ kResolverTypeSystem,
+ kResolverTypeIPLiteral,
+ };
+
+ Rule(ResolverType resolver_type,
+ const std::string& host_pattern,
+ AddressFamily address_family,
+ HostResolverFlags host_resolver_flags,
+ const std::string& replacement,
+ const std::string& canonical_name,
+ int latency_ms);
+ Rule(const Rule& other);
+
+ ResolverType resolver_type;
+ std::string host_pattern;
+ AddressFamily address_family;
+ HostResolverFlags host_resolver_flags;
+ std::string replacement;
+ std::string canonical_name;
+ int latency_ms; // In milliseconds.
+ };
+
typedef std::list<Rule> RuleList;
+ RuleList GetRules();
+
+ private:
~RuleBasedHostResolverProc() override;
void AddRuleInternal(const Rule& rule);
@@ -231,6 +263,9 @@ class RuleBasedHostResolverProc : public HostResolverProc {
// Must be obtained before writing to or reading from |rules_|.
base::Lock rule_lock_;
+
+ // Whether changes are allowed.
+ bool modifications_allowed_;
};
// Create rules that map all requests to localhost.
« no previous file with comments | « content/utility/utility_service_factory.cc ('k') | net/dns/mock_host_resolver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698