| OLD | NEW |
| 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 #include "net/cookies/cookie_store_unittest.h" | 5 #include "net/cookies/cookie_store_unittest.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 2147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2158 ASSERT_TRUE(cookie_list[0].IsExpired(Time::Now())); | 2158 ASSERT_TRUE(cookie_list[0].IsExpired(Time::Now())); |
| 2159 } | 2159 } |
| 2160 | 2160 |
| 2161 namespace { | 2161 namespace { |
| 2162 | 2162 |
| 2163 // Mock PersistentCookieStore that keeps track of the number of Flush() calls. | 2163 // Mock PersistentCookieStore that keeps track of the number of Flush() calls. |
| 2164 class FlushablePersistentStore : public CookieMonster::PersistentCookieStore { | 2164 class FlushablePersistentStore : public CookieMonster::PersistentCookieStore { |
| 2165 public: | 2165 public: |
| 2166 FlushablePersistentStore() : flush_count_(0) {} | 2166 FlushablePersistentStore() : flush_count_(0) {} |
| 2167 | 2167 |
| 2168 virtual void Load(const LoadedCallback& loaded_callback) OVERRIDE { | 2168 virtual void Load(const LoadedCallback& loaded_callback) override { |
| 2169 std::vector<CanonicalCookie*> out_cookies; | 2169 std::vector<CanonicalCookie*> out_cookies; |
| 2170 base::MessageLoop::current()->PostTask( | 2170 base::MessageLoop::current()->PostTask( |
| 2171 FROM_HERE, | 2171 FROM_HERE, |
| 2172 base::Bind(&net::LoadedCallbackTask::Run, | 2172 base::Bind(&net::LoadedCallbackTask::Run, |
| 2173 new net::LoadedCallbackTask(loaded_callback, out_cookies))); | 2173 new net::LoadedCallbackTask(loaded_callback, out_cookies))); |
| 2174 } | 2174 } |
| 2175 | 2175 |
| 2176 virtual void LoadCookiesForKey( | 2176 virtual void LoadCookiesForKey( |
| 2177 const std::string& key, | 2177 const std::string& key, |
| 2178 const LoadedCallback& loaded_callback) OVERRIDE { | 2178 const LoadedCallback& loaded_callback) override { |
| 2179 Load(loaded_callback); | 2179 Load(loaded_callback); |
| 2180 } | 2180 } |
| 2181 | 2181 |
| 2182 virtual void AddCookie(const CanonicalCookie&) OVERRIDE {} | 2182 virtual void AddCookie(const CanonicalCookie&) override {} |
| 2183 virtual void UpdateCookieAccessTime(const CanonicalCookie&) OVERRIDE {} | 2183 virtual void UpdateCookieAccessTime(const CanonicalCookie&) override {} |
| 2184 virtual void DeleteCookie(const CanonicalCookie&) OVERRIDE {} | 2184 virtual void DeleteCookie(const CanonicalCookie&) override {} |
| 2185 virtual void SetForceKeepSessionState() OVERRIDE {} | 2185 virtual void SetForceKeepSessionState() override {} |
| 2186 | 2186 |
| 2187 virtual void Flush(const base::Closure& callback) OVERRIDE { | 2187 virtual void Flush(const base::Closure& callback) override { |
| 2188 ++flush_count_; | 2188 ++flush_count_; |
| 2189 if (!callback.is_null()) | 2189 if (!callback.is_null()) |
| 2190 callback.Run(); | 2190 callback.Run(); |
| 2191 } | 2191 } |
| 2192 | 2192 |
| 2193 int flush_count() { | 2193 int flush_count() { |
| 2194 return flush_count_; | 2194 return flush_count_; |
| 2195 } | 2195 } |
| 2196 | 2196 |
| 2197 private: | 2197 private: |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2732 | 2732 |
| 2733 // Inject our initial cookies into the mock PersistentCookieStore. | 2733 // Inject our initial cookies into the mock PersistentCookieStore. |
| 2734 store->SetLoadExpectation(true, initial_cookies); | 2734 store->SetLoadExpectation(true, initial_cookies); |
| 2735 | 2735 |
| 2736 scoped_refptr<CookieMonster> cm(new CookieMonster(store.get(), NULL)); | 2736 scoped_refptr<CookieMonster> cm(new CookieMonster(store.get(), NULL)); |
| 2737 | 2737 |
| 2738 EXPECT_EQ("foo=bar; hello=world", GetCookies(cm.get(), url)); | 2738 EXPECT_EQ("foo=bar; hello=world", GetCookies(cm.get(), url)); |
| 2739 } | 2739 } |
| 2740 | 2740 |
| 2741 } // namespace net | 2741 } // namespace net |
| OLD | NEW |