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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "base/threading/non_thread_safe.h" | 14 #include "base/threading/thread_checker.h" |
15 #include "net/base/auth.h" | 15 #include "net/base/auth.h" |
16 #include "net/base/completion_callback.h" | 16 #include "net/base/completion_callback.h" |
17 #include "net/base/net_export.h" | 17 #include "net/base/net_export.h" |
18 #include "net/cookies/canonical_cookie.h" | 18 #include "net/cookies/canonical_cookie.h" |
19 #include "net/proxy/proxy_retry_info.h" | 19 #include "net/proxy/proxy_retry_info.h" |
20 | 20 |
21 class GURL; | 21 class GURL; |
22 | 22 |
23 namespace base { | 23 namespace base { |
24 class FilePath; | 24 class FilePath; |
(...skipping 14 matching lines...) Expand all Loading... |
39 // | 39 // |
40 // NOTE: It is not okay to add any compile-time dependencies on symbols outside | 40 // NOTE: It is not okay to add any compile-time dependencies on symbols outside |
41 // of net/base here, because we have a net_base library. Forward declarations | 41 // of net/base here, because we have a net_base library. Forward declarations |
42 // are ok. | 42 // are ok. |
43 class CookieOptions; | 43 class CookieOptions; |
44 class HttpRequestHeaders; | 44 class HttpRequestHeaders; |
45 class HttpResponseHeaders; | 45 class HttpResponseHeaders; |
46 class ProxyInfo; | 46 class ProxyInfo; |
47 class URLRequest; | 47 class URLRequest; |
48 | 48 |
49 class NET_EXPORT NetworkDelegate : public base::NonThreadSafe { | 49 class NET_EXPORT NetworkDelegate { |
50 public: | 50 public: |
51 // AuthRequiredResponse indicates how a NetworkDelegate handles an | 51 // AuthRequiredResponse indicates how a NetworkDelegate handles an |
52 // OnAuthRequired call. It's placed in this file to prevent url_request.h | 52 // OnAuthRequired call. It's placed in this file to prevent url_request.h |
53 // from having to include network_delegate.h. | 53 // from having to include network_delegate.h. |
54 enum AuthRequiredResponse { | 54 enum AuthRequiredResponse { |
55 AUTH_REQUIRED_RESPONSE_NO_ACTION, | 55 AUTH_REQUIRED_RESPONSE_NO_ACTION, |
56 AUTH_REQUIRED_RESPONSE_SET_AUTH, | 56 AUTH_REQUIRED_RESPONSE_SET_AUTH, |
57 AUTH_REQUIRED_RESPONSE_CANCEL_AUTH, | 57 AUTH_REQUIRED_RESPONSE_CANCEL_AUTH, |
58 AUTH_REQUIRED_RESPONSE_IO_PENDING, | 58 AUTH_REQUIRED_RESPONSE_IO_PENDING, |
59 }; | 59 }; |
60 typedef base::Callback<void(AuthRequiredResponse)> AuthCallback; | 60 typedef base::Callback<void(AuthRequiredResponse)> AuthCallback; |
61 | 61 |
62 virtual ~NetworkDelegate() {} | 62 virtual ~NetworkDelegate(); |
63 | 63 |
64 // Notification interface called by the network stack. Note that these | 64 // Notification interface called by the network stack. Note that these |
65 // functions mostly forward to the private virtuals. They also add some sanity | 65 // functions mostly forward to the private virtuals. They also add some sanity |
66 // checking on parameters. See the corresponding virtuals for explanations of | 66 // checking on parameters. See the corresponding virtuals for explanations of |
67 // the methods and their arguments. | 67 // the methods and their arguments. |
68 int NotifyBeforeURLRequest(URLRequest* request, | 68 int NotifyBeforeURLRequest(URLRequest* request, |
69 const CompletionCallback& callback, | 69 const CompletionCallback& callback, |
70 GURL* new_url); | 70 GURL* new_url); |
71 int NotifyBeforeStartTransaction(URLRequest* request, | 71 int NotifyBeforeStartTransaction(URLRequest* request, |
72 const CompletionCallback& callback, | 72 const CompletionCallback& callback, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 const GURL& target_url, | 117 const GURL& target_url, |
118 const GURL& referrer_url) const; | 118 const GURL& referrer_url) const; |
119 | 119 |
120 bool CanQueueReportingReport(const url::Origin& origin) const; | 120 bool CanQueueReportingReport(const url::Origin& origin) const; |
121 bool CanSendReportingReport(const url::Origin& origin) const; | 121 bool CanSendReportingReport(const url::Origin& origin) const; |
122 bool CanSetReportingClient(const url::Origin& origin, | 122 bool CanSetReportingClient(const url::Origin& origin, |
123 const GURL& endpoint) const; | 123 const GURL& endpoint) const; |
124 bool CanUseReportingClient(const url::Origin& origin, | 124 bool CanUseReportingClient(const url::Origin& origin, |
125 const GURL& endpoint) const; | 125 const GURL& endpoint) const; |
126 | 126 |
| 127 protected: |
| 128 THREAD_CHECKER(thread_checker_); |
| 129 |
127 private: | 130 private: |
128 // This is the interface for subclasses of NetworkDelegate to implement. These | 131 // This is the interface for subclasses of NetworkDelegate to implement. These |
129 // member functions will be called by the respective public notification | 132 // member functions will be called by the respective public notification |
130 // member function, which will perform basic sanity checking. | 133 // member function, which will perform basic sanity checking. |
131 // | 134 // |
132 // (NetworkDelegateImpl has default implementations of these member functions. | 135 // (NetworkDelegateImpl has default implementations of these member functions. |
133 // NetworkDelegate implementations should consider subclassing | 136 // NetworkDelegate implementations should consider subclassing |
134 // NetworkDelegateImpl.) | 137 // NetworkDelegateImpl.) |
135 | 138 |
136 // Called before a request is sent. Allows the delegate to rewrite the URL | 139 // Called before a request is sent. Allows the delegate to rewrite the URL |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 virtual bool OnCanSetReportingClient(const url::Origin& origin, | 318 virtual bool OnCanSetReportingClient(const url::Origin& origin, |
316 const GURL& endpoint) const = 0; | 319 const GURL& endpoint) const = 0; |
317 | 320 |
318 virtual bool OnCanUseReportingClient(const url::Origin& origin, | 321 virtual bool OnCanUseReportingClient(const url::Origin& origin, |
319 const GURL& endpoint) const = 0; | 322 const GURL& endpoint) const = 0; |
320 }; | 323 }; |
321 | 324 |
322 } // namespace net | 325 } // namespace net |
323 | 326 |
324 #endif // NET_BASE_NETWORK_DELEGATE_H_ | 327 #endif // NET_BASE_NETWORK_DELEGATE_H_ |
OLD | NEW |