| 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" |
| 11 #include "base/string16.h" | 11 #include "base/string16.h" |
| 12 #include "base/threading/non_thread_safe.h" | 12 #include "base/threading/non_thread_safe.h" |
| 13 #include "net/base/auth.h" | 13 #include "net/base/auth.h" |
| 14 #include "net/base/completion_callback.h" | 14 #include "net/base/completion_callback.h" |
| 15 #include "net/cookies/canonical_cookie.h" | 15 #include "net/cookies/canonical_cookie.h" |
| 16 | 16 |
| 17 class GURL; |
| 18 |
| 19 namespace base { |
| 17 class FilePath; | 20 class FilePath; |
| 18 class GURL; | 21 } |
| 19 | 22 |
| 20 namespace net { | 23 namespace net { |
| 21 | 24 |
| 22 // NOTE: Layering violations! | 25 // NOTE: Layering violations! |
| 23 // We decided to accept these violations (depending | 26 // We decided to accept these violations (depending |
| 24 // on other net/ submodules from net/base/), because otherwise NetworkDelegate | 27 // on other net/ submodules from net/base/), because otherwise NetworkDelegate |
| 25 // would have to be broken up into too many smaller interfaces targeted to each | 28 // would have to be broken up into too many smaller interfaces targeted to each |
| 26 // submodule. Also, since the lower levels in net/ may callback into higher | 29 // submodule. Also, since the lower levels in net/ may callback into higher |
| 27 // levels, we may encounter dangerous casting issues. | 30 // levels, we may encounter dangerous casting issues. |
| 28 // | 31 // |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 AuthRequiredResponse NotifyAuthRequired(URLRequest* request, | 88 AuthRequiredResponse NotifyAuthRequired(URLRequest* request, |
| 86 const AuthChallengeInfo& auth_info, | 89 const AuthChallengeInfo& auth_info, |
| 87 const AuthCallback& callback, | 90 const AuthCallback& callback, |
| 88 AuthCredentials* credentials); | 91 AuthCredentials* credentials); |
| 89 bool CanGetCookies(const URLRequest& request, | 92 bool CanGetCookies(const URLRequest& request, |
| 90 const CookieList& cookie_list); | 93 const CookieList& cookie_list); |
| 91 bool CanSetCookie(const URLRequest& request, | 94 bool CanSetCookie(const URLRequest& request, |
| 92 const std::string& cookie_line, | 95 const std::string& cookie_line, |
| 93 CookieOptions* options); | 96 CookieOptions* options); |
| 94 bool CanAccessFile(const URLRequest& request, | 97 bool CanAccessFile(const URLRequest& request, |
| 95 const FilePath& path) const; | 98 const base::FilePath& path) const; |
| 96 bool CanThrottleRequest(const URLRequest& request) const; | 99 bool CanThrottleRequest(const URLRequest& request) const; |
| 97 | 100 |
| 98 int NotifyBeforeSocketStreamConnect(SocketStream* socket, | 101 int NotifyBeforeSocketStreamConnect(SocketStream* socket, |
| 99 const CompletionCallback& callback); | 102 const CompletionCallback& callback); |
| 100 | 103 |
| 101 void NotifyRequestWaitStateChange(const URLRequest& request, | 104 void NotifyRequestWaitStateChange(const URLRequest& request, |
| 102 RequestWaitState state); | 105 RequestWaitState state); |
| 103 | 106 |
| 104 private: | 107 private: |
| 105 // This is the interface for subclasses of NetworkDelegate to implement. These | 108 // This is the interface for subclasses of NetworkDelegate to implement. These |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 // LOAD_DO_NOT_SAVE_COOKIES is specified. | 211 // LOAD_DO_NOT_SAVE_COOKIES is specified. |
| 209 virtual bool OnCanSetCookie(const URLRequest& request, | 212 virtual bool OnCanSetCookie(const URLRequest& request, |
| 210 const std::string& cookie_line, | 213 const std::string& cookie_line, |
| 211 CookieOptions* options) = 0; | 214 CookieOptions* options) = 0; |
| 212 | 215 |
| 213 | 216 |
| 214 // Called when a file access is attempted to allow the network delegate to | 217 // Called when a file access is attempted to allow the network delegate to |
| 215 // allow or block access to the given file path. Returns true if access is | 218 // allow or block access to the given file path. Returns true if access is |
| 216 // allowed. | 219 // allowed. |
| 217 virtual bool OnCanAccessFile(const URLRequest& request, | 220 virtual bool OnCanAccessFile(const URLRequest& request, |
| 218 const FilePath& path) const = 0; | 221 const base::FilePath& path) const = 0; |
| 219 | 222 |
| 220 // Returns true if the given request may be rejected when the | 223 // Returns true if the given request may be rejected when the |
| 221 // URLRequestThrottlerManager believes the server servicing the | 224 // URLRequestThrottlerManager believes the server servicing the |
| 222 // request is overloaded or down. | 225 // request is overloaded or down. |
| 223 virtual bool OnCanThrottleRequest(const URLRequest& request) const = 0; | 226 virtual bool OnCanThrottleRequest(const URLRequest& request) const = 0; |
| 224 | 227 |
| 225 // Called before a SocketStream tries to connect. | 228 // Called before a SocketStream tries to connect. |
| 226 virtual int OnBeforeSocketStreamConnect( | 229 virtual int OnBeforeSocketStreamConnect( |
| 227 SocketStream* socket, const CompletionCallback& callback) = 0; | 230 SocketStream* socket, const CompletionCallback& callback) = 0; |
| 228 | 231 |
| 229 // Called when the completion of a URLRequest is blocking on a cache | 232 // Called when the completion of a URLRequest is blocking on a cache |
| 230 // action or a network action, or when that is no longer the case. | 233 // action or a network action, or when that is no longer the case. |
| 231 // REQUEST_WAIT_STATE_RESET indicates for a given URLRequest | 234 // REQUEST_WAIT_STATE_RESET indicates for a given URLRequest |
| 232 // cancellation of any pending waits for this request. | 235 // cancellation of any pending waits for this request. |
| 233 virtual void OnRequestWaitStateChange(const URLRequest& request, | 236 virtual void OnRequestWaitStateChange(const URLRequest& request, |
| 234 RequestWaitState state) = 0; | 237 RequestWaitState state) = 0; |
| 235 }; | 238 }; |
| 236 | 239 |
| 237 } // namespace net | 240 } // namespace net |
| 238 | 241 |
| 239 #endif // NET_BASE_NETWORK_DELEGATE_H_ | 242 #endif // NET_BASE_NETWORK_DELEGATE_H_ |
| OLD | NEW |