Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: net/base/cookie_monster_unittest.cc

Issue 6780035: Use lock-free lazy initialization for static histogram references (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <time.h> 5 #include <time.h>
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 2230 matching lines...) Expand 10 before | Expand all | Expand 10 after
2241 EXPECT_EQ("http://example.com/", 2241 EXPECT_EQ("http://example.com/",
2242 CookieMonster::CanonicalCookie::GetCookieSourceFromURL( 2242 CookieMonster::CanonicalCookie::GetCookieSourceFromURL(
2243 GURL("http://example.com/test#foo"))); 2243 GURL("http://example.com/test#foo")));
2244 } 2244 }
2245 2245
2246 TEST(CookieMonsterTest, HistogramCheck) { 2246 TEST(CookieMonsterTest, HistogramCheck) {
2247 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); 2247 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
2248 // Should match call in InitializeHistograms, but doesn't really matter 2248 // Should match call in InitializeHistograms, but doesn't really matter
2249 // since the histogram should have been initialized by the CM construction 2249 // since the histogram should have been initialized by the CM construction
2250 // above. 2250 // above.
2251 scoped_refptr<base::Histogram> expired_histogram = 2251 base::Histogram* expired_histogram =
2252 base::Histogram::FactoryGet( 2252 base::Histogram::FactoryGet(
2253 "Cookie.ExpirationDurationMinutes", 1, 10 * 365 * 24 * 60, 50, 2253 "Cookie.ExpirationDurationMinutes", 1, 10 * 365 * 24 * 60, 50,
2254 base::Histogram::kUmaTargetedHistogramFlag); 2254 base::Histogram::kUmaTargetedHistogramFlag);
2255 2255
2256 base::Histogram::SampleSet histogram_set_1; 2256 base::Histogram::SampleSet histogram_set_1;
2257 expired_histogram->SnapshotSample(&histogram_set_1); 2257 expired_histogram->SnapshotSample(&histogram_set_1);
2258 ASSERT_TRUE(cm->SetCookieWithDetails( 2258 ASSERT_TRUE(cm->SetCookieWithDetails(
2259 GURL("http://fake.a.url"), "a", "b", "a.url", "/", 2259 GURL("http://fake.a.url"), "a", "b", "a.url", "/",
2260 base::Time::Now() + base::TimeDelta::FromMinutes(59), 2260 base::Time::Now() + base::TimeDelta::FromMinutes(59),
2261 false, false)); 2261 false, false));
2262 2262
2263 base::Histogram::SampleSet histogram_set_2; 2263 base::Histogram::SampleSet histogram_set_2;
2264 expired_histogram->SnapshotSample(&histogram_set_2); 2264 expired_histogram->SnapshotSample(&histogram_set_2);
2265 EXPECT_EQ(histogram_set_1.TotalCount() + 1, 2265 EXPECT_EQ(histogram_set_1.TotalCount() + 1,
2266 histogram_set_2.TotalCount()); 2266 histogram_set_2.TotalCount());
2267 2267
2268 // kValidCookieLine creates a session cookie. 2268 // kValidCookieLine creates a session cookie.
2269 GURL url_google(kUrlGoogle); 2269 GURL url_google(kUrlGoogle);
2270 ASSERT_TRUE(cm->SetCookie(url_google, kValidCookieLine)); 2270 ASSERT_TRUE(cm->SetCookie(url_google, kValidCookieLine));
2271 expired_histogram->SnapshotSample(&histogram_set_1); 2271 expired_histogram->SnapshotSample(&histogram_set_1);
2272 EXPECT_EQ(histogram_set_2.TotalCount(), 2272 EXPECT_EQ(histogram_set_2.TotalCount(),
2273 histogram_set_1.TotalCount()); 2273 histogram_set_1.TotalCount());
2274 } 2274 }
2275 2275
2276 } // namespace 2276 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698