[Android WebView] Fix webview perf bot switchover to use org.chromium.webview_shell...
[chromium-blink-merge.git] / content / public / browser / resource_throttle.h
blob240d95e1967b0a01d028d8c4be9e8a961bcde7be
1 // Copyright (c) 2012 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.
5 #ifndef CONTENT_PUBLIC_BROWSER_RESOURCE_THROTTLE_H_
6 #define CONTENT_PUBLIC_BROWSER_RESOURCE_THROTTLE_H_
8 #include <vector>
10 class GURL;
12 namespace net {
13 struct RedirectInfo;
16 namespace content {
18 class ResourceController;
20 // A ResourceThrottle gets notified at various points during the process of
21 // loading a resource. At each stage, it has the opportunity to defer the
22 // resource load. The ResourceController interface may be used to resume a
23 // deferred resource load, or it may be used to cancel a resource load at any
24 // time.
25 class ResourceThrottle {
26 public:
27 virtual ~ResourceThrottle() {}
29 // Called before the resource request is started.
30 virtual void WillStartRequest(bool* defer) {}
32 // Called before the resource request uses the network for the first time.
33 virtual void WillStartUsingNetwork(bool* defer) {}
35 // Called when the request was redirected. |redirect_info| contains the
36 // redirect responses's HTTP status code and some information about the new
37 // request that will be sent if the redirect is followed, including the new
38 // URL and new method.
39 virtual void WillRedirectRequest(const net::RedirectInfo& redirect_info,
40 bool* defer) {}
42 // Called when the response headers and meta data are available.
43 virtual void WillProcessResponse(bool* defer) {}
45 // Returns the name of the throttle, as a UTF-8 C-string, for logging
46 // purposes. nullptr is not allowed. Caller does *not* take ownership of the
47 // returned string.
48 virtual const char* GetNameForLogging() const = 0;
50 void set_controller_for_testing(ResourceController* c) {
51 controller_ = c;
54 protected:
55 ResourceThrottle() : controller_(nullptr) {}
56 ResourceController* controller() { return controller_; }
58 private:
59 friend class ThrottlingResourceHandler;
60 void set_controller(ResourceController* c) { controller_ = c; }
62 ResourceController* controller_;
65 } // namespace content
67 #endif // CONTENT_PUBLIC_BROWSER_RESOURCE_THROTTLE_H_