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 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 // OnAuthRequired call. It's placed in this file to prevent url_request.h | 41 // OnAuthRequired call. It's placed in this file to prevent url_request.h |
42 // from having to include network_delegate.h. | 42 // from having to include network_delegate.h. |
43 enum AuthRequiredResponse { | 43 enum AuthRequiredResponse { |
44 AUTH_REQUIRED_RESPONSE_NO_ACTION, | 44 AUTH_REQUIRED_RESPONSE_NO_ACTION, |
45 AUTH_REQUIRED_RESPONSE_SET_AUTH, | 45 AUTH_REQUIRED_RESPONSE_SET_AUTH, |
46 AUTH_REQUIRED_RESPONSE_CANCEL_AUTH, | 46 AUTH_REQUIRED_RESPONSE_CANCEL_AUTH, |
47 AUTH_REQUIRED_RESPONSE_IO_PENDING, | 47 AUTH_REQUIRED_RESPONSE_IO_PENDING, |
48 }; | 48 }; |
49 typedef base::Callback<void(AuthRequiredResponse)> AuthCallback; | 49 typedef base::Callback<void(AuthRequiredResponse)> AuthCallback; |
50 | 50 |
51 enum CacheWaitState { | 51 enum RequestWaitState { |
52 CACHE_WAIT_STATE_START, | 52 REQUEST_WAIT_STATE_CACHE_START, |
53 CACHE_WAIT_STATE_FINISH, | 53 REQUEST_WAIT_STATE_CACHE_FINISH, |
54 CACHE_WAIT_STATE_RESET | 54 REQUEST_WAIT_STATE_NETWORK_START, |
| 55 REQUEST_WAIT_STATE_NETWORK_FINISH, |
| 56 REQUEST_WAIT_STATE_RESET |
55 }; | 57 }; |
56 | 58 |
57 virtual ~NetworkDelegate() {} | 59 virtual ~NetworkDelegate() {} |
58 | 60 |
59 // Notification interface called by the network stack. Note that these | 61 // Notification interface called by the network stack. Note that these |
60 // functions mostly forward to the private virtuals. They also add some sanity | 62 // functions mostly forward to the private virtuals. They also add some sanity |
61 // checking on parameters. See the corresponding virtuals for explanations of | 63 // checking on parameters. See the corresponding virtuals for explanations of |
62 // the methods and their arguments. | 64 // the methods and their arguments. |
63 int NotifyBeforeURLRequest(URLRequest* request, | 65 int NotifyBeforeURLRequest(URLRequest* request, |
64 const CompletionCallback& callback, | 66 const CompletionCallback& callback, |
(...skipping 24 matching lines...) Expand all Loading... |
89 bool CanSetCookie(const URLRequest& request, | 91 bool CanSetCookie(const URLRequest& request, |
90 const std::string& cookie_line, | 92 const std::string& cookie_line, |
91 CookieOptions* options); | 93 CookieOptions* options); |
92 bool CanAccessFile(const URLRequest& request, | 94 bool CanAccessFile(const URLRequest& request, |
93 const FilePath& path) const; | 95 const FilePath& path) const; |
94 bool CanThrottleRequest(const URLRequest& request) const; | 96 bool CanThrottleRequest(const URLRequest& request) const; |
95 | 97 |
96 int NotifyBeforeSocketStreamConnect(SocketStream* socket, | 98 int NotifyBeforeSocketStreamConnect(SocketStream* socket, |
97 const CompletionCallback& callback); | 99 const CompletionCallback& callback); |
98 | 100 |
99 void NotifyCacheWaitStateChange(const URLRequest& request, | 101 void NotifyRequestWaitStateChange(const URLRequest& request, |
100 CacheWaitState state); | 102 RequestWaitState state); |
101 | 103 |
102 private: | 104 private: |
103 // This is the interface for subclasses of NetworkDelegate to implement. These | 105 // This is the interface for subclasses of NetworkDelegate to implement. These |
104 // member functions will be called by the respective public notification | 106 // member functions will be called by the respective public notification |
105 // member function, which will perform basic sanity checking. | 107 // member function, which will perform basic sanity checking. |
106 | 108 |
107 // Called before a request is sent. Allows the delegate to rewrite the URL | 109 // Called before a request is sent. Allows the delegate to rewrite the URL |
108 // being fetched by modifying |new_url|. |callback| and |new_url| are valid | 110 // being fetched by modifying |new_url|. |callback| and |new_url| are valid |
109 // only until OnURLRequestDestroyed is called for this request. Returns a net | 111 // only until OnURLRequestDestroyed is called for this request. Returns a net |
110 // status code, generally either OK to continue with the request or | 112 // status code, generally either OK to continue with the request or |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 // Returns true if the given request may be rejected when the | 220 // Returns true if the given request may be rejected when the |
219 // URLRequestThrottlerManager believes the server servicing the | 221 // URLRequestThrottlerManager believes the server servicing the |
220 // request is overloaded or down. | 222 // request is overloaded or down. |
221 virtual bool OnCanThrottleRequest(const URLRequest& request) const = 0; | 223 virtual bool OnCanThrottleRequest(const URLRequest& request) const = 0; |
222 | 224 |
223 // Called before a SocketStream tries to connect. | 225 // Called before a SocketStream tries to connect. |
224 virtual int OnBeforeSocketStreamConnect( | 226 virtual int OnBeforeSocketStreamConnect( |
225 SocketStream* socket, const CompletionCallback& callback) = 0; | 227 SocketStream* socket, const CompletionCallback& callback) = 0; |
226 | 228 |
227 // Called when the completion of a URLRequest is blocking on a cache | 229 // Called when the completion of a URLRequest is blocking on a cache |
228 // transaction (CACHE_WAIT_STATE_START), or when a URLRequest is no longer | 230 // action or a network action, or when that is no longer the case. |
229 // blocked on a cache transaction (CACHE_WAIT_STATE_FINISH), or when a | 231 // REQUEST_WAIT_STATE_RESET indicates for a given URLRequest |
230 // URLRequest is reset (CACHE_WAIT_STATE_RESET), indicating | 232 // cancellation of any pending waits for this request. |
231 // cancellation of any pending cache waits for this request. Notice that | 233 virtual void OnRequestWaitStateChange(const URLRequest& request, |
232 // START can be called several times for the same request. It is the | 234 RequestWaitState state) = 0; |
233 // responsibility of the delegate to keep track of the number of outstanding | |
234 // cache transactions. | |
235 virtual void OnCacheWaitStateChange(const URLRequest& request, | |
236 CacheWaitState state) = 0; | |
237 }; | 235 }; |
238 | 236 |
239 } // namespace net | 237 } // namespace net |
240 | 238 |
241 #endif // NET_BASE_NETWORK_DELEGATE_H_ | 239 #endif // NET_BASE_NETWORK_DELEGATE_H_ |
OLD | NEW |