| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 const AuthCallback& callback, | 80 const AuthCallback& callback, |
| 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 | 89 |
| 90 int NotifyBeforeSocketStreamConnect(SocketStream* socket, |
| 91 const CompletionCallback& callback); |
| 92 |
| 89 private: | 93 private: |
| 90 // This is the interface for subclasses of NetworkDelegate to implement. These | 94 // This is the interface for subclasses of NetworkDelegate to implement. These |
| 91 // member functions will be called by the respective public notification | 95 // member functions will be called by the respective public notification |
| 92 // member function, which will perform basic sanity checking. | 96 // member function, which will perform basic sanity checking. |
| 93 | 97 |
| 94 // Called before a request is sent. Allows the delegate to rewrite the URL | 98 // Called before a request is sent. Allows the delegate to rewrite the URL |
| 95 // being fetched by modifying |new_url|. |callback| and |new_url| are valid | 99 // being fetched by modifying |new_url|. |callback| and |new_url| are valid |
| 96 // only until OnURLRequestDestroyed is called for this request. Returns a net | 100 // only until OnURLRequestDestroyed is called for this request. Returns a net |
| 97 // status code, generally either OK to continue with the request or | 101 // status code, generally either OK to continue with the request or |
| 98 // ERR_IO_PENDING if the result is not ready yet. A status code other than OK | 102 // ERR_IO_PENDING if the result is not ready yet. A status code other than OK |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 const std::string& cookie_line, | 199 const std::string& cookie_line, |
| 196 CookieOptions* options) = 0; | 200 CookieOptions* options) = 0; |
| 197 | 201 |
| 198 | 202 |
| 199 // Called when a file access is attempted to allow the network delegate to | 203 // Called when a file access is attempted to allow the network delegate to |
| 200 // allow or block access to the given file path. Returns true if access is | 204 // allow or block access to the given file path. Returns true if access is |
| 201 // allowed. | 205 // allowed. |
| 202 virtual bool OnCanAccessFile(const URLRequest& request, | 206 virtual bool OnCanAccessFile(const URLRequest& request, |
| 203 const FilePath& path) const = 0; | 207 const FilePath& path) const = 0; |
| 204 | 208 |
| 209 // Called before a SocketStream tries to connect. |
| 210 virtual int OnBeforeSocketStreamConnect( |
| 211 SocketStream* socket, const CompletionCallback& callback) = 0; |
| 205 }; | 212 }; |
| 206 | 213 |
| 207 } // namespace net | 214 } // namespace net |
| 208 | 215 |
| 209 #endif // NET_BASE_NETWORK_DELEGATE_H_ | 216 #endif // NET_BASE_NETWORK_DELEGATE_H_ |
| OLD | NEW |