summaryrefslogtreecommitdiffstats
path: root/net/base/registry_controlled_domain.h
diff options
context:
space:
mode:
authormmentovai@google.com <mmentovai@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-21 18:15:35 +0000
committermmentovai@google.com <mmentovai@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-21 18:15:35 +0000
commitd862fd9d396126f3f06a8061412def6d61d156fd (patch)
tree7052b96f95ac8b9b2f3d861daddbc82d4cdda99a /net/base/registry_controlled_domain.h
parent4167c3a50e73968cd47e0eb2502f017f432d367a (diff)
downloadchromium_src-d862fd9d396126f3f06a8061412def6d61d156fd.zip
chromium_src-d862fd9d396126f3f06a8061412def6d61d156fd.tar.gz
chromium_src-d862fd9d396126f3f06a8061412def6d61d156fd.tar.bz2
Port cookie_monster, net_util, and registry_controlled_domain to POSIXish platforms
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1164 0039d316-1c4b-4281-b951-d872f2087c98
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_