summaryrefslogtreecommitdiffstats
path: root/net/base/cookie_monster_perftest.cc
diff options
context:
space:
mode:
authorrdsmith@google.com <rdsmith@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-28 16:41:04 +0000
committerrdsmith@google.com <rdsmith@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-28 16:41:04 +0000
commitb866a02d3444bcc56199533fa264827ed73601cd (patch)
tree566b90b57d410207d4701b6d02165b2e3132c54d /net/base/cookie_monster_perftest.cc
parent1bcb12b22d6ba77966c4c5b65e9db55ed1916344 (diff)
downloadchromium_src-b866a02d3444bcc56199533fa264827ed73601cd.zip
chromium_src-b866a02d3444bcc56199533fa264827ed73601cd.tar.gz
chromium_src-b866a02d3444bcc56199533fa264827ed73601cd.tar.bz2
Fixes targeting the unique creation times invariant in the CookieMonster:
* Make sure we don't import cookies with identical creation times. * DCHECK that duplicate cookie list insertion succeeds (it silently didn't when there were not unique creation times.) * Confirm that we eliminate all the duplicats we find on cookie import. * Make Methods allowing setting of creation time private. * Create performance test for import (involved refactoring backing store mock.) This change does increase the performance cost on import, and hence adds to startup time. However, the increase for importing 15000 cookies was only 5 ms, so I think that's acceptable to prevent crashes. rdsmith-macbookpro:~/tmp $ perfparse base_perf_import.txt new_perf_import.txt base_perf_import.txt new_perf_import.txt CookieMonsterTest.TestImport Cookie_monster_import_from_store 26.36 +/- 0.88 31.38 +/- 1.1 BUG=43188 TEST=net_unittest --gtest_filter=CookieMonsterTest.* (including two new tests.), Linux & Windows Review URL: http://codereview.chromium.org/3070001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53957 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/cookie_monster_perftest.cc')
-rw-r--r--net/base/cookie_monster_perftest.cc40
1 files changed, 37 insertions, 3 deletions
diff --git a/net/base/cookie_monster_perftest.cc b/net/base/cookie_monster_perftest.cc
index 3d1e7a7..042f971 100644
--- a/net/base/cookie_monster_perftest.cc
+++ b/net/base/cookie_monster_perftest.cc
@@ -1,12 +1,13 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "net/base/cookie_monster.h"
#include "base/perftimer.h"
#include "base/string_util.h"
-#include "net/base/cookie_monster.h"
-#include "testing/gtest/include/gtest/gtest.h"
#include "googleurl/src/gurl.h"
+#include "net/base/cookie_monster_store_test.h"
+#include "testing/gtest/include/gtest/gtest.h"
namespace {
class ParsedCookieTest : public testing::Test { };
@@ -161,3 +162,36 @@ TEST(CookieMonsterTest, TestDomainTree) {
}
timer2.Done();
}
+
+TEST(CookieMonsterTest, TestImport) {
+ scoped_refptr<MockPersistentCookieStore> store(new MockPersistentCookieStore);
+ std::vector<net::CookieMonster::KeyedCanonicalCookie> initial_cookies;
+
+ // We want to setup a fairly large backing store, with 300 domains of 50
+ // cookies each. Creation times must be unique.
+ int64 time_tick(base::Time::Now().ToInternalValue());
+
+ for (int domain_num = 0; domain_num < 300; domain_num++) {
+ std::string domain_name(StringPrintf(".Domain_%d.com", domain_num));
+ std::string gurl("www" + domain_name);
+ for (int cookie_num = 0; cookie_num < 50; cookie_num++) {
+ std::string cookie_line(StringPrintf("Cookie_%d=1; Path=/", cookie_num));
+ AddKeyedCookieToList(gurl, cookie_line,
+ base::Time::FromInternalValue(time_tick++),
+ &initial_cookies);
+ }
+ }
+
+ store->SetLoadExpectation(true, initial_cookies);
+
+ scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(store, NULL));
+
+ // Import will happen on first access.
+ GURL gurl("www.google.com");
+ net::CookieOptions options;
+ PerfTimeLogger timer("Cookie_monster_import_from_store");
+ cm->GetCookiesWithOptions(gurl, options);
+ timer.Done();
+}
+
+