OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 mock_time_ = mock_time_base_; | 120 mock_time_ = mock_time_base_; |
121 } | 121 } |
122 | 122 |
123 void EvictedDomainCookieCounterTest::TearDown() { | 123 void EvictedDomainCookieCounterTest::TearDown() { |
124 } | 124 } |
125 | 125 |
126 void EvictedDomainCookieCounterTest::InitCounter(size_t max_size, | 126 void EvictedDomainCookieCounterTest::InitCounter(size_t max_size, |
127 size_t purge_count) { | 127 size_t purge_count) { |
128 scoped_ptr<MockDelegate> cookie_counter_delegate(new MockDelegate(this)); | 128 scoped_ptr<MockDelegate> cookie_counter_delegate(new MockDelegate(this)); |
129 cookie_counter_ = new EvictedDomainCookieCounter( | 129 cookie_counter_ = new EvictedDomainCookieCounter( |
130 NULL, | 130 NULL, cookie_counter_delegate.Pass(), max_size, purge_count); |
131 cookie_counter_delegate.PassAs<EvictedDomainCookieCounter::Delegate>(), | |
132 max_size, | |
133 purge_count); | |
134 } | 131 } |
135 | 132 |
136 void EvictedDomainCookieCounterTest::CreateNewCookie( | 133 void EvictedDomainCookieCounterTest::CreateNewCookie( |
137 const char* url, const std::string& cookie_line, int64 max_age) { | 134 const char* url, const std::string& cookie_line, int64 max_age) { |
138 std::string line(cookie_line); | 135 std::string line(cookie_line); |
139 if (max_age) | 136 if (max_age) |
140 line.append(";max-age=" + base::Int64ToString(max_age)); | 137 line.append(";max-age=" + base::Int64ToString(max_age)); |
141 net::CanonicalCookie* cookie = net::CanonicalCookie::Create( | 138 net::CanonicalCookie* cookie = net::CanonicalCookie::Create( |
142 GURL(url), line, mock_time_, net::CookieOptions()); | 139 GURL(url), line, mock_time_, net::CookieOptions()); |
143 DCHECK(cookie); | 140 DCHECK(cookie); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 virtual void OnLoaded() override {} | 193 virtual void OnLoaded() override {} |
197 | 194 |
198 private: | 195 private: |
199 virtual ~ChangedDelegateDummy() {} | 196 virtual ~ChangedDelegateDummy() {} |
200 | 197 |
201 int* result_; | 198 int* result_; |
202 }; | 199 }; |
203 | 200 |
204 scoped_ptr<MockDelegate> cookie_counter_delegate(new MockDelegate(this)); | 201 scoped_ptr<MockDelegate> cookie_counter_delegate(new MockDelegate(this)); |
205 cookie_counter_ = new EvictedDomainCookieCounter( | 202 cookie_counter_ = new EvictedDomainCookieCounter( |
206 new ChangedDelegateDummy(&result), | 203 new ChangedDelegateDummy(&result), cookie_counter_delegate.Pass(), 10, 5); |
207 cookie_counter_delegate.PassAs<EvictedDomainCookieCounter::Delegate>(), | |
208 10, | |
209 5); | |
210 InitStockCookies(); | 204 InitStockCookies(); |
211 // Perform 6 cookie transactions. | 205 // Perform 6 cookie transactions. |
212 for (int i = 0; i < 6; ++i) { | 206 for (int i = 0; i < 6; ++i) { |
213 Add(cookies_[i]); | 207 Add(cookies_[i]); |
214 StepTime(1); | 208 StepTime(1); |
215 Evict(cookies_[i]); | 209 Evict(cookies_[i]); |
216 StepTime(1); | 210 StepTime(1); |
217 Remove(cookies_[i]); | 211 Remove(cookies_[i]); |
218 } | 212 } |
219 EXPECT_EQ(18, result); // 6 cookies x 3 operations each. | 213 EXPECT_EQ(18, result); // 6 cookies x 3 operations each. |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 for (int i = 0; i < 6; ++i) | 376 for (int i = 0; i < 6; ++i) |
383 Add(cookies_[i]); | 377 Add(cookies_[i]); |
384 EXPECT_EQ(0u, cookie_counter_->GetStorageSize()); | 378 EXPECT_EQ(0u, cookie_counter_->GetStorageSize()); |
385 // Reinstatement delays: [1499,1497,(1494),(1490),(1485),300]. | 379 // Reinstatement delays: [1499,1497,(1494),(1490),(1485),300]. |
386 EXPECT_EQ("1499,1497;300", google_stat_ + ";" + other_stat_); | 380 EXPECT_EQ("1499,1497;300", google_stat_ + ";" + other_stat_); |
387 } | 381 } |
388 | 382 |
389 } // namespace | 383 } // namespace |
390 | 384 |
391 } // namespace chrome_browser_net | 385 } // namespace chrome_browser_net |
OLD | NEW |