Fix crash in SpeechRecognizerImpl introduced in AudioParams refactor.
[chromium-blink-merge.git] / net / base / layered_network_delegate.h
blob8530db3e7550ee436292df35eff56cf0b62fc65a
1 // Copyright 2014 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 NET_BASE_LAYERED_NETWORK_DELEGATE_H_
6 #define NET_BASE_LAYERED_NETWORK_DELEGATE_H_
8 #include <stdint.h>
10 #include "base/memory/scoped_ptr.h"
11 #include "base/strings/string16.h"
12 #include "net/base/completion_callback.h"
13 #include "net/base/network_delegate.h"
14 #include "net/cookies/canonical_cookie.h"
16 class GURL;
18 namespace base {
19 class FilePath;
22 namespace net {
24 class CookieOptions;
25 class HttpRequestHeaders;
26 class HttpResponseHeaders;
27 class ProxyInfo;
28 class ProxyServer;
29 class ProxyService;
30 class URLRequest;
32 // WrappingNetworkDelegate takes a |network_delegate| and extends it. When
33 // On*() is called, the On*Internal() method of this is first called and then
34 // the On*() of |network_delegate| is called. On*Internal() methods have no
35 // return values, and cannot prevent calling into the nested network delegate.
36 class NET_EXPORT LayeredNetworkDelegate : public NetworkDelegate {
37 public:
38 explicit LayeredNetworkDelegate(
39 scoped_ptr<NetworkDelegate> nested_network_delegate);
40 ~LayeredNetworkDelegate() override;
42 // NetworkDelegate implementation:
43 int OnBeforeURLRequest(URLRequest* request,
44 const CompletionCallback& callback,
45 GURL* new_url) final;
46 void OnResolveProxy(const GURL& url,
47 int load_flags,
48 const ProxyService& proxy_service,
49 ProxyInfo* result) final;
50 void OnProxyFallback(const ProxyServer& bad_proxy, int net_error) final;
51 int OnBeforeSendHeaders(URLRequest* request,
52 const CompletionCallback& callback,
53 HttpRequestHeaders* headers) final;
54 void OnBeforeSendProxyHeaders(URLRequest* request,
55 const ProxyInfo& proxy_info,
56 HttpRequestHeaders* headers) final;
57 void OnSendHeaders(URLRequest* request,
58 const HttpRequestHeaders& headers) final;
59 int OnHeadersReceived(
60 URLRequest* request,
61 const CompletionCallback& callback,
62 const HttpResponseHeaders* original_response_headers,
63 scoped_refptr<HttpResponseHeaders>* override_response_headers,
64 GURL* allowed_unsafe_redirect_url) final;
65 void OnBeforeRedirect(URLRequest* request, const GURL& new_location) final;
66 void OnResponseStarted(URLRequest* request) final;
67 void OnNetworkBytesReceived(const URLRequest& request,
68 int64_t bytes_received) final;
69 void OnCompleted(URLRequest* request, bool started) final;
70 void OnURLRequestDestroyed(URLRequest* request) final;
71 void OnPACScriptError(int line_number, const base::string16& error) final;
72 AuthRequiredResponse OnAuthRequired(URLRequest* request,
73 const AuthChallengeInfo& auth_info,
74 const AuthCallback& callback,
75 AuthCredentials* credentials) final;
76 bool OnCanGetCookies(const URLRequest& request,
77 const CookieList& cookie_list) final;
78 bool OnCanSetCookie(const URLRequest& request,
79 const std::string& cookie_line,
80 CookieOptions* options) final;
81 bool OnCanAccessFile(const URLRequest& request,
82 const base::FilePath& path) const final;
83 bool OnCanEnablePrivacyMode(const GURL& url,
84 const GURL& first_party_for_cookies) const final;
85 bool OnFirstPartyOnlyCookieExperimentEnabled() const final;
86 bool OnCancelURLRequestWithPolicyViolatingReferrerHeader(
87 const URLRequest& request,
88 const GURL& target_url,
89 const GURL& referrer_url) const final;
91 protected:
92 virtual void OnBeforeURLRequestInternal(URLRequest* request,
93 const CompletionCallback& callback,
94 GURL* new_url);
96 virtual void OnResolveProxyInternal(const GURL& url,
97 int load_flags,
98 const ProxyService& proxy_service,
99 ProxyInfo* result);
101 virtual void OnProxyFallbackInternal(const ProxyServer& bad_proxy,
102 int net_error);
104 virtual void OnBeforeSendHeadersInternal(URLRequest* request,
105 const CompletionCallback& callback,
106 HttpRequestHeaders* headers);
108 virtual void OnBeforeSendProxyHeadersInternal(URLRequest* request,
109 const ProxyInfo& proxy_info,
110 HttpRequestHeaders* headers);
112 virtual void OnSendHeadersInternal(URLRequest* request,
113 const HttpRequestHeaders& headers);
115 virtual void OnHeadersReceivedInternal(
116 URLRequest* request,
117 const CompletionCallback& callback,
118 const HttpResponseHeaders* original_response_headers,
119 scoped_refptr<HttpResponseHeaders>* override_response_headers,
120 GURL* allowed_unsafe_redirect_url);
122 virtual void OnBeforeRedirectInternal(URLRequest* request,
123 const GURL& new_location);
125 virtual void OnResponseStartedInternal(URLRequest* request);
127 virtual void OnNetworkBytesReceivedInternal(const URLRequest& request,
128 int64_t bytes_received);
130 virtual void OnCompletedInternal(URLRequest* request, bool started);
132 virtual void OnURLRequestDestroyedInternal(URLRequest* request);
134 virtual void OnPACScriptErrorInternal(int line_number,
135 const base::string16& error);
137 virtual void OnCanGetCookiesInternal(const URLRequest& request,
138 const CookieList& cookie_list);
140 virtual void OnCanSetCookieInternal(const URLRequest& request,
141 const std::string& cookie_line,
142 CookieOptions* options);
144 virtual void OnAuthRequiredInternal(URLRequest* request,
145 const AuthChallengeInfo& auth_info,
146 const AuthCallback& callback,
147 AuthCredentials* credentials);
149 virtual void OnCanAccessFileInternal(const URLRequest& request,
150 const base::FilePath& path) const;
152 virtual void OnCanEnablePrivacyModeInternal(
153 const GURL& url,
154 const GURL& first_party_for_cookies) const;
156 virtual void OnFirstPartyOnlyCookieExperimentEnabledInternal() const;
158 virtual void OnCancelURLRequestWithPolicyViolatingReferrerHeaderInternal(
159 const URLRequest& request,
160 const GURL& target_url,
161 const GURL& referrer_url) const;
163 private:
164 scoped_ptr<NetworkDelegate> nested_network_delegate_;
167 } // namespace net
169 #endif // NET_BASE_LAYERED_NETWORK_DELEGATE_H_