Chromium Code Reviews| Index: content/browser/site_per_process_browsertest.h |
| diff --git a/content/browser/site_per_process_browsertest.h b/content/browser/site_per_process_browsertest.h |
| index 32861ec6d3978e1139d0bd3201b34c1e2aa1f9b7..2bdf014148da03ad853660e14c259e72ee1292b7 100644 |
| --- a/content/browser/site_per_process_browsertest.h |
| +++ b/content/browser/site_per_process_browsertest.h |
| @@ -5,14 +5,25 @@ |
| #ifndef CONTENT_BROWSER_SITE_PER_PROCESS_BROWSERTEST_H_ |
| #define CONTENT_BROWSER_SITE_PER_PROCESS_BROWSERTEST_H_ |
| +#include <map> |
| #include <string> |
| +#include <vector> |
| +#include "base/callback.h" |
| +#include "base/macros.h" |
| #include "content/browser/web_contents/web_contents_impl.h" |
| #include "content/public/test/content_browser_test.h" |
| #include "content/shell/browser/shell.h" |
| #include "content/test/content_browser_test_utils_internal.h" |
| +#include "net/test/embedded_test_server/http_response.h" |
| #include "url/gurl.h" |
| +namespace net { |
| +namespace test_server { |
| +struct HttpRequest; |
| +} |
| +} |
| + |
| namespace content { |
| class FrameTreeNode; |
| @@ -20,6 +31,10 @@ class FrameTreeNode; |
| class SitePerProcessBrowserTest : public ContentBrowserTest { |
| public: |
| SitePerProcessBrowserTest(); |
| + ~SitePerProcessBrowserTest() override; |
| + |
| + void AddDelayedResponse(const net::test_server::SendBytesCallback& send, |
| + const net::test_server::SendCompleteCallback& done); |
| protected: |
| std::string DepictFrameTree(FrameTreeNode* node); |
| @@ -31,8 +46,35 @@ class SitePerProcessBrowserTest : public ContentBrowserTest { |
| return static_cast<WebContentsImpl*>(shell()->web_contents()); |
| } |
| + // Note: must be called on the UI thread before any requests are made for a |
| + // test. |
| + void SetDelayedRequestsForPath(std::string path, int num_delayed); |
| + |
| private: |
| + // Custom embedded test server handler. Looks for requests matching |
| + // delayed_requests_for_path_, and delays them if necessary. As soon as a |
| + // single request comes in and: |
| + // 1) It matches a delayed path |
| + // 2) No path has any more requests to delay |
| + // Then we release the barrier and finish all delayed requests. |
| + std::unique_ptr<net::test_server::HttpResponse> HandleMockResource( |
| + const net::test_server::HttpRequest& request); |
| + |
| + // If there are no more requests to delay, post a series of tasks finishing |
| + // all the delayed tasks. |
| + void MaybeStartRequests(); |
| + |
| + // Set of closures to call which will complete delayed requests. |
| + std::vector<base::Closure> send_response_closures_; |
| + |
| + // Map from URL paths to the number of requests to delay for that particular |
| + // path. Initialized on the UI thread but modified and read on the IO thread |
| + // once requests start being made. |
| + std::map<std::string, int> delayed_requests_for_path_; |
|
nasko
2017/01/31 15:50:34
All of these changes don't seem appropriate to add
Charlie Harrison
2017/01/31 20:19:32
Done. Subclass'd
|
| + |
| FrameTreeVisualizer visualizer_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(SitePerProcessBrowserTest); |
| }; |
| } // namespace content |