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

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
« no previous file with comments | « net/base/cookie_monster.h ('k') | net/base/mime_sniffer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2220 matching lines...) Expand 10 before | Expand all | Expand 10 after
2231 EXPECT_EQ("http://example.com/", 2231 EXPECT_EQ("http://example.com/",
2232 CookieMonster::CanonicalCookie::GetCookieSourceFromURL( 2232 CookieMonster::CanonicalCookie::GetCookieSourceFromURL(
2233 GURL("http://example.com/test#foo"))); 2233 GURL("http://example.com/test#foo")));
2234 } 2234 }
2235 2235
2236 TEST(CookieMonsterTest, HistogramCheck) { 2236 TEST(CookieMonsterTest, HistogramCheck) {
2237 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); 2237 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
2238 // Should match call in InitializeHistograms, but doesn't really matter 2238 // Should match call in InitializeHistograms, but doesn't really matter
2239 // since the histogram should have been initialized by the CM construction 2239 // since the histogram should have been initialized by the CM construction
2240 // above. 2240 // above.
2241 scoped_refptr<base::Histogram> expired_histogram = 2241 base::Histogram* expired_histogram =
2242 base::Histogram::FactoryGet( 2242 base::Histogram::FactoryGet(
2243 "Cookie.ExpirationDurationMinutes", 1, 10 * 365 * 24 * 60, 50, 2243 "Cookie.ExpirationDurationMinutes", 1, 10 * 365 * 24 * 60, 50,
2244 base::Histogram::kUmaTargetedHistogramFlag); 2244 base::Histogram::kUmaTargetedHistogramFlag);
2245 2245
2246 base::Histogram::SampleSet histogram_set_1; 2246 base::Histogram::SampleSet histogram_set_1;
2247 expired_histogram->SnapshotSample(&histogram_set_1); 2247 expired_histogram->SnapshotSample(&histogram_set_1);
2248 ASSERT_TRUE(cm->SetCookieWithDetails( 2248 ASSERT_TRUE(cm->SetCookieWithDetails(
2249 GURL("http://fake.a.url"), "a", "b", "a.url", "/", 2249 GURL("http://fake.a.url"), "a", "b", "a.url", "/",
2250 base::Time::Now() + base::TimeDelta::FromMinutes(59), 2250 base::Time::Now() + base::TimeDelta::FromMinutes(59),
2251 false, false)); 2251 false, false));
2252 2252
2253 base::Histogram::SampleSet histogram_set_2; 2253 base::Histogram::SampleSet histogram_set_2;
2254 expired_histogram->SnapshotSample(&histogram_set_2); 2254 expired_histogram->SnapshotSample(&histogram_set_2);
2255 EXPECT_EQ(histogram_set_1.TotalCount() + 1, 2255 EXPECT_EQ(histogram_set_1.TotalCount() + 1,
2256 histogram_set_2.TotalCount()); 2256 histogram_set_2.TotalCount());
2257 2257
2258 // kValidCookieLine creates a session cookie. 2258 // kValidCookieLine creates a session cookie.
2259 GURL url_google(kUrlGoogle); 2259 GURL url_google(kUrlGoogle);
2260 ASSERT_TRUE(cm->SetCookie(url_google, kValidCookieLine)); 2260 ASSERT_TRUE(cm->SetCookie(url_google, kValidCookieLine));
2261 expired_histogram->SnapshotSample(&histogram_set_1); 2261 expired_histogram->SnapshotSample(&histogram_set_1);
2262 EXPECT_EQ(histogram_set_2.TotalCount(), 2262 EXPECT_EQ(histogram_set_2.TotalCount(),
2263 histogram_set_1.TotalCount()); 2263 histogram_set_1.TotalCount());
2264 } 2264 }
2265 2265
2266 } // namespace 2266 } // namespace
OLDNEW
« no previous file with comments | « net/base/cookie_monster.h ('k') | net/base/mime_sniffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698