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> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 namespace net { | 16 namespace net { |
17 | 17 |
18 class DelayedCookieMonster : public CookieStore { | 18 class DelayedCookieMonster : public CookieStore { |
19 public: | 19 public: |
20 DelayedCookieMonster(); | 20 DelayedCookieMonster(); |
21 | 21 |
22 // Call the asynchronous CookieMonster function, expect it to immediately | 22 // Call the asynchronous CookieMonster function, expect it to immediately |
23 // invoke the internal callback. | 23 // invoke the internal callback. |
24 // Post a delayed task to invoke the original callback with the results. | 24 // Post a delayed task to invoke the original callback with the results. |
25 | 25 |
26 virtual void SetCookieWithOptionsAsync( | 26 virtual void SetCookieWithOptionsAsync( |
27 const GURL& url, | 27 const GURL& url, |
28 const std::string& cookie_line, | 28 const std::string& cookie_line, |
29 const CookieOptions& options, | 29 const CookieOptions& options, |
30 const CookieMonster::SetCookiesCallback& callback) OVERRIDE; | 30 const CookieMonster::SetCookiesCallback& callback) override; |
31 | 31 |
32 virtual void GetCookiesWithOptionsAsync( | 32 virtual void GetCookiesWithOptionsAsync( |
33 const GURL& url, | 33 const GURL& url, |
34 const CookieOptions& options, | 34 const CookieOptions& options, |
35 const CookieMonster::GetCookiesCallback& callback) OVERRIDE; | 35 const CookieMonster::GetCookiesCallback& callback) override; |
36 | 36 |
37 virtual void GetAllCookiesForURLAsync( | 37 virtual void GetAllCookiesForURLAsync( |
38 const GURL& url, | 38 const GURL& url, |
39 const GetCookieListCallback& callback) OVERRIDE; | 39 const GetCookieListCallback& callback) override; |
40 | 40 |
41 virtual bool SetCookieWithOptions(const GURL& url, | 41 virtual bool SetCookieWithOptions(const GURL& url, |
42 const std::string& cookie_line, | 42 const std::string& cookie_line, |
43 const CookieOptions& options); | 43 const CookieOptions& options); |
44 | 44 |
45 virtual std::string GetCookiesWithOptions(const GURL& url, | 45 virtual std::string GetCookiesWithOptions(const GURL& url, |
46 const CookieOptions& options); | 46 const CookieOptions& options); |
47 | 47 |
48 virtual void DeleteCookie(const GURL& url, | 48 virtual void DeleteCookie(const GURL& url, |
49 const std::string& cookie_name); | 49 const std::string& cookie_name); |
50 | 50 |
51 virtual void DeleteCookieAsync(const GURL& url, | 51 virtual void DeleteCookieAsync(const GURL& url, |
52 const std::string& cookie_name, | 52 const std::string& cookie_name, |
53 const base::Closure& callback) OVERRIDE; | 53 const base::Closure& callback) override; |
54 | 54 |
55 virtual void DeleteAllCreatedBetweenAsync( | 55 virtual void DeleteAllCreatedBetweenAsync( |
56 const base::Time& delete_begin, | 56 const base::Time& delete_begin, |
57 const base::Time& delete_end, | 57 const base::Time& delete_end, |
58 const DeleteCallback& callback) OVERRIDE; | 58 const DeleteCallback& callback) override; |
59 | 59 |
60 virtual void DeleteAllCreatedBetweenForHostAsync( | 60 virtual void DeleteAllCreatedBetweenForHostAsync( |
61 const base::Time delete_begin, | 61 const base::Time delete_begin, |
62 const base::Time delete_end, | 62 const base::Time delete_end, |
63 const GURL& url, | 63 const GURL& url, |
64 const DeleteCallback& callback) OVERRIDE; | 64 const DeleteCallback& callback) override; |
65 | 65 |
66 virtual void DeleteSessionCookiesAsync(const DeleteCallback&) OVERRIDE; | 66 virtual void DeleteSessionCookiesAsync(const DeleteCallback&) override; |
67 | 67 |
68 virtual CookieMonster* GetCookieMonster() OVERRIDE; | 68 virtual CookieMonster* GetCookieMonster() override; |
69 | 69 |
70 private: | 70 private: |
71 | 71 |
72 // Be called immediately from CookieMonster. | 72 // Be called immediately from CookieMonster. |
73 | 73 |
74 void SetCookiesInternalCallback(bool result); | 74 void SetCookiesInternalCallback(bool result); |
75 | 75 |
76 void GetCookiesWithOptionsInternalCallback(const std::string& cookie); | 76 void GetCookiesWithOptionsInternalCallback(const std::string& cookie); |
77 | 77 |
78 // Invoke the original callbacks. | 78 // Invoke the original callbacks. |
(...skipping 11 matching lines...) Expand all Loading... |
90 | 90 |
91 bool did_run_; | 91 bool did_run_; |
92 bool result_; | 92 bool result_; |
93 std::string cookie_; | 93 std::string cookie_; |
94 std::string cookie_line_; | 94 std::string cookie_line_; |
95 }; | 95 }; |
96 | 96 |
97 } // namespace net | 97 } // namespace net |
98 | 98 |
99 #endif // NET_COOKIES_COOKIE_STORE_TEST_HELPERS_H_ | 99 #endif // NET_COOKIES_COOKIE_STORE_TEST_HELPERS_H_ |
OLD | NEW |