OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 HEADLESS_PUBLIC_UTIL_TESTING_GENERIC_URL_REQUEST_MOCKS_H_ | 5 #ifndef HEADLESS_PUBLIC_UTIL_TESTING_GENERIC_URL_REQUEST_MOCKS_H_ |
6 #define HEADLESS_PUBLIC_UTIL_TESTING_GENERIC_URL_REQUEST_MOCKS_H_ | 6 #define HEADLESS_PUBLIC_UTIL_TESTING_GENERIC_URL_REQUEST_MOCKS_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 // TODO(alexclarke): We may be able to replace this with the CookieMonster. | 51 // TODO(alexclarke): We may be able to replace this with the CookieMonster. |
52 class HEADLESS_EXPORT MockCookieStore : public net::CookieStore { | 52 class HEADLESS_EXPORT MockCookieStore : public net::CookieStore { |
53 public: | 53 public: |
54 MockCookieStore(); | 54 MockCookieStore(); |
55 ~MockCookieStore() override; | 55 ~MockCookieStore() override; |
56 | 56 |
57 // net::CookieStore implementation: | 57 // net::CookieStore implementation: |
58 void SetCookieWithOptionsAsync(const GURL& url, | 58 void SetCookieWithOptionsAsync(const GURL& url, |
59 const std::string& cookie_line, | 59 const std::string& cookie_line, |
60 const net::CookieOptions& options, | 60 const net::CookieOptions& options, |
61 const SetCookiesCallback& callback) override; | 61 SetCookiesCallback callback) override; |
62 | 62 |
63 void SetCookieWithDetailsAsync(const GURL& url, | 63 void SetCookieWithDetailsAsync(const GURL& url, |
64 const std::string& name, | 64 const std::string& name, |
65 const std::string& value, | 65 const std::string& value, |
66 const std::string& domain, | 66 const std::string& domain, |
67 const std::string& path, | 67 const std::string& path, |
68 base::Time creation_time, | 68 base::Time creation_time, |
69 base::Time expiration_time, | 69 base::Time expiration_time, |
70 base::Time last_access_time, | 70 base::Time last_access_time, |
71 bool secure, | 71 bool secure, |
72 bool http_only, | 72 bool http_only, |
73 net::CookieSameSite same_site, | 73 net::CookieSameSite same_site, |
74 net::CookiePriority priority, | 74 net::CookiePriority priority, |
75 const SetCookiesCallback& callback) override; | 75 SetCookiesCallback callback) override; |
76 | 76 |
77 void SetCanonicalCookieAsync(std::unique_ptr<net::CanonicalCookie> cookie, | 77 void SetCanonicalCookieAsync(std::unique_ptr<net::CanonicalCookie> cookie, |
78 bool secure_source, | 78 bool secure_source, |
79 bool modify_http_only, | 79 bool modify_http_only, |
80 const SetCookiesCallback& callback) override; | 80 SetCookiesCallback callback) override; |
81 | 81 |
82 void GetCookiesWithOptionsAsync(const GURL& url, | 82 void GetCookiesWithOptionsAsync(const GURL& url, |
83 const net::CookieOptions& options, | 83 const net::CookieOptions& options, |
84 const GetCookiesCallback& callback) override; | 84 GetCookiesCallback callback) override; |
85 | 85 |
86 void GetCookieListWithOptionsAsync( | 86 void GetCookieListWithOptionsAsync(const GURL& url, |
87 const GURL& url, | 87 const net::CookieOptions& options, |
88 const net::CookieOptions& options, | 88 GetCookieListCallback callback) override; |
89 const GetCookieListCallback& callback) override; | |
90 | 89 |
91 void GetAllCookiesAsync(const GetCookieListCallback& callback) override; | 90 void GetAllCookiesAsync(GetCookieListCallback callback) override; |
92 | 91 |
93 void DeleteCookieAsync(const GURL& url, | 92 void DeleteCookieAsync(const GURL& url, |
94 const std::string& cookie_name, | 93 const std::string& cookie_name, |
95 const base::Closure& callback) override; | 94 base::OnceClosure callback) override; |
96 | 95 |
97 void DeleteCanonicalCookieAsync(const net::CanonicalCookie& cookie, | 96 void DeleteCanonicalCookieAsync(const net::CanonicalCookie& cookie, |
98 const DeleteCallback& callback) override; | 97 DeleteCallback callback) override; |
99 | 98 |
100 void DeleteAllCreatedBetweenAsync(const base::Time& delete_begin, | 99 void DeleteAllCreatedBetweenAsync(const base::Time& delete_begin, |
101 const base::Time& delete_end, | 100 const base::Time& delete_end, |
102 const DeleteCallback& callback) override; | 101 DeleteCallback callback) override; |
103 | 102 |
104 void DeleteAllCreatedBetweenWithPredicateAsync( | 103 void DeleteAllCreatedBetweenWithPredicateAsync( |
105 const base::Time& delete_begin, | 104 const base::Time& delete_begin, |
106 const base::Time& delete_end, | 105 const base::Time& delete_end, |
107 const CookiePredicate& predicate, | 106 const CookiePredicate& predicate, |
108 const DeleteCallback& callback) override; | 107 DeleteCallback callback) override; |
109 | 108 |
110 void DeleteSessionCookiesAsync(const DeleteCallback&) override; | 109 void DeleteSessionCookiesAsync(DeleteCallback) override; |
111 | 110 |
112 void FlushStore(const base::Closure& callback) override; | 111 void FlushStore(base::OnceClosure callback) override; |
113 | 112 |
114 void SetForceKeepSessionState() override; | 113 void SetForceKeepSessionState() override; |
115 | 114 |
116 std::unique_ptr<CookieChangedSubscription> AddCallbackForCookie( | 115 std::unique_ptr<CookieChangedSubscription> AddCallbackForCookie( |
117 const GURL& url, | 116 const GURL& url, |
118 const std::string& name, | 117 const std::string& name, |
119 const CookieChangedCallback& callback) override; | 118 const CookieChangedCallback& callback) override; |
120 | 119 |
121 bool IsEphemeral() override; | 120 bool IsEphemeral() override; |
122 | 121 |
123 net::CookieList* cookies() { return &cookies_; } | 122 net::CookieList* cookies() { return &cookies_; } |
124 | 123 |
125 private: | 124 private: |
126 void SendCookies(const GURL& url, | 125 void SendCookies(const GURL& url, |
127 const net::CookieOptions& options, | 126 const net::CookieOptions& options, |
128 const GetCookieListCallback& callback); | 127 GetCookieListCallback callback); |
129 | 128 |
130 net::CookieList cookies_; | 129 net::CookieList cookies_; |
131 | 130 |
132 DISALLOW_COPY_AND_ASSIGN(MockCookieStore); | 131 DISALLOW_COPY_AND_ASSIGN(MockCookieStore); |
133 }; | 132 }; |
134 | 133 |
135 class HEADLESS_EXPORT MockURLRequestDelegate | 134 class HEADLESS_EXPORT MockURLRequestDelegate |
136 : public net::URLRequest::Delegate { | 135 : public net::URLRequest::Delegate { |
137 public: | 136 public: |
138 MockURLRequestDelegate(); | 137 MockURLRequestDelegate(); |
139 ~MockURLRequestDelegate() override; | 138 ~MockURLRequestDelegate() override; |
140 | 139 |
141 void OnResponseStarted(net::URLRequest* request) override; | 140 void OnResponseStarted(net::URLRequest* request) override; |
142 void OnReadCompleted(net::URLRequest* request, int bytes_read) override; | 141 void OnReadCompleted(net::URLRequest* request, int bytes_read) override; |
143 const std::string& response_data() const; | 142 const std::string& response_data() const; |
144 const net::IOBufferWithSize* metadata() const; | 143 const net::IOBufferWithSize* metadata() const; |
145 | 144 |
146 private: | 145 private: |
147 std::string response_data_; | 146 std::string response_data_; |
148 | 147 |
149 DISALLOW_COPY_AND_ASSIGN(MockURLRequestDelegate); | 148 DISALLOW_COPY_AND_ASSIGN(MockURLRequestDelegate); |
150 }; | 149 }; |
151 | 150 |
152 } // namespace headless | 151 } // namespace headless |
153 | 152 |
154 #endif // HEADLESS_PUBLIC_UTIL_TESTING_GENERIC_URL_REQUEST_MOCKS_H_ | 153 #endif // HEADLESS_PUBLIC_UTIL_TESTING_GENERIC_URL_REQUEST_MOCKS_H_ |
OLD | NEW |