Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | 1 //* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
| 2 /* ***** BEGIN LICENSE BLOCK ***** | 2 /* ***** BEGIN LICENSE BLOCK ***** |
| 3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
| 4 * | 4 * |
| 5 * The contents of this file are subject to the Mozilla Public License Version | 5 * The contents of this file are subject to the Mozilla Public License Version |
| 6 * 1.1 (the "License"); you may not use this file except in compliance with | 6 * 1.1 (the "License"); you may not use this file except in compliance with |
| 7 * the License. You may obtain a copy of the License at | 7 * the License. You may obtain a copy of the License at |
| 8 * http://www.mozilla.org/MPL/ | 8 * http://www.mozilla.org/MPL/ |
| 9 * | 9 * |
| 10 * Software distributed under the License is distributed on an "AS IS" basis, | 10 * Software distributed under the License is distributed on an "AS IS" basis, |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 static size_t GetRegistryLength(const GURL& gurl, | 191 static size_t GetRegistryLength(const GURL& gurl, |
| 192 bool allow_unknown_registries); | 192 bool allow_unknown_registries); |
| 193 | 193 |
| 194 // Like the GURL version, but takes a host (which is canonicalized internally) | 194 // Like the GURL version, but takes a host (which is canonicalized internally) |
| 195 // instead of a full GURL. | 195 // instead of a full GURL. |
| 196 static size_t GetRegistryLength(const std::string& host, | 196 static size_t GetRegistryLength(const std::string& host, |
| 197 bool allow_unknown_registries); | 197 bool allow_unknown_registries); |
| 198 static size_t GetRegistryLength(const std::wstring& host, | 198 static size_t GetRegistryLength(const std::wstring& host, |
| 199 bool allow_unknown_registries); | 199 bool allow_unknown_registries); |
| 200 | 200 |
| 201 // Returns the singleton instance, after attempting to initialize it. | |
| 202 // NOTE that if the effective-TLD data resource can't be found, the instance | |
| 203 // will be initialized and continue operation with simple default TLD data. | |
| 204 static RegistryControlledDomainService* GetInstance(); | |
|
Nico
2010/12/12 23:42:47
Does this have to become public?
| |
| 205 | |
| 201 protected: | 206 protected: |
| 202 // The entire protected API is only for unit testing. I mean it. Don't make | 207 // The entire protected API is only for unit testing. I mean it. Don't make |
| 203 // me come over there! | 208 // me come over there! |
| 204 RegistryControlledDomainService(); | 209 RegistryControlledDomainService(); |
| 205 | 210 |
| 206 // Set the RegistryControledDomainService instance to be used internally. | 211 // Set the RegistryControledDomainService instance to be used internally. |
| 207 // |instance| will supersede the singleton instance normally used. If | 212 // |instance| will supersede the singleton instance normally used. If |
| 208 // |instance| is NULL, normal behavior is restored, and internal operations | 213 // |instance| is NULL, normal behavior is restored, and internal operations |
| 209 // will return to using the singleton. This function always returns the | 214 // will return to using the singleton. This function always returns the |
| 210 // instance set by the most recent call to SetInstance. | 215 // instance set by the most recent call to SetInstance. |
| 211 static RegistryControlledDomainService* SetInstance( | 216 static RegistryControlledDomainService* SetInstance( |
| 212 RegistryControlledDomainService* instance); | 217 RegistryControlledDomainService* instance); |
| 213 | 218 |
| 214 typedef const struct DomainRule* (*FindDomainPtr)(const char *, unsigned int); | 219 typedef const struct DomainRule* (*FindDomainPtr)(const char *, unsigned int); |
| 215 | 220 |
| 216 // Used for unit tests, so that a different perfect hash map from the full | 221 // Used for unit tests, so that a different perfect hash map from the full |
| 217 // list is used. | 222 // list is used. |
| 218 static void UseFindDomainFunction(FindDomainPtr function); | 223 static void UseFindDomainFunction(FindDomainPtr function); |
| 219 | 224 |
| 220 private: | 225 private: |
| 221 // To allow construction of the internal singleton instance. | 226 // To allow construction of the internal singleton instance. |
| 222 friend struct DefaultSingletonTraits<RegistryControlledDomainService>; | 227 friend struct DefaultSingletonTraits<RegistryControlledDomainService>; |
| 223 | 228 |
| 224 // Returns the singleton instance, after attempting to initialize it. | |
| 225 // NOTE that if the effective-TLD data resource can't be found, the instance | |
| 226 // will be initialized and continue operation with simple default TLD data. | |
| 227 static RegistryControlledDomainService* GetInstance(); | |
| 228 | |
| 229 // Internal workings of the static public methods. See above. | 229 // Internal workings of the static public methods. See above. |
| 230 static std::string GetDomainAndRegistryImpl(const std::string& host); | 230 static std::string GetDomainAndRegistryImpl(const std::string& host); |
| 231 size_t GetRegistryLengthImpl(const std::string& host, | 231 size_t GetRegistryLengthImpl(const std::string& host, |
| 232 bool allow_unknown_registries); | 232 bool allow_unknown_registries); |
| 233 | 233 |
| 234 // Function that returns a DomainRule given a domain. | 234 // Function that returns a DomainRule given a domain. |
| 235 FindDomainPtr find_domain_function_; | 235 FindDomainPtr find_domain_function_; |
| 236 | 236 |
| 237 DISALLOW_COPY_AND_ASSIGN(RegistryControlledDomainService); | 237 DISALLOW_COPY_AND_ASSIGN(RegistryControlledDomainService); |
| 238 }; | 238 }; |
| 239 | 239 |
| 240 } // namespace net | 240 } // namespace net |
| 241 | 241 |
| 242 #endif // NET_BASE_REGISTRY_CONTROLLED_DOMAIN_H_ | 242 #endif // NET_BASE_REGISTRY_CONTROLLED_DOMAIN_H_ |
| OLD | NEW |