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 run_loop_.Quit(); | 94 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 95 run_loop_.QuitClosure()); |
| 96 } |
95 return std::move(http_response); | 97 return std::move(http_response); |
96 } | 98 } |
97 | 99 |
98 // A request handler which increases a cookie value on every request. | 100 // A request handler which increases a cookie value on every request. |
99 std::unique_ptr<HttpResponse> CookieRequestHandler( | 101 std::unique_ptr<HttpResponse> CookieRequestHandler( |
100 const HttpRequest& request) { | 102 const HttpRequest& request) { |
101 static const char kHtml[] = | 103 static const char kHtml[] = |
102 "<script>\n" | 104 "<script>\n" |
103 "var intervalId;\n" | 105 "var intervalId;\n" |
104 "function checkCookie() {\n" | 106 "function checkCookie() {\n" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 NavigateToURL(shell(), GURL("about:blank")); | 232 NavigateToURL(shell(), GURL("about:blank")); |
231 | 233 |
232 // The page will load from the cache, then when the async revalidation | 234 // The page will load from the cache, then when the async revalidation |
233 // completes the cookie will update. | 235 // completes the cookie will update. |
234 EXPECT_TRUE(TitleBecomes(url, "PASS")); | 236 EXPECT_TRUE(TitleBecomes(url, "PASS")); |
235 } | 237 } |
236 | 238 |
237 } // namespace | 239 } // namespace |
238 | 240 |
239 } // namespace content | 241 } // namespace content |
OLD | NEW |