| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef NET_COOKIES_COOKIE_STORE_TEST_HELPERS_H_ | |
| 6 #define NET_COOKIES_COOKIE_STORE_TEST_HELPERS_H_ | |
| 7 | |
| 8 #include "net/cookies/cookie_monster.h" | |
| 9 | |
| 10 #include <string> | |
| 11 #include <vector> | |
| 12 | |
| 13 #include "base/callback_forward.h" | |
| 14 #include "testing/gtest/include/gtest/gtest.h" | |
| 15 | |
| 16 namespace net { | |
| 17 | |
| 18 class DelayedCookieMonster : public CookieStore { | |
| 19 public: | |
| 20 DelayedCookieMonster(); | |
| 21 | |
| 22 // Call the asynchronous CookieMonster function, expect it to immediately | |
| 23 // invoke the internal callback. | |
| 24 // Post a delayed task to invoke the original callback with the results. | |
| 25 | |
| 26 void SetCookieWithOptionsAsync( | |
| 27 const GURL& url, | |
| 28 const std::string& cookie_line, | |
| 29 const CookieOptions& options, | |
| 30 const CookieMonster::SetCookiesCallback& callback) override; | |
| 31 | |
| 32 void GetCookiesWithOptionsAsync( | |
| 33 const GURL& url, | |
| 34 const CookieOptions& options, | |
| 35 const CookieMonster::GetCookiesCallback& callback) override; | |
| 36 | |
| 37 void GetAllCookiesForURLAsync(const GURL& url, | |
| 38 const GetCookieListCallback& callback) override; | |
| 39 | |
| 40 virtual bool SetCookieWithOptions(const GURL& url, | |
| 41 const std::string& cookie_line, | |
| 42 const CookieOptions& options); | |
| 43 | |
| 44 virtual std::string GetCookiesWithOptions(const GURL& url, | |
| 45 const CookieOptions& options); | |
| 46 | |
| 47 virtual void DeleteCookie(const GURL& url, | |
| 48 const std::string& cookie_name); | |
| 49 | |
| 50 void DeleteCookieAsync(const GURL& url, | |
| 51 const std::string& cookie_name, | |
| 52 const base::Closure& callback) override; | |
| 53 | |
| 54 void DeleteAllCreatedBetweenAsync(const base::Time& delete_begin, | |
| 55 const base::Time& delete_end, | |
| 56 const DeleteCallback& callback) override; | |
| 57 | |
| 58 void DeleteAllCreatedBetweenForHostAsync( | |
| 59 const base::Time delete_begin, | |
| 60 const base::Time delete_end, | |
| 61 const GURL& url, | |
| 62 const DeleteCallback& callback) override; | |
| 63 | |
| 64 void DeleteSessionCookiesAsync(const DeleteCallback&) override; | |
| 65 | |
| 66 CookieMonster* GetCookieMonster() override; | |
| 67 | |
| 68 scoped_ptr<CookieStore::CookieChangedSubscription> | |
| 69 AddCallbackForCookie(const GURL& url, const std::string& name, | |
| 70 const CookieChangedCallback& callback) override; | |
| 71 | |
| 72 private: | |
| 73 | |
| 74 // Be called immediately from CookieMonster. | |
| 75 | |
| 76 void SetCookiesInternalCallback(bool result); | |
| 77 | |
| 78 void GetCookiesWithOptionsInternalCallback(const std::string& cookie); | |
| 79 | |
| 80 // Invoke the original callbacks. | |
| 81 | |
| 82 void InvokeSetCookiesCallback( | |
| 83 const CookieMonster::SetCookiesCallback& callback); | |
| 84 | |
| 85 void InvokeGetCookieStringCallback( | |
| 86 const CookieMonster::GetCookiesCallback& callback); | |
| 87 | |
| 88 friend class base::RefCountedThreadSafe<DelayedCookieMonster>; | |
| 89 ~DelayedCookieMonster() override; | |
| 90 | |
| 91 scoped_refptr<CookieMonster> cookie_monster_; | |
| 92 | |
| 93 bool did_run_; | |
| 94 bool result_; | |
| 95 std::string cookie_; | |
| 96 std::string cookie_line_; | |
| 97 }; | |
| 98 | |
| 99 } // namespace net | |
| 100 | |
| 101 #endif // NET_COOKIES_COOKIE_STORE_TEST_HELPERS_H_ | |
| OLD | NEW |