OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_RENDERER_HOST_THREAD_HOP_RESOURCE_THROTTLE_H_ | |
6 #define CHROME_BROWSER_RENDERER_HOST_THREAD_HOP_RESOURCE_THROTTLE_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "base/memory/weak_ptr.h" | |
10 #include "content/public/browser/resource_throttle.h" | |
11 | |
12 namespace base { | |
13 class TimeTicks; | |
14 } | |
15 | |
16 // A ResourceThrottle which defers request start, redirect, and response | |
17 // completion on an IO to UI to IO round-trip. This throttle will be added on a | |
18 // field trial to determine the cost of making some resource-related decisions | |
19 // on the UI thread. See https://crbug.com/524228. | |
20 class ThreadHopResourceThrottle : public content::ResourceThrottle { | |
21 public: | |
22 ThreadHopResourceThrottle(); | |
23 ~ThreadHopResourceThrottle() override; | |
24 | |
25 static bool IsEnabled(); | |
26 | |
27 // content::ResourceThrottle: | |
28 void WillStartRequest(bool* defer) override; | |
29 void WillRedirectRequest(const net::RedirectInfo& redirect_info, | |
30 bool* defer) override; | |
31 void WillProcessResponse(bool* defer) override; | |
32 const char* GetNameForLogging() const override; | |
33 | |
34 private: | |
35 void ResumeAfterThreadHop(); | |
36 void Resume(const base::TimeTicks& time); | |
37 | |
38 base::WeakPtrFactory<ThreadHopResourceThrottle> weak_factory_; | |
39 | |
40 DISALLOW_COPY_AND_ASSIGN(ThreadHopResourceThrottle); | |
41 }; | |
42 | |
43 #endif // CHROME_BROWSER_RENDERER_HOST_THREAD_HOP_RESOURCE_THROTTLE_H_ | |
OLD | NEW |