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

Side by Side Diff: net/base/cookie_store_unittest.h

Issue 9572036: Convert uses of int ms to TimeDelta in chrome/browser and net. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add more TimeDelta integration. Created 8 years, 9 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
« no previous file with comments | « chrome/browser/ssl/ssl_browser_tests.cc ('k') | net/base/host_resolver_impl.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef NET_BASE_COOKIE_STORE_UNITTEST_H_ 5 #ifndef NET_BASE_COOKIE_STORE_UNITTEST_H_
6 #define NET_BASE_COOKIE_STORE_UNITTEST_H_ 6 #define NET_BASE_COOKIE_STORE_UNITTEST_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 void MatchCookieLineWithTimeout(CookieStore* cs, 204 void MatchCookieLineWithTimeout(CookieStore* cs,
205 const GURL& url, 205 const GURL& url,
206 const std::string& line) { 206 const std::string& line) {
207 std::string cookies = GetCookies(cs, url); 207 std::string cookies = GetCookies(cs, url);
208 bool matched = (TokenizeCookieLine(line) == TokenizeCookieLine(cookies)); 208 bool matched = (TokenizeCookieLine(line) == TokenizeCookieLine(cookies));
209 base::Time polling_end_date = base::Time::Now() + 209 base::Time polling_end_date = base::Time::Now() +
210 base::TimeDelta::FromMilliseconds( 210 base::TimeDelta::FromMilliseconds(
211 CookieStoreTestTraits::creation_time_granularity_in_ms); 211 CookieStoreTestTraits::creation_time_granularity_in_ms);
212 212
213 while (!matched && base::Time::Now() <= polling_end_date) { 213 while (!matched && base::Time::Now() <= polling_end_date) {
214 base::PlatformThread::Sleep(10); 214 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10));
215 cookies = GetCookies(cs, url); 215 cookies = GetCookies(cs, url);
216 matched = (TokenizeCookieLine(line) == TokenizeCookieLine(cookies)); 216 matched = (TokenizeCookieLine(line) == TokenizeCookieLine(cookies));
217 } 217 }
218 218
219 EXPECT_TRUE(matched) << "\"" << cookies 219 EXPECT_TRUE(matched) << "\"" << cookies
220 << "\" does not match \"" << line << "\""; 220 << "\" does not match \"" << line << "\"";
221 } 221 }
222 222
223 GURL url_google_; 223 GURL url_google_;
224 GURL url_google_secure_; 224 GURL url_google_secure_;
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 842
843 TYPED_TEST_P(CookieStoreTest, CookieOrdering) { 843 TYPED_TEST_P(CookieStoreTest, CookieOrdering) {
844 // Put a random set of cookies into a store and make sure they're returned in 844 // Put a random set of cookies into a store and make sure they're returned in
845 // the right order. 845 // the right order.
846 // Cookies should be sorted by path length and creation time, as per RFC6265. 846 // Cookies should be sorted by path length and creation time, as per RFC6265.
847 scoped_refptr<CookieStore> cs(this->GetCookieStore()); 847 scoped_refptr<CookieStore> cs(this->GetCookieStore());
848 EXPECT_TRUE(this->SetCookie(cs, GURL("http://d.c.b.a.google.com/aa/x.html"), 848 EXPECT_TRUE(this->SetCookie(cs, GURL("http://d.c.b.a.google.com/aa/x.html"),
849 "c=1")); 849 "c=1"));
850 EXPECT_TRUE(this->SetCookie(cs, GURL("http://b.a.google.com/aa/bb/cc/x.html"), 850 EXPECT_TRUE(this->SetCookie(cs, GURL("http://b.a.google.com/aa/bb/cc/x.html"),
851 "d=1; domain=b.a.google.com")); 851 "d=1; domain=b.a.google.com"));
852 base::PlatformThread::Sleep(TypeParam::creation_time_granularity_in_ms); 852 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(
853 TypeParam::creation_time_granularity_in_ms));
853 EXPECT_TRUE(this->SetCookie(cs, GURL("http://b.a.google.com/aa/bb/cc/x.html"), 854 EXPECT_TRUE(this->SetCookie(cs, GURL("http://b.a.google.com/aa/bb/cc/x.html"),
854 "a=4; domain=b.a.google.com")); 855 "a=4; domain=b.a.google.com"));
855 base::PlatformThread::Sleep(TypeParam::creation_time_granularity_in_ms); 856 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(
857 TypeParam::creation_time_granularity_in_ms));
856 EXPECT_TRUE(this->SetCookie(cs, 858 EXPECT_TRUE(this->SetCookie(cs,
857 GURL("http://c.b.a.google.com/aa/bb/cc/x.html"), 859 GURL("http://c.b.a.google.com/aa/bb/cc/x.html"),
858 "e=1; domain=c.b.a.google.com")); 860 "e=1; domain=c.b.a.google.com"));
859 EXPECT_TRUE(this->SetCookie(cs, 861 EXPECT_TRUE(this->SetCookie(cs,
860 GURL("http://d.c.b.a.google.com/aa/bb/x.html"), 862 GURL("http://d.c.b.a.google.com/aa/bb/x.html"),
861 "b=1")); 863 "b=1"));
862 EXPECT_TRUE(this->SetCookie(cs, GURL("http://news.bbc.co.uk/midpath/x.html"), 864 EXPECT_TRUE(this->SetCookie(cs, GURL("http://news.bbc.co.uk/midpath/x.html"),
863 "g=10")); 865 "g=10"));
864 EXPECT_EQ("d=1; a=4; e=1; b=1; c=1", 866 EXPECT_EQ("d=1; a=4; e=1; b=1; c=1",
865 this->GetCookies(cs, GURL("http://d.c.b.a.google.com/aa/bb/cc/dd"))); 867 this->GetCookies(cs, GURL("http://d.c.b.a.google.com/aa/bb/cc/dd")));
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 } 1046 }
1045 1047
1046 REGISTER_TYPED_TEST_CASE_P(MultiThreadedCookieStoreTest, 1048 REGISTER_TYPED_TEST_CASE_P(MultiThreadedCookieStoreTest,
1047 ThreadCheckGetCookies, ThreadCheckGetCookiesWithOptions, 1049 ThreadCheckGetCookies, ThreadCheckGetCookiesWithOptions,
1048 ThreadCheckGetCookiesWithInfo, ThreadCheckSetCookieWithOptions, 1050 ThreadCheckGetCookiesWithInfo, ThreadCheckSetCookieWithOptions,
1049 ThreadCheckDeleteCookie); 1051 ThreadCheckDeleteCookie);
1050 1052
1051 } // namespace net 1053 } // namespace net
1052 1054
1053 #endif // NET_BASE_COOKIE_STORE_UNITTEST_H_ 1055 #endif // NET_BASE_COOKIE_STORE_UNITTEST_H_
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_browser_tests.cc ('k') | net/base/host_resolver_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698