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 #ifndef NET_COOKIES_COOKIE_STORE_TEST_HELPERS_H_ | 5 #ifndef NET_COOKIES_COOKIE_STORE_TEST_HELPERS_H_ |
6 #define NET_COOKIES_COOKIE_STORE_TEST_HELPERS_H_ | 6 #define NET_COOKIES_COOKIE_STORE_TEST_HELPERS_H_ |
7 | 7 |
8 #include "net/cookies/cookie_monster.h" | 8 #include "net/cookies/cookie_monster.h" |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 11 matching lines...) Expand all Loading... |
22 ~DelayedCookieMonster() override; | 22 ~DelayedCookieMonster() override; |
23 | 23 |
24 // Call the asynchronous CookieMonster function, expect it to immediately | 24 // Call the asynchronous CookieMonster function, expect it to immediately |
25 // invoke the internal callback. | 25 // invoke the internal callback. |
26 // Post a delayed task to invoke the original callback with the results. | 26 // Post a delayed task to invoke the original callback with the results. |
27 | 27 |
28 void SetCookieWithOptionsAsync( | 28 void SetCookieWithOptionsAsync( |
29 const GURL& url, | 29 const GURL& url, |
30 const std::string& cookie_line, | 30 const std::string& cookie_line, |
31 const CookieOptions& options, | 31 const CookieOptions& options, |
32 const CookieMonster::SetCookiesCallback& callback) override; | 32 CookieMonster::SetCookiesCallback callback) override; |
33 | 33 |
34 void SetCookieWithDetailsAsync(const GURL& url, | 34 void SetCookieWithDetailsAsync(const GURL& url, |
35 const std::string& name, | 35 const std::string& name, |
36 const std::string& value, | 36 const std::string& value, |
37 const std::string& domain, | 37 const std::string& domain, |
38 const std::string& path, | 38 const std::string& path, |
39 base::Time creation_time, | 39 base::Time creation_time, |
40 base::Time expiration_time, | 40 base::Time expiration_time, |
41 base::Time last_access_time, | 41 base::Time last_access_time, |
42 bool secure, | 42 bool secure, |
43 bool http_only, | 43 bool http_only, |
44 CookieSameSite same_site, | 44 CookieSameSite same_site, |
45 CookiePriority priority, | 45 CookiePriority priority, |
46 const SetCookiesCallback& callback) override; | 46 SetCookiesCallback callback) override; |
47 | 47 |
48 void SetCanonicalCookieAsync(std::unique_ptr<CanonicalCookie> cookie, | 48 void SetCanonicalCookieAsync(std::unique_ptr<CanonicalCookie> cookie, |
49 bool secure_source, | 49 bool secure_source, |
50 bool modify_http_only, | 50 bool modify_http_only, |
51 const SetCookiesCallback& callback) override; | 51 SetCookiesCallback callback) override; |
52 | 52 |
53 void GetCookiesWithOptionsAsync( | 53 void GetCookiesWithOptionsAsync( |
54 const GURL& url, | 54 const GURL& url, |
55 const CookieOptions& options, | 55 const CookieOptions& options, |
56 const CookieMonster::GetCookiesCallback& callback) override; | 56 CookieMonster::GetCookiesCallback callback) override; |
57 | 57 |
58 void GetCookieListWithOptionsAsync( | 58 void GetCookieListWithOptionsAsync(const GURL& url, |
59 const GURL& url, | 59 const CookieOptions& options, |
60 const CookieOptions& options, | 60 GetCookieListCallback callback) override; |
61 const GetCookieListCallback& callback) override; | |
62 | 61 |
63 void GetAllCookiesAsync(const GetCookieListCallback& callback) override; | 62 void GetAllCookiesAsync(GetCookieListCallback callback) override; |
64 | 63 |
65 virtual bool SetCookieWithOptions(const GURL& url, | 64 virtual bool SetCookieWithOptions(const GURL& url, |
66 const std::string& cookie_line, | 65 const std::string& cookie_line, |
67 const CookieOptions& options); | 66 const CookieOptions& options); |
68 | 67 |
69 virtual std::string GetCookiesWithOptions(const GURL& url, | 68 virtual std::string GetCookiesWithOptions(const GURL& url, |
70 const CookieOptions& options); | 69 const CookieOptions& options); |
71 | 70 |
72 virtual void DeleteCookie(const GURL& url, | 71 virtual void DeleteCookie(const GURL& url, |
73 const std::string& cookie_name); | 72 const std::string& cookie_name); |
74 | 73 |
75 void DeleteCookieAsync(const GURL& url, | 74 void DeleteCookieAsync(const GURL& url, |
76 const std::string& cookie_name, | 75 const std::string& cookie_name, |
77 const base::Closure& callback) override; | 76 base::OnceClosure callback) override; |
78 | 77 |
79 void DeleteCanonicalCookieAsync(const CanonicalCookie& cookie, | 78 void DeleteCanonicalCookieAsync(const CanonicalCookie& cookie, |
80 const DeleteCallback& callback) override; | 79 DeleteCallback callback) override; |
81 | 80 |
82 void DeleteAllCreatedBetweenAsync(const base::Time& delete_begin, | 81 void DeleteAllCreatedBetweenAsync(const base::Time& delete_begin, |
83 const base::Time& delete_end, | 82 const base::Time& delete_end, |
84 const DeleteCallback& callback) override; | 83 DeleteCallback callback) override; |
85 | 84 |
86 void DeleteAllCreatedBetweenWithPredicateAsync( | 85 void DeleteAllCreatedBetweenWithPredicateAsync( |
87 const base::Time& delete_begin, | 86 const base::Time& delete_begin, |
88 const base::Time& delete_end, | 87 const base::Time& delete_end, |
89 const base::Callback<bool(const CanonicalCookie&)>& predicate, | 88 const base::Callback<bool(const CanonicalCookie&)>& predicate, |
90 const DeleteCallback& callback) override; | 89 DeleteCallback callback) override; |
91 | 90 |
92 void DeleteSessionCookiesAsync(const DeleteCallback&) override; | 91 void DeleteSessionCookiesAsync(DeleteCallback) override; |
93 | 92 |
94 void FlushStore(const base::Closure& callback) override; | 93 void FlushStore(base::OnceClosure callback) override; |
95 | 94 |
96 std::unique_ptr<CookieStore::CookieChangedSubscription> AddCallbackForCookie( | 95 std::unique_ptr<CookieStore::CookieChangedSubscription> AddCallbackForCookie( |
97 const GURL& url, | 96 const GURL& url, |
98 const std::string& name, | 97 const std::string& name, |
99 const CookieChangedCallback& callback) override; | 98 const CookieChangedCallback& callback) override; |
100 | 99 |
101 bool IsEphemeral() override; | 100 bool IsEphemeral() override; |
102 | 101 |
103 private: | 102 private: |
104 // Be called immediately from CookieMonster. | 103 // Be called immediately from CookieMonster. |
105 | 104 |
106 void SetCookiesInternalCallback(bool result); | 105 void SetCookiesInternalCallback(bool result); |
107 | 106 |
108 void GetCookiesWithOptionsInternalCallback(const std::string& cookie); | 107 void GetCookiesWithOptionsInternalCallback(const std::string& cookie); |
109 void GetCookieListWithOptionsInternalCallback(const CookieList& cookie); | 108 void GetCookieListWithOptionsInternalCallback(const CookieList& cookie); |
110 | 109 |
111 // Invoke the original callbacks. | 110 // Invoke the original callbacks. |
112 | 111 |
113 void InvokeSetCookiesCallback( | 112 void InvokeSetCookiesCallback(CookieMonster::SetCookiesCallback callback); |
114 const CookieMonster::SetCookiesCallback& callback); | |
115 | 113 |
116 void InvokeGetCookieStringCallback( | 114 void InvokeGetCookieStringCallback( |
117 const CookieMonster::GetCookiesCallback& callback); | 115 CookieMonster::GetCookiesCallback callback); |
118 | 116 |
119 void InvokeGetCookieListCallback( | 117 void InvokeGetCookieListCallback( |
120 const CookieMonster::GetCookieListCallback& callback); | 118 CookieMonster::GetCookieListCallback callback); |
121 | 119 |
122 friend class base::RefCountedThreadSafe<DelayedCookieMonster>; | 120 friend class base::RefCountedThreadSafe<DelayedCookieMonster>; |
123 | 121 |
124 std::unique_ptr<CookieMonster> cookie_monster_; | 122 std::unique_ptr<CookieMonster> cookie_monster_; |
125 | 123 |
126 bool did_run_; | 124 bool did_run_; |
127 bool result_; | 125 bool result_; |
128 std::string cookie_; | 126 std::string cookie_; |
129 std::string cookie_line_; | 127 std::string cookie_line_; |
130 CookieList cookie_list_; | 128 CookieList cookie_list_; |
(...skipping 15 matching lines...) Expand all Loading... |
146 | 144 |
147 private: | 145 private: |
148 const GURL url_; | 146 const GURL url_; |
149 const std::string registry_; | 147 const std::string registry_; |
150 const std::string domain_and_registry_; | 148 const std::string domain_and_registry_; |
151 }; | 149 }; |
152 | 150 |
153 } // namespace net | 151 } // namespace net |
154 | 152 |
155 #endif // NET_COOKIES_COOKIE_STORE_TEST_HELPERS_H_ | 153 #endif // NET_COOKIES_COOKIE_STORE_TEST_HELPERS_H_ |
OLD | NEW |