summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authormmentovai@google.com <mmentovai@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-21 16:39:56 +0000
committermmentovai@google.com <mmentovai@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-21 16:39:56 +0000
commit70a41f29d64a3f5198149016293ab9ae5d23a03d (patch)
tree8388e8042ed2934f9d2c24f17205469943eefbbc /net
parentf297d180543addddd8f046bc2bd76ad7ef52fa51 (diff)
downloadchromium_src-70a41f29d64a3f5198149016293ab9ae5d23a03d.zip
chromium_src-70a41f29d64a3f5198149016293ab9ae5d23a03d.tar.gz
chromium_src-70a41f29d64a3f5198149016293ab9ae5d23a03d.tar.bz2
Back out r1154 due to test failures
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1156 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/cookie_monster.cc15
-rw-r--r--net/base/cookie_monster.h22
-rw-r--r--net/base/cookie_monster_unittest.cc20
-rw-r--r--net/base/net_util.cc65
-rw-r--r--net/base/registry_controlled_domain.cc41
-rw-r--r--net/base/registry_controlled_domain.h32
-rw-r--r--net/base/registry_controlled_domain_unittest.cc148
-rw-r--r--net/net.xcodeproj/project.pbxproj10
8 files changed, 158 insertions, 195 deletions
diff --git a/net/base/cookie_monster.cc b/net/base/cookie_monster.cc
index 12b1b46d7..b8dd8e7 100644
--- a/net/base/cookie_monster.cc
+++ b/net/base/cookie_monster.cc
@@ -192,13 +192,8 @@ Time CookieMonster::ParseCookieTime(const std::string& time_string) {
// Numeric field w/ a colon
} else if (token.find(':') != std::string::npos) {
if (!found_time &&
-#ifdef COMPILER_MSVC
- sscanf_s(
-#else
- sscanf(
-#endif
- token.c_str(), "%2u:%2u:%2u", &exploded.hour,
- &exploded.minute, &exploded.second) == 3) {
+ sscanf_s(token.c_str(), "%2hu:%2hu:%2hu", &exploded.hour,
+ &exploded.minute, &exploded.second) == 3) {
found_time = true;
} else {
// We should only ever encounter one time-like thing. If we're here,
@@ -339,12 +334,7 @@ static Time CanonExpiration(const CookieMonster::ParsedCookie& pc,
// First, try the Max-Age attribute.
uint64 max_age = 0;
if (pc.HasMaxAge() &&
-#if defined(COMPILER_MSVC)
sscanf_s(pc.MaxAge().c_str(), " %I64u", &max_age) == 1) {
-
-#else
- sscanf(pc.MaxAge().c_str(), " %llu", &max_age) == 1) {
-#endif
return current + TimeDelta::FromSeconds(max_age);
}
@@ -430,7 +420,6 @@ bool CookieMonster::SetCookieWithCreationTime(const GURL& url,
// We should have only purged at most one matching cookie.
int num_deleted = DeleteEquivalentCookies(cookie_domain, *cc);
- DCHECK(num_deleted <= 1);
COOKIE_DLOG(INFO) << "SetCookie() cc: " << cc->DebugString();
diff --git a/net/base/cookie_monster.h b/net/base/cookie_monster.h
index 80f8b34..9c1a6f5 100644
--- a/net/base/cookie_monster.h
+++ b/net/base/cookie_monster.h
@@ -29,13 +29,13 @@
// Brought to you by the letter D and the number 2.
-#ifndef NET_BASE_COOKIE_MONSTER_H_
-#define NET_BASE_COOKIE_MONSTER_H_
+#ifndef NET_BASE_COOKIE_MONSTER_H__
+#define NET_BASE_COOKIE_MONSTER_H__
-#include <map>
#include <string>
-#include <utility>
#include <vector>
+#include <utility>
+#include <map>
#include "base/basictypes.h"
#include "base/lock.h"
@@ -199,7 +199,7 @@ class CookieMonster {
// Lock for thread-safety
Lock lock_;
- DISALLOW_COPY_AND_ASSIGN(CookieMonster);
+ DISALLOW_EVIL_CONSTRUCTORS(CookieMonster);
};
class CookieMonster::ParsedCookie {
@@ -208,7 +208,7 @@ class CookieMonster::ParsedCookie {
typedef std::vector<TokenValuePair> PairList;
// The maximum length of a cookie string we will try to parse
- static const size_t kMaxCookieSize = 4096;
+ static const int kMaxCookieSize = 4096;
// The maximum number of Token/Value pairs. Shouldn't have more than 8.
static const int kMaxPairs = 16;
@@ -267,11 +267,11 @@ class CookieMonster::CanonicalCookie {
: name_(name),
value_(value),
path_(path),
+ secure_(secure),
+ httponly_(httponly),
creation_date_(creation),
- expiry_date_(expires),
has_expires_(has_expires),
- secure_(secure),
- httponly_(httponly) {
+ expiry_date_(expires) {
}
// Supports the default copy constructor.
@@ -306,8 +306,8 @@ class CookieMonster::CanonicalCookie {
std::string value_;
std::string path_;
Time creation_date_;
- Time expiry_date_;
bool has_expires_;
+ Time expiry_date_;
bool secure_;
bool httponly_;
};
@@ -332,4 +332,4 @@ class CookieMonster::PersistentCookieStore {
} // namespace net
-#endif // NET_BASE_COOKIE_MONSTER_H_
+#endif // NET_BASE_COOKIE_MONSTER_H__
diff --git a/net/base/cookie_monster_unittest.cc b/net/base/cookie_monster_unittest.cc
index 47eb90c..9de1464 100644
--- a/net/base/cookie_monster_unittest.cc
+++ b/net/base/cookie_monster_unittest.cc
@@ -495,18 +495,12 @@ TEST(CookieMonsterTest, HttpOnlyTest) {
url_google, net::CookieMonster::INCLUDE_HTTPONLY), "A=B");
}
-namespace {
-
-struct CookieDateParsingCase {
- const char* str;
- const bool valid;
- const time_t epoch;
-};
-
-} // namespace
-
TEST(CookieMonsterTest, TestCookieDateParsing) {
- const CookieDateParsingCase tests[] = {
+ const struct {
+ const char* str;
+ const bool valid;
+ const time_t epoch;
+ } tests[] = {
{ "Sat, 15-Apr-17 21:01:22 GMT", true, 1492290082 },
{ "Thu, 19-Apr-2007 16:00:00 GMT", true, 1176998400 },
{ "Wed, 25 Apr 2007 21:02:13 GMT", true, 1177534933 },
@@ -578,7 +572,7 @@ TEST(CookieMonsterTest, TestCookieDateParsing) {
};
Time parsed_time;
- for (size_t i = 0; i < arraysize(tests); ++i) {
+ for (int i = 0; i < arraysize(tests); ++i) {
parsed_time = net::CookieMonster::ParseCookieTime(tests[i].str);
if (!tests[i].valid) {
EXPECT_FALSE(!parsed_time.is_null()) << tests[i].str;
@@ -789,7 +783,7 @@ TEST(CookieMonsterTest, TestTotalGarbageCollection) {
// Formerly NetUtilTest.CookieTest back when we used wininet's cookie handling.
TEST(CookieMonsterTest, NetUtilCookieTest) {
- const GURL test_url("http://mojo.jojo.google.izzle/");
+ const GURL test_url(L"http://mojo.jojo.google.izzle/");
net::CookieMonster cm;
diff --git a/net/base/net_util.cc b/net/base/net_util.cc
index 8ceccc1..e0cbd04 100644
--- a/net/base/net_util.cc
+++ b/net/base/net_util.cc
@@ -451,8 +451,8 @@ UScriptCode NormalizeScript(UScriptCode code) {
}
}
-bool IsIDNComponentInSingleScript(const char16* str, int str_len) {
- UScriptCode first_script = USCRIPT_INVALID_CODE;
+bool IsIDNComponentInSingleScript(const wchar_t* str, int str_len) {
+ UScriptCode first_script;
bool is_first = true;
int i = 0;
@@ -491,7 +491,7 @@ bool IsCompatibleWithASCIILetters(const std::string& lang) {
// Returns true if the given Unicode host component is safe to display to the
// user.
-bool IsIDNComponentSafe(const char16* str,
+bool IsIDNComponentSafe(const wchar_t* str,
int str_len,
const std::wstring& languages) {
// Most common cases (non-IDN) do not reach here so that we don't
@@ -532,7 +532,14 @@ bool IsIDNComponentSafe(const char16* str,
#endif
DCHECK(U_SUCCESS(status));
UnicodeSet component_characters;
+#ifdef WCHAR_T_IS_UTF32
+ std::string16 converted_str;
+ WideToUTF16(str, str_len, &converted_str);
+ component_characters.addAll(UnicodeString(converted_str.c_str(),
+ converted_str.length()));
+#else
component_characters.addAll(UnicodeString(str, str_len));
+#endif
if (dangerous_characters.containsSome(component_characters))
return false;
@@ -591,10 +598,10 @@ bool IsIDNComponentSafe(const char16* str,
// Converts one component of a host (between dots) to IDN if safe. The result
// will be APPENDED to the given output string and will be the same as the
// input if it is not IDN or the IDN is unsafe to display.
-void IDNToUnicodeOneComponent(const char16* comp,
+void IDNToUnicodeOneComponent(const wchar_t* comp,
int comp_len,
const std::wstring& languages,
- std::string16* out) {
+ std::wstring* out) {
DCHECK(comp_len >= 0);
if (comp_len == 0)
return;
@@ -605,8 +612,7 @@ void IDNToUnicodeOneComponent(const char16* comp,
size_t host_begin_in_output = out->size();
// Just copy the input if it can't be an IDN component.
- if (comp_len < 4 ||
- comp[0] != 'x' || comp[1] != 'n' || comp[2] != '-' || comp[3] != '-') {
+ if (comp_len < 4 || wcsncmp(comp, L"xn--", 4)) {
out->resize(host_begin_in_output + comp_len);
for (int i = 0; i < comp_len; i++)
(*out)[host_begin_in_output + i] = comp[i];
@@ -615,10 +621,23 @@ void IDNToUnicodeOneComponent(const char16* comp,
while (true) {
UErrorCode status = U_ZERO_ERROR;
+#if defined(WCHAR_T_IS_UTF32)
+ std::string16 comp16;
+ WideToUTF16(comp, comp_len, &comp16);
+ std::string16 out16;
+ WideToUTF16(out->c_str(), out->length(), &out16);
+ out16.resize(out16.size() + extra_space);
+ int output_chars =
+ uidna_IDNToUnicode(comp16.data(), static_cast<int32>(comp16.length()),
+ &(out16)[host_begin_in_output], extra_space,
+ UIDNA_DEFAULT, NULL, &status);
+ *out = UTF16ToWide(out16);
+#else
out->resize(out->size() + extra_space);
int output_chars =
uidna_IDNToUnicode(comp, comp_len, &(*out)[host_begin_in_output],
- extra_space, UIDNA_DEFAULT, NULL, &status);
+ extra_space, UIDNA_DEFAULT, NULL, &status);
+#endif
if (status == U_ZERO_ERROR) {
// Converted successfully.
out->resize(host_begin_in_output + output_chars);
@@ -793,45 +812,37 @@ void IDNToUnicode(const char* host,
const std::wstring& languages,
std::wstring* out) {
// Convert the ASCII input to a wide string for ICU.
- std::string16 input16;
- input16.reserve(host_len);
+ std::wstring wide_input;
+ wide_input.reserve(host_len);
for (int i = 0; i < host_len; i++)
- input16.push_back(host[i]);
-
- std::string16 out16;
+ wide_input.push_back(host[i]);
// Do each component of the host separately, since we enforce script matching
// on a per-component basis.
size_t cur_begin = 0; // Beginning of the current component (inclusive).
- while (cur_begin < input16.size()) {
+ while (cur_begin < wide_input.size()) {
// Find the next dot or the end of the string.
- size_t next_dot = input16.find_first_of('.', cur_begin);
+ size_t next_dot = wide_input.find_first_of('.', cur_begin);
if (next_dot == std::wstring::npos)
- next_dot = input16.size(); // For getting the last component.
+ next_dot = wide_input.size(); // For getting the last component.
if (next_dot > cur_begin) {
// Add the substring that we just found.
- IDNToUnicodeOneComponent(&input16[cur_begin],
+ IDNToUnicodeOneComponent(&wide_input[cur_begin],
static_cast<int>(next_dot - cur_begin),
languages,
- &out16);
+ out);
}
// Need to add the dot we just found (if we found one). This needs to be
// done before we break out below in case the URL ends in a dot.
- if (next_dot < input16.size())
- out16.push_back('.');
+ if (next_dot < wide_input.size())
+ out->push_back('.');
else
break; // No more components left.
cur_begin = next_dot + 1;
}
-
-#if defined(WCHAR_T_IS_UTF32)
- UTF16ToWide(out16.data(), out16.length(), out);
-#elif defined(WCHAR_T_IS_UTF16)
- out->swap(out16);
-#endif
}
std::string CanonicalizeHost(const std::string& host, bool* is_ip_address) {
@@ -861,7 +872,7 @@ std::string CanonicalizeHost(const std::string& host, bool* is_ip_address) {
// Return the host as a string, stripping any unnecessary bits off the ends.
if ((canon_host_component.begin == 0) &&
- (static_cast<size_t>(canon_host_component.len) == canon_host.length()))
+ (canon_host_component.len == canon_host.length()))
return canon_host;
return canon_host.substr(canon_host_component.begin,
canon_host_component.len);
diff --git a/net/base/registry_controlled_domain.cc b/net/base/registry_controlled_domain.cc
index 3f4f024..f0aad4c 100644
--- a/net/base/registry_controlled_domain.cc
+++ b/net/base/registry_controlled_domain.cc
@@ -37,16 +37,16 @@
*
* ***** END LICENSE BLOCK ***** */
-#include "net/base/registry_controlled_domain.h"
+#include <windows.h>
#include "base/logging.h"
-#include "base/singleton.h"
#include "base/string_util.h"
#include "googleurl/src/gurl.h"
#include "googleurl/src/url_parse.h"
#include "net/base/net_module.h"
#include "net/base/net_resources.h"
#include "net/base/net_util.h"
+#include "net/base/registry_controlled_domain.h"
namespace net {
@@ -258,34 +258,23 @@ size_t RegistryControlledDomainService::GetRegistryLengthImpl(
return allow_unknown_registries ? (host.length() - curr_start) : 0;
}
-static RegistryControlledDomainService* test_instance_;
-
-// static
-RegistryControlledDomainService* RegistryControlledDomainService::SetInstance(
- RegistryControlledDomainService* instance) {
- RegistryControlledDomainService* old_instance = test_instance_;
- test_instance_ = instance;
- return old_instance;
-}
-
-struct RegistryControlledDomainServiceSingletonTraits :
- public DefaultSingletonTraits<RegistryControlledDomainService> {
- static RegistryControlledDomainService* New() {
- RegistryControlledDomainService* instance =
- new RegistryControlledDomainService();
- instance->Init();
- return instance;
- }
-};
+RegistryControlledDomainService* RegistryControlledDomainService::instance_ =
+ NULL;
// static
RegistryControlledDomainService* RegistryControlledDomainService::GetInstance()
{
- if (test_instance_)
- return test_instance_;
-
- return Singleton<RegistryControlledDomainService,
- RegistryControlledDomainServiceSingletonTraits>::get();
+ if (!instance_) {
+ RegistryControlledDomainService* s = new RegistryControlledDomainService();
+ s->Init();
+ // TODO(darin): use fix_wp64.h once it lives in base/
+ if (InterlockedCompareExchangePointer(
+ reinterpret_cast<PVOID*>(&instance_), s, NULL)) {
+ // Oops, another thread initialized instance_ out from under us.
+ delete s;
+ }
+ }
+ return instance_;
}
// static
diff --git a/net/base/registry_controlled_domain.h b/net/base/registry_controlled_domain.h
index b5ba97f6..72d7512 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,13 +119,9 @@ 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
@@ -198,23 +194,20 @@ class RegistryControlledDomainService {
// The entire protected API is only for unit testing. I mean it. Don't make
// me come over there!
RegistryControlledDomainService() { }
+ ~RegistryControlledDomainService() { }
- // 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);
+ // 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;
+ }
// 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 {
@@ -279,6 +272,9 @@ 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_.
@@ -298,9 +294,9 @@ class RegistryControlledDomainService {
size_t GetRegistryLengthImpl(const std::string& host,
bool allow_unknown_registries);
- DISALLOW_COPY_AND_ASSIGN(RegistryControlledDomainService);
+ DISALLOW_EVIL_CONSTRUCTORS(RegistryControlledDomainService);
};
} // namespace net
-#endif // NET_BASE_REGISTRY_CONTROLLED_DOMAIN_H_
+#endif // NET_BASE_REGISTRY_CONTROLLED_DOMAIN_H__
diff --git a/net/base/registry_controlled_domain_unittest.cc b/net/base/registry_controlled_domain_unittest.cc
index 05bfea3..590f17b 100644
--- a/net/base/registry_controlled_domain_unittest.cc
+++ b/net/base/registry_controlled_domain_unittest.cc
@@ -33,36 +33,33 @@
namespace {
+class TestRegistryControlledDomainService;
+static TestRegistryControlledDomainService* test_instance_;
+
class TestRegistryControlledDomainService :
public net::RegistryControlledDomainService {
public:
+
+ // Deletes the instance so a new one will be created.
+ static void ResetInstance() {
+ net::RegistryControlledDomainService::ResetInstance();
+ }
+
// Sets and parses the given data.
static void UseDomainData(const std::string& data) {
net::RegistryControlledDomainService::UseDomainData(data);
}
- // Creates a new dedicated instance to be used for testing, deleting any
- // previously-set one.
- static void UseDedicatedInstance() {
- delete static_cast<TestRegistryControlledDomainService*>(
- SetInstance(new TestRegistryControlledDomainService()));
- }
-
- // Restores RegistryControlledDomainService to using its default instance,
- // deleting any previously-set test instance.
- static void UseDefaultInstance() {
- delete static_cast<TestRegistryControlledDomainService*>(SetInstance(NULL));
+ private:
+ TestRegistryControlledDomainService::TestRegistryControlledDomainService() { }
+ TestRegistryControlledDomainService::~TestRegistryControlledDomainService() {
}
};
class RegistryControlledDomainTest : public testing::Test {
protected:
virtual void SetUp() {
- TestRegistryControlledDomainService::UseDedicatedInstance();
- }
-
- virtual void TearDown() {
- TestRegistryControlledDomainService::UseDefaultInstance();
+ TestRegistryControlledDomainService::ResetInstance();
}
};
@@ -189,74 +186,73 @@ TEST_F(RegistryControlledDomainTest, TestGetRegistryLength) {
SetTestData(kTestData);
// Test GURL version of GetRegistryLength().
- EXPECT_EQ(2U, GetRegistryLengthFromURL("http://a.baz.jp/file.html", false));
+ EXPECT_EQ(2, GetRegistryLengthFromURL("http://a.baz.jp/file.html", false));
// 1
- EXPECT_EQ(3U, GetRegistryLengthFromURL("http://a.baz.jp./file.html", false));
+ EXPECT_EQ(3, GetRegistryLengthFromURL("http://a.baz.jp./file.html", false));
// 1
- EXPECT_EQ(0U, GetRegistryLengthFromURL("http://ac.jp", false)); // 2
- EXPECT_EQ(0U, GetRegistryLengthFromURL("http://a.bar.jp", false)); // 3
- EXPECT_EQ(0U, GetRegistryLengthFromURL("http://bar.jp", false)); // 3
- EXPECT_EQ(0U, GetRegistryLengthFromURL("http://baz.bar.jp", false)); // 3 4
- EXPECT_EQ(12U, GetRegistryLengthFromURL("http://a.b.baz.bar.jp", false));
+ EXPECT_EQ(0, GetRegistryLengthFromURL("http://ac.jp", false)); // 2
+ EXPECT_EQ(0, GetRegistryLengthFromURL("http://a.bar.jp", false)); // 3
+ EXPECT_EQ(0, GetRegistryLengthFromURL("http://bar.jp", false)); // 3
+ EXPECT_EQ(0, GetRegistryLengthFromURL("http://baz.bar.jp", false)); // 3 4
+ EXPECT_EQ(12, GetRegistryLengthFromURL("http://a.b.baz.bar.jp", false));
// 4
- EXPECT_EQ(6U, GetRegistryLengthFromURL("http://foo.bar.jp", false)); // 3 5 6
- EXPECT_EQ(6U, GetRegistryLengthFromURL("http://baz.pref.bar.jp", false));
+ EXPECT_EQ(6, GetRegistryLengthFromURL("http://foo.bar.jp", false)); // 3 5 6
+ EXPECT_EQ(6, GetRegistryLengthFromURL("http://baz.pref.bar.jp", false));
// 7
- EXPECT_EQ(11U, GetRegistryLengthFromURL("http://a.b.bar.baz.com", false));
+ EXPECT_EQ(11, GetRegistryLengthFromURL("http://a.b.bar.baz.com", false));
// 8
- EXPECT_EQ(3U, GetRegistryLengthFromURL("http://a.d.c", false)); // 9
- EXPECT_EQ(3U, GetRegistryLengthFromURL("http://.a.d.c", false)); // 9
- EXPECT_EQ(3U, GetRegistryLengthFromURL("http://..a.d.c", false)); // 9
- EXPECT_EQ(1U, GetRegistryLengthFromURL("http://a.b.c", false)); // 9 10
- EXPECT_EQ(0U, GetRegistryLengthFromURL("http://baz.com", false)); // none
- EXPECT_EQ(0U, GetRegistryLengthFromURL("http://baz.com.", false)); // none
- EXPECT_EQ(3U, GetRegistryLengthFromURL("http://baz.com", true)); // none
- EXPECT_EQ(4U, GetRegistryLengthFromURL("http://baz.com.", true)); // none
+ EXPECT_EQ(3, GetRegistryLengthFromURL("http://a.d.c", false)); // 9
+ EXPECT_EQ(3, GetRegistryLengthFromURL("http://.a.d.c", false)); // 9
+ EXPECT_EQ(3, GetRegistryLengthFromURL("http://..a.d.c", false)); // 9
+ EXPECT_EQ(1, GetRegistryLengthFromURL("http://a.b.c", false)); // 9 10
+ EXPECT_EQ(0, GetRegistryLengthFromURL("http://baz.com", false)); // none
+ EXPECT_EQ(0, GetRegistryLengthFromURL("http://baz.com.", false)); // none
+ EXPECT_EQ(3, GetRegistryLengthFromURL("http://baz.com", true)); // none
+ EXPECT_EQ(4, GetRegistryLengthFromURL("http://baz.com.", true)); // none
EXPECT_EQ(std::string::npos, GetRegistryLengthFromURL("", false));
EXPECT_EQ(std::string::npos, GetRegistryLengthFromURL("http://", false));
EXPECT_EQ(std::string::npos,
GetRegistryLengthFromURL("file:///C:/file.html", false));
- EXPECT_EQ(0U, GetRegistryLengthFromURL("http://foo.com..", false));
- EXPECT_EQ(0U, GetRegistryLengthFromURL("http://...", false));
- EXPECT_EQ(0U, GetRegistryLengthFromURL("http://192.168.0.1", false));
- EXPECT_EQ(0U, GetRegistryLengthFromURL("http://localhost", false));
- EXPECT_EQ(0U, GetRegistryLengthFromURL("http://localhost", true));
- EXPECT_EQ(0U, GetRegistryLengthFromURL("http://localhost.", false));
- EXPECT_EQ(0U, GetRegistryLengthFromURL("http://localhost.", true));
- EXPECT_EQ(0U, GetRegistryLengthFromURL("http:////Comment", false));
+ EXPECT_EQ(0, GetRegistryLengthFromURL("http://foo.com..", false));
+ EXPECT_EQ(0, GetRegistryLengthFromURL("http://...", false));
+ EXPECT_EQ(0, GetRegistryLengthFromURL("http://192.168.0.1", false));
+ EXPECT_EQ(0, GetRegistryLengthFromURL("http://localhost", false));
+ EXPECT_EQ(0, GetRegistryLengthFromURL("http://localhost", true));
+ EXPECT_EQ(0, GetRegistryLengthFromURL("http://localhost.", false));
+ EXPECT_EQ(0, GetRegistryLengthFromURL("http://localhost.", true));
+ EXPECT_EQ(0, GetRegistryLengthFromURL("http:////Comment", false));
// Test std::wstring version of GetRegistryLength(). Uses the same
// underpinnings as the GURL version, so this is really more of a check of
// CanonicalizeHost().
- EXPECT_EQ(2U, GetRegistryLengthFromHost(L"a.baz.jp", false)); // 1
- EXPECT_EQ(3U, GetRegistryLengthFromHost(L"a.baz.jp.", false)); // 1
- EXPECT_EQ(0U, GetRegistryLengthFromHost(L"ac.jp", false)); // 2
- EXPECT_EQ(0U, GetRegistryLengthFromHost(L"a.bar.jp", false)); // 3
- EXPECT_EQ(0U, GetRegistryLengthFromHost(L"bar.jp", false)); // 3
- EXPECT_EQ(0U, GetRegistryLengthFromHost(L"baz.bar.jp", false)); // 3 4
- EXPECT_EQ(12U, GetRegistryLengthFromHost(L"a.b.baz.bar.jp", false)); // 4
- EXPECT_EQ(6U, GetRegistryLengthFromHost(L"foo.bar.jp", false)); // 3 5 6
- EXPECT_EQ(6U, GetRegistryLengthFromHost(L"baz.pref.bar.jp", false)); // 7
- EXPECT_EQ(11U, GetRegistryLengthFromHost(L"a.b.bar.baz.com", false));
- // 8
- EXPECT_EQ(3U, GetRegistryLengthFromHost(L"a.d.c", false)); // 9
- EXPECT_EQ(3U, GetRegistryLengthFromHost(L".a.d.c", false)); // 9
- EXPECT_EQ(3U, GetRegistryLengthFromHost(L"..a.d.c", false)); // 9
- EXPECT_EQ(1U, GetRegistryLengthFromHost(L"a.b.c", false)); // 9 10
- EXPECT_EQ(0U, GetRegistryLengthFromHost(L"baz.com", false)); // none
- EXPECT_EQ(0U, GetRegistryLengthFromHost(L"baz.com.", false)); // none
- EXPECT_EQ(3U, GetRegistryLengthFromHost(L"baz.com", true)); // none
- EXPECT_EQ(4U, GetRegistryLengthFromHost(L"baz.com.", true)); // none
+ EXPECT_EQ(2, GetRegistryLengthFromHost(L"a.baz.jp", false)); // 1
+ EXPECT_EQ(3, GetRegistryLengthFromHost(L"a.baz.jp.", false)); // 1
+ EXPECT_EQ(0, GetRegistryLengthFromHost(L"ac.jp", false)); // 2
+ EXPECT_EQ(0, GetRegistryLengthFromHost(L"a.bar.jp", false)); // 3
+ EXPECT_EQ(0, GetRegistryLengthFromHost(L"bar.jp", false)); // 3
+ EXPECT_EQ(0, GetRegistryLengthFromHost(L"baz.bar.jp", false)); // 3 4
+ EXPECT_EQ(12, GetRegistryLengthFromHost(L"a.b.baz.bar.jp", false)); // 4
+ EXPECT_EQ(6, GetRegistryLengthFromHost(L"foo.bar.jp", false)); // 3 5 6
+ EXPECT_EQ(6, GetRegistryLengthFromHost(L"baz.pref.bar.jp", false)); // 7
+ EXPECT_EQ(11, GetRegistryLengthFromHost(L"a.b.bar.baz.com", false)); // 8
+ EXPECT_EQ(3, GetRegistryLengthFromHost(L"a.d.c", false)); // 9
+ EXPECT_EQ(3, GetRegistryLengthFromHost(L".a.d.c", false)); // 9
+ EXPECT_EQ(3, GetRegistryLengthFromHost(L"..a.d.c", false)); // 9
+ EXPECT_EQ(1, GetRegistryLengthFromHost(L"a.b.c", false)); // 9 10
+ EXPECT_EQ(0, GetRegistryLengthFromHost(L"baz.com", false)); // none
+ EXPECT_EQ(0, GetRegistryLengthFromHost(L"baz.com.", false)); // none
+ EXPECT_EQ(3, GetRegistryLengthFromHost(L"baz.com", true)); // none
+ EXPECT_EQ(4, GetRegistryLengthFromHost(L"baz.com.", true)); // none
EXPECT_EQ(std::string::npos, GetRegistryLengthFromHost(L"", false));
- EXPECT_EQ(0U, GetRegistryLengthFromHost(L"foo.com..", false));
- EXPECT_EQ(0U, GetRegistryLengthFromHost(L"..", false));
- EXPECT_EQ(0U, GetRegistryLengthFromHost(L"192.168.0.1", false));
- EXPECT_EQ(0U, GetRegistryLengthFromHost(L"localhost", false));
- EXPECT_EQ(0U, GetRegistryLengthFromHost(L"localhost", true));
- EXPECT_EQ(0U, GetRegistryLengthFromHost(L"localhost.", false));
- EXPECT_EQ(0U, GetRegistryLengthFromHost(L"localhost.", true));
+ EXPECT_EQ(0, GetRegistryLengthFromHost(L"foo.com..", false));
+ EXPECT_EQ(0, GetRegistryLengthFromHost(L"..", false));
+ EXPECT_EQ(0, GetRegistryLengthFromHost(L"192.168.0.1", false));
+ EXPECT_EQ(0, GetRegistryLengthFromHost(L"localhost", false));
+ EXPECT_EQ(0, GetRegistryLengthFromHost(L"localhost", true));
+ EXPECT_EQ(0, GetRegistryLengthFromHost(L"localhost.", false));
+ EXPECT_EQ(0, GetRegistryLengthFromHost(L"localhost.", true));
}
TEST_F(RegistryControlledDomainTest, TestSameDomainOrHost) {
@@ -289,14 +285,12 @@ TEST_F(RegistryControlledDomainTest, TestSameDomainOrHost) {
}
TEST_F(RegistryControlledDomainTest, TestDefaultData) {
- TestRegistryControlledDomainService::UseDefaultInstance();
-
// Note that no data is set: we're using the default rules.
- EXPECT_EQ(3U, GetRegistryLengthFromURL("http://google.com", false));
- EXPECT_EQ(3U, GetRegistryLengthFromURL("http://stanford.edu", false));
- EXPECT_EQ(3U, GetRegistryLengthFromURL("http://ustreas.gov", false));
- EXPECT_EQ(3U, GetRegistryLengthFromURL("http://icann.net", false));
- EXPECT_EQ(3U, GetRegistryLengthFromURL("http://ferretcentral.org", false));
- EXPECT_EQ(0U, GetRegistryLengthFromURL("http://nowhere.foo", false));
- EXPECT_EQ(3U, GetRegistryLengthFromURL("http://nowhere.foo", true));
+ EXPECT_EQ(3, GetRegistryLengthFromURL("http://google.com", false));
+ EXPECT_EQ(3, GetRegistryLengthFromURL("http://stanford.edu", false));
+ EXPECT_EQ(3, GetRegistryLengthFromURL("http://ustreas.gov", false));
+ EXPECT_EQ(3, GetRegistryLengthFromURL("http://icann.net", false));
+ EXPECT_EQ(3, GetRegistryLengthFromURL("http://ferretcentral.org", false));
+ EXPECT_EQ(0, GetRegistryLengthFromURL("http://nowhere.foo", false));
+ EXPECT_EQ(3, GetRegistryLengthFromURL("http://nowhere.foo", true));
}
diff --git a/net/net.xcodeproj/project.pbxproj b/net/net.xcodeproj/project.pbxproj
index 384bf39..23d3c3c 100644
--- a/net/net.xcodeproj/project.pbxproj
+++ b/net/net.xcodeproj/project.pbxproj
@@ -63,11 +63,6 @@
7B85044A0E5B2E9600730B43 /* url_request_error_job.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BED33B20E5A198600A747DB /* url_request_error_job.cc */; };
7B8504530E5B2E9600730B43 /* url_request_job_metrics.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BED33A00E5A198600A747DB /* url_request_job_metrics.cc */; };
7B8504540E5B2E9600730B43 /* url_request_job_tracker.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BED339E0E5A198600A747DB /* url_request_job_tracker.cc */; };
- 7B8B5A430E5CD1FD002F9A97 /* cookie_monster.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BED32690E5A181C00A747DB /* cookie_monster.cc */; };
- 7B8B5AE30E5CDC00002F9A97 /* net_util.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BED32A10E5A181C00A747DB /* net_util.cc */; };
- 7B8B5B530E5CEAC7002F9A97 /* cookie_monster_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BED32660E5A181C00A747DB /* cookie_monster_unittest.cc */; };
- 7B8B5B560E5CEADE002F9A97 /* registry_controlled_domain.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BED329B0E5A181C00A747DB /* registry_controlled_domain.cc */; };
- 7B8B5B9E0E5D188E002F9A97 /* registry_controlled_domain_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BED32990E5A181C00A747DB /* registry_controlled_domain_unittest.cc */; };
7BA0151F0E5A1B9200044150 /* gzip_filter_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BED32B80E5A181C00A747DB /* gzip_filter_unittest.cc */; };
7BA015210E5A1B9800044150 /* bzip2_filter_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BED32730E5A181C00A747DB /* bzip2_filter_unittest.cc */; };
7BA0152E0E5A1BF400044150 /* auth_cache.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BED327C0E5A181C00A747DB /* auth_cache.cc */; };
@@ -1181,7 +1176,6 @@
821F207B0E5CD342003C7E38 /* cert_status_cache.cc in Sources */,
7B8504080E5B2DD800730B43 /* client_socket_handle.cc in Sources */,
7B8504090E5B2DD800730B43 /* client_socket_pool.cc in Sources */,
- 7B8B5A430E5CD1FD002F9A97 /* cookie_monster.cc in Sources */,
7B85040C0E5B2DD800730B43 /* cookie_policy.cc in Sources */,
7B85040D0E5B2DD800730B43 /* data_url.cc in Sources */,
7B8504100E5B2DF000730B43 /* entry_impl.cc in Sources */,
@@ -1207,11 +1201,9 @@
048268070E5B3B1000A30786 /* mime_util.cc in Sources */,
7BA015550E5A1C1000044150 /* net_errors.cc in Sources */,
7B8504390E5B2E5700730B43 /* net_module.cc in Sources */,
- 7B8B5AE30E5CDC00002F9A97 /* net_util.cc in Sources */,
7B85043B0E5B2E6400730B43 /* os_file_posix.cc in Sources */,
7B85043C0E5B2E6400730B43 /* platform_mime_util_mac.mm in Sources */,
7B85043D0E5B2E6400730B43 /* rankings.cc in Sources */,
- 7B8B5B560E5CEADE002F9A97 /* registry_controlled_domain.cc in Sources */,
7B8504410E5B2E9600730B43 /* stats.cc in Sources */,
7B8504450E5B2E9600730B43 /* trace.cc in Sources */,
7B85044A0E5B2E9600730B43 /* url_request_error_job.cc in Sources */,
@@ -1230,7 +1222,6 @@
7B8502120E5A37A800730B43 /* base64_unittest.cc in Sources */,
7BA015210E5A1B9800044150 /* bzip2_filter_unittest.cc in Sources */,
7B4DF64A0E5B98DF004D7619 /* client_socket_pool_unittest.cc in Sources */,
- 7B8B5B530E5CEAC7002F9A97 /* cookie_monster_unittest.cc in Sources */,
7B4DF6A90E5B98E7004D7619 /* data_url_unittest.cc in Sources */,
7B4DF6B10E5B98ED004D7619 /* escape_unittest.cc in Sources */,
7BA0151F0E5A1B9200044150 /* gzip_filter_unittest.cc in Sources */,
@@ -1239,7 +1230,6 @@
821F21130E5CD662003C7E38 /* http_vary_data_unittest.cc in Sources */,
7B4DF9AC0E5C906A004D7619 /* mime_sniffer_unittest.cc in Sources */,
048268090E5B3B4800A30786 /* mime_util_unittest.cc in Sources */,
- 7B8B5B9E0E5D188E002F9A97 /* registry_controlled_domain_unittest.cc in Sources */,
E4AFA6430E5241B400201347 /* run_all_unittests.cc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;