summaryrefslogtreecommitdiffstats
path: root/net/base/registry_controlled_domain.h
diff options
context:
space:
mode:
Diffstat (limited to 'net/base/registry_controlled_domain.h')
-rw-r--r--net/base/registry_controlled_domain.h32
1 files changed, 18 insertions, 14 deletions
diff --git a/net/base/registry_controlled_domain.h b/net/base/registry_controlled_domain.h
index 72d7512..b5ba97f6 100644
--- a/net/base/registry_controlled_domain.h
+++ b/net/base/registry_controlled_domain.h
@@ -107,8 +107,8 @@
GURL to normalize rules, and validating the rules.
*/
-#ifndef NET_BASE_REGISTRY_CONTROLLED_DOMAIN_H__
-#define NET_BASE_REGISTRY_CONTROLLED_DOMAIN_H__
+#ifndef NET_BASE_REGISTRY_CONTROLLED_DOMAIN_H_
+#define NET_BASE_REGISTRY_CONTROLLED_DOMAIN_H_
#include <map>
#include <string>
@@ -119,9 +119,13 @@ class GURL;
namespace net {
+struct RegistryControlledDomainServiceSingletonTraits;
+
// This class is a singleton.
class RegistryControlledDomainService {
public:
+ ~RegistryControlledDomainService() { }
+
// Returns the registered, organization-identifying host and all its registry
// information, but no subdomains, from the given GURL. Returns an empty
// string if the GURL is invalid, has no host (e.g. a file: URL), has multiple
@@ -194,20 +198,23 @@ class RegistryControlledDomainService {
// The entire protected API is only for unit testing. I mean it. Don't make
// me come over there!
RegistryControlledDomainService() { }
- ~RegistryControlledDomainService() { }
- // Clears the static singleton instance. This is used by unit tests to
- // create a new instance for each test, to help ensure test independence.
- static void ResetInstance() {
- delete instance_;
- instance_ = NULL;
- }
+ // Set the RegistryControledDomainService instance to be used internally.
+ // |instance| will supersede the singleton instance normally used. If
+ // |instance| is NULL, normal behavior is restored, and internal operations
+ // will return to using the singleton. This function always returns the
+ // instance set by the most recent call to SetInstance.
+ static RegistryControlledDomainService* SetInstance(
+ RegistryControlledDomainService* instance);
// Sets the domain_data_ of the current instance (creating one, if necessary),
// then parses it.
static void UseDomainData(const std::string& data);
private:
+ // To allow construction of the internal singleton instance.
+ friend struct RegistryControlledDomainServiceSingletonTraits;
+
// Using the StringSegment class, we can compare portions of strings without
// needing to allocate or copy them.
class StringSegment {
@@ -272,9 +279,6 @@ class RegistryControlledDomainService {
// assumed to be syntactically valid.
void ParseDomainData();
- // The class's singleton instance.
- static RegistryControlledDomainService* instance_;
-
// Returns the singleton instance, after attempting to initialize it.
// NOTE that if the effective-TLD data resource can't be found, the instance
// will be initialized and continue operation with an empty domain_map_.
@@ -294,9 +298,9 @@ class RegistryControlledDomainService {
size_t GetRegistryLengthImpl(const std::string& host,
bool allow_unknown_registries);
- DISALLOW_EVIL_CONSTRUCTORS(RegistryControlledDomainService);
+ DISALLOW_COPY_AND_ASSIGN(RegistryControlledDomainService);
};
} // namespace net
-#endif // NET_BASE_REGISTRY_CONTROLLED_DOMAIN_H__
+#endif // NET_BASE_REGISTRY_CONTROLLED_DOMAIN_H_