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/sequence_checker.h" |
13 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
14 #include "base/threading/non_thread_safe.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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 const GURL& target_url, | 116 const GURL& target_url, |
117 const GURL& referrer_url) const; | 117 const GURL& referrer_url) const; |
118 | 118 |
119 bool CanQueueReportingReport(const url::Origin& origin) const; | 119 bool CanQueueReportingReport(const url::Origin& origin) const; |
120 bool CanSendReportingReport(const url::Origin& origin) const; | 120 bool CanSendReportingReport(const url::Origin& origin) const; |
121 bool CanSetReportingClient(const url::Origin& origin, | 121 bool CanSetReportingClient(const url::Origin& origin, |
122 const GURL& endpoint) const; | 122 const GURL& endpoint) const; |
123 bool CanUseReportingClient(const url::Origin& origin, | 123 bool CanUseReportingClient(const url::Origin& origin, |
124 const GURL& endpoint) const; | 124 const GURL& endpoint) const; |
125 | 125 |
| 126 protected: |
| 127 SEQUENCE_CHECKER(sequence_checker_); |
| 128 |
126 private: | 129 private: |
127 // This is the interface for subclasses of NetworkDelegate to implement. These | 130 // This is the interface for subclasses of NetworkDelegate to implement. These |
128 // member functions will be called by the respective public notification | 131 // member functions will be called by the respective public notification |
129 // member function, which will perform basic sanity checking. | 132 // member function, which will perform basic sanity checking. |
130 // | 133 // |
131 // (NetworkDelegateImpl has default implementations of these member functions. | 134 // (NetworkDelegateImpl has default implementations of these member functions. |
132 // NetworkDelegate implementations should consider subclassing | 135 // NetworkDelegate implementations should consider subclassing |
133 // NetworkDelegateImpl.) | 136 // NetworkDelegateImpl.) |
134 | 137 |
135 // Called before a request is sent. Allows the delegate to rewrite the URL | 138 // Called before a request is sent. Allows the delegate to rewrite the URL |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 virtual bool OnCanSetReportingClient(const url::Origin& origin, | 314 virtual bool OnCanSetReportingClient(const url::Origin& origin, |
312 const GURL& endpoint) const = 0; | 315 const GURL& endpoint) const = 0; |
313 | 316 |
314 virtual bool OnCanUseReportingClient(const url::Origin& origin, | 317 virtual bool OnCanUseReportingClient(const url::Origin& origin, |
315 const GURL& endpoint) const = 0; | 318 const GURL& endpoint) const = 0; |
316 }; | 319 }; |
317 | 320 |
318 } // namespace net | 321 } // namespace net |
319 | 322 |
320 #endif // NET_BASE_NETWORK_DELEGATE_H_ | 323 #endif // NET_BASE_NETWORK_DELEGATE_H_ |
OLD | NEW |