OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef NET_BASE_NETWORK_DELEGATE_H_ | 5 #ifndef NET_BASE_NETWORK_DELEGATE_H_ |
6 #define NET_BASE_NETWORK_DELEGATE_H_ | 6 #define NET_BASE_NETWORK_DELEGATE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 // submodule. Also, since the lower levels in net/ may callback into higher | 26 // submodule. Also, since the lower levels in net/ may callback into higher |
27 // levels, we may encounter dangerous casting issues. | 27 // levels, we may encounter dangerous casting issues. |
28 // | 28 // |
29 // NOTE: It is not okay to add any compile-time dependencies on symbols outside | 29 // NOTE: It is not okay to add any compile-time dependencies on symbols outside |
30 // of net/base here, because we have a net_base library. Forward declarations | 30 // of net/base here, because we have a net_base library. Forward declarations |
31 // are ok. | 31 // are ok. |
32 class CookieList; | 32 class CookieList; |
33 class CookieOptions; | 33 class CookieOptions; |
34 class HttpRequestHeaders; | 34 class HttpRequestHeaders; |
35 class HttpResponseHeaders; | 35 class HttpResponseHeaders; |
| 36 class SocketStream; |
36 class URLRequest; | 37 class URLRequest; |
37 | 38 |
38 class NetworkDelegate : public base::NonThreadSafe { | 39 class NetworkDelegate : public base::NonThreadSafe { |
39 public: | 40 public: |
40 // AuthRequiredResponse indicates how a NetworkDelegate handles an | 41 // AuthRequiredResponse indicates how a NetworkDelegate handles an |
41 // OnAuthRequired call. It's placed in this file to prevent url_request.h | 42 // OnAuthRequired call. It's placed in this file to prevent url_request.h |
42 // from having to include network_delegate.h. | 43 // from having to include network_delegate.h. |
43 enum AuthRequiredResponse { | 44 enum AuthRequiredResponse { |
44 AUTH_REQUIRED_RESPONSE_NO_ACTION, | 45 AUTH_REQUIRED_RESPONSE_NO_ACTION, |
45 AUTH_REQUIRED_RESPONSE_SET_AUTH, | 46 AUTH_REQUIRED_RESPONSE_SET_AUTH, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 AuthCredentials* credentials); | 81 AuthCredentials* credentials); |
81 bool CanGetCookies(const URLRequest& request, | 82 bool CanGetCookies(const URLRequest& request, |
82 const CookieList& cookie_list); | 83 const CookieList& cookie_list); |
83 bool CanSetCookie(const URLRequest& request, | 84 bool CanSetCookie(const URLRequest& request, |
84 const std::string& cookie_line, | 85 const std::string& cookie_line, |
85 CookieOptions* options); | 86 CookieOptions* options); |
86 bool CanAccessFile(const URLRequest& request, | 87 bool CanAccessFile(const URLRequest& request, |
87 const FilePath& path) const; | 88 const FilePath& path) const; |
88 bool CanThrottleRequest(const URLRequest& request) const; | 89 bool CanThrottleRequest(const URLRequest& request) const; |
89 | 90 |
| 91 int NotifyBeforeSocketStreamConnect(SocketStream* socket, |
| 92 const CompletionCallback& callback); |
| 93 |
90 private: | 94 private: |
91 // This is the interface for subclasses of NetworkDelegate to implement. These | 95 // This is the interface for subclasses of NetworkDelegate to implement. These |
92 // member functions will be called by the respective public notification | 96 // member functions will be called by the respective public notification |
93 // member function, which will perform basic sanity checking. | 97 // member function, which will perform basic sanity checking. |
94 | 98 |
95 // Called before a request is sent. Allows the delegate to rewrite the URL | 99 // Called before a request is sent. Allows the delegate to rewrite the URL |
96 // being fetched by modifying |new_url|. |callback| and |new_url| are valid | 100 // being fetched by modifying |new_url|. |callback| and |new_url| are valid |
97 // only until OnURLRequestDestroyed is called for this request. Returns a net | 101 // only until OnURLRequestDestroyed is called for this request. Returns a net |
98 // status code, generally either OK to continue with the request or | 102 // status code, generally either OK to continue with the request or |
99 // ERR_IO_PENDING if the result is not ready yet. A status code other than OK | 103 // ERR_IO_PENDING if the result is not ready yet. A status code other than OK |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 // Called when a file access is attempted to allow the network delegate to | 204 // Called when a file access is attempted to allow the network delegate to |
201 // allow or block access to the given file path. Returns true if access is | 205 // allow or block access to the given file path. Returns true if access is |
202 // allowed. | 206 // allowed. |
203 virtual bool OnCanAccessFile(const URLRequest& request, | 207 virtual bool OnCanAccessFile(const URLRequest& request, |
204 const FilePath& path) const = 0; | 208 const FilePath& path) const = 0; |
205 | 209 |
206 // Returns true if the given request may be rejected when the | 210 // Returns true if the given request may be rejected when the |
207 // URLRequestThrottlerManager believes the server servicing the | 211 // URLRequestThrottlerManager believes the server servicing the |
208 // request is overloaded or down. | 212 // request is overloaded or down. |
209 virtual bool OnCanThrottleRequest(const URLRequest& request) const = 0; | 213 virtual bool OnCanThrottleRequest(const URLRequest& request) const = 0; |
| 214 |
| 215 // Called before a SocketStream tries to connect. |
| 216 virtual int OnBeforeSocketStreamConnect( |
| 217 SocketStream* socket, const CompletionCallback& callback) = 0; |
210 }; | 218 }; |
211 | 219 |
212 } // namespace net | 220 } // namespace net |
213 | 221 |
214 #endif // NET_BASE_NETWORK_DELEGATE_H_ | 222 #endif // NET_BASE_NETWORK_DELEGATE_H_ |
OLD | NEW |