OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <memory> | 5 #include <memory> |
6 #include <string> | 6 #include <string> |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 83 |
84 int version = ++requests_counted_; | 84 int version = ++requests_counted_; |
85 | 85 |
86 std::unique_ptr<BasicHttpResponse> http_response( | 86 std::unique_ptr<BasicHttpResponse> http_response( |
87 StaleWhileRevalidateHeaders()); | 87 StaleWhileRevalidateHeaders()); |
88 http_response->set_content( | 88 http_response->set_content( |
89 base::StringPrintf("<title>Version %d</title>", version)); | 89 base::StringPrintf("<title>Version %d</title>", version)); |
90 | 90 |
91 // The second time this handler is run is the async revalidation. Tests can | 91 // The second time this handler is run is the async revalidation. Tests can |
92 // use this for synchronisation. | 92 // use this for synchronisation. |
93 if (version == 2) { | 93 if (version == 2) |
94 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 94 run_loop_.Quit(); |
95 run_loop_.QuitClosure()); | |
96 } | |
97 return std::move(http_response); | 95 return std::move(http_response); |
98 } | 96 } |
99 | 97 |
100 // A request handler which increases a cookie value on every request. | 98 // A request handler which increases a cookie value on every request. |
101 std::unique_ptr<HttpResponse> CookieRequestHandler( | 99 std::unique_ptr<HttpResponse> CookieRequestHandler( |
102 const HttpRequest& request) { | 100 const HttpRequest& request) { |
103 static const char kHtml[] = | 101 static const char kHtml[] = |
104 "<script>\n" | 102 "<script>\n" |
105 "var intervalId;\n" | 103 "var intervalId;\n" |
106 "function checkCookie() {\n" | 104 "function checkCookie() {\n" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 NavigateToURL(shell(), GURL("about:blank")); | 230 NavigateToURL(shell(), GURL("about:blank")); |
233 | 231 |
234 // The page will load from the cache, then when the async revalidation | 232 // The page will load from the cache, then when the async revalidation |
235 // completes the cookie will update. | 233 // completes the cookie will update. |
236 EXPECT_TRUE(TitleBecomes(url, "PASS")); | 234 EXPECT_TRUE(TitleBecomes(url, "PASS")); |
237 } | 235 } |
238 | 236 |
239 } // namespace | 237 } // namespace |
240 | 238 |
241 } // namespace content | 239 } // namespace content |
OLD | NEW |