Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/threading/non_thread_safe.h" | 9 #include "base/threading/non_thread_safe.h" |
| 10 #include "net/base/completion_callback.h" | 10 #include "net/base/completion_callback.h" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 | 27 |
| 28 class NetworkDelegate : public base::NonThreadSafe { | 28 class NetworkDelegate : public base::NonThreadSafe { |
| 29 public: | 29 public: |
| 30 virtual ~NetworkDelegate() {} | 30 virtual ~NetworkDelegate() {} |
| 31 | 31 |
| 32 // Notification interface called by the network stack. Note that these | 32 // Notification interface called by the network stack. Note that these |
| 33 // functions mostly forward to the private virtuals. They also add some sanity | 33 // functions mostly forward to the private virtuals. They also add some sanity |
| 34 // checking on parameters. | 34 // checking on parameters. |
| 35 bool NotifyBeforeURLRequest(URLRequest* request, | 35 bool NotifyBeforeURLRequest(URLRequest* request, |
| 36 CompletionCallback* callback); | 36 CompletionCallback* callback); |
| 37 void NotifySendHttpRequest(HttpRequestHeaders* headers); | 37 bool NotifyBeforeSendHeaders(uint64 request_id, |
|
rvargas (doing something else)
2011/03/24 18:16:03
Given that this is part of the network interface,
Matt Perry
2011/03/24 22:10:53
Done.
| |
| 38 HttpRequestHeaders* headers, | |
| 39 CompletionCallback* callback); | |
| 38 void NotifyResponseStarted(URLRequest* request); | 40 void NotifyResponseStarted(URLRequest* request); |
| 39 void NotifyReadCompleted(URLRequest* request, int bytes_read); | 41 void NotifyReadCompleted(URLRequest* request, int bytes_read); |
| 40 | 42 |
| 41 // Returns a URLRequestJob that will be used to handle the request if | 43 // Returns a URLRequestJob that will be used to handle the request if |
| 42 // non-null. | 44 // non-null. |
| 43 // TODO(koz): Currently this is called inside registered ProtocolFactories, | 45 // TODO(koz): Currently this is called inside registered ProtocolFactories, |
| 44 // so that we can perform Delegate-dependent request handling from the static | 46 // so that we can perform Delegate-dependent request handling from the static |
| 45 // factories, but ultimately it should be called directly from | 47 // factories, but ultimately it should be called directly from |
| 46 // URLRequestJobManager::CreateJob() as a general override mechanism. | 48 // URLRequestJobManager::CreateJob() as a general override mechanism. |
| 47 URLRequestJob* MaybeCreateURLRequestJob(URLRequest* request); | 49 URLRequestJob* MaybeCreateURLRequestJob(URLRequest* request); |
| 48 | 50 |
| 51 void NotifyURLRequestDestroyed(URLRequest* request); | |
| 52 | |
| 49 private: | 53 private: |
| 50 // This is the interface for subclasses of NetworkDelegate to implement. This | 54 // This is the interface for subclasses of NetworkDelegate to implement. This |
| 51 // member functions will be called by the respective public notification | 55 // member functions will be called by the respective public notification |
| 52 // member function, which will perform basic sanity checking. | 56 // member function, which will perform basic sanity checking. |
| 53 | 57 |
| 54 // Called before a request is sent. | 58 // Called before a request is sent. The callback can be called at any time, |
| 59 // but will have no effect if the request has already been cancelled or | |
| 60 // deleted. | |
| 55 virtual bool OnBeforeURLRequest(URLRequest* request, | 61 virtual bool OnBeforeURLRequest(URLRequest* request, |
| 56 CompletionCallback* callback) = 0; | 62 CompletionCallback* callback) = 0; |
| 57 | 63 |
| 58 // Called right before the HTTP headers are sent. Allows the delegate to | 64 // Called right before the HTTP headers are sent. Allows the delegate to |
| 59 // read/write |headers| before they get sent out. | 65 // read/write |headers| before they get sent out. The callback can be called |
| 60 virtual void OnSendHttpRequest(HttpRequestHeaders* headers) = 0; | 66 // at any time, but will have no effect if the transaction handling this |
| 67 // request has been cancelled. | |
| 68 virtual bool OnBeforeSendHeaders(uint64 request_id, | |
| 69 HttpRequestHeaders* headers, | |
| 70 CompletionCallback* callback) = 0; | |
| 61 | 71 |
| 62 // This corresponds to URLRequestDelegate::OnResponseStarted. | 72 // This corresponds to URLRequestDelegate::OnResponseStarted. |
| 63 virtual void OnResponseStarted(URLRequest* request) = 0; | 73 virtual void OnResponseStarted(URLRequest* request) = 0; |
| 64 | 74 |
| 65 // This corresponds to URLRequestDelegate::OnReadCompleted. | 75 // This corresponds to URLRequestDelegate::OnReadCompleted. |
| 66 virtual void OnReadCompleted(URLRequest* request, int bytes_read) = 0; | 76 virtual void OnReadCompleted(URLRequest* request, int bytes_read) = 0; |
| 67 | 77 |
| 68 // Called before a request is sent and before a URLRequestJob is created to | 78 // Called before a request is sent and before a URLRequestJob is created to |
| 69 // handle the request. | 79 // handle the request. |
| 70 virtual URLRequestJob* OnMaybeCreateURLRequestJob(URLRequest* request) = 0; | 80 virtual URLRequestJob* OnMaybeCreateURLRequestJob(URLRequest* request) = 0; |
| 81 | |
| 82 // Called when an URLRequest is being destroyed. | |
| 83 virtual void OnURLRequestDestroyed(URLRequest* request) = 0; | |
| 71 }; | 84 }; |
| 72 | 85 |
| 73 } // namespace net | 86 } // namespace net |
| 74 | 87 |
| 75 #endif // NET_BASE_NETWORK_DELEGATE_H_ | 88 #endif // NET_BASE_NETWORK_DELEGATE_H_ |
| OLD | NEW |