diff options
author | mmentovai@google.com <mmentovai@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-21 16:20:02 +0000 |
---|---|---|
committer | mmentovai@google.com <mmentovai@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-21 16:20:02 +0000 |
commit | 7fad3d83abe5281e6be62f5a809da4015ad6b222 (patch) | |
tree | ab84b802185c39e77f8334e18459b86b32416a32 /net/base/registry_controlled_domain.h | |
parent | f25387b62a3cccde48622d0b7fca57cd6fb16ab7 (diff) | |
download | chromium_src-7fad3d83abe5281e6be62f5a809da4015ad6b222.zip chromium_src-7fad3d83abe5281e6be62f5a809da4015ad6b222.tar.gz chromium_src-7fad3d83abe5281e6be62f5a809da4015ad6b222.tar.bz2 |
Port cookie_monster, net_util, and registry_controlled_domain to POSIXish platforms
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1154 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/registry_controlled_domain.h')
-rw-r--r-- | net/base/registry_controlled_domain.h | 32 |
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_ |