Notify NetworkDelegate when bytes have been received over the network.
This will allow for network delegates to notify observers when network
usage occurs, for up-to-date accounting of data usage. See bug for more
details.
This change also removes the NetworkDelegate::OnRawBytesRead method,
replacing it with this new NetworkDelgate::OnNetworkBytesReceived
method.
BUG=518051
Review URL: https://codereview.chromium.org/1284993005
Cr-Commit-Position: refs/heads/master@{#345163}
diff --git a/net/base/network_delegate.h b/net/base/network_delegate.h
index e7ee964..715d8943 100644
--- a/net/base/network_delegate.h
+++ b/net/base/network_delegate.h
@@ -5,6 +5,8 @@
#ifndef NET_BASE_NETWORK_DELEGATE_H_
#define NET_BASE_NETWORK_DELEGATE_H_
+#include <stdint.h>
+
#include <string>
#include "base/callback.h"
@@ -85,7 +87,8 @@
void NotifyBeforeRedirect(URLRequest* request,
const GURL& new_location);
void NotifyResponseStarted(URLRequest* request);
- void NotifyRawBytesRead(const URLRequest& request, int bytes_read);
+ void NotifyNetworkBytesReceived(const URLRequest& request,
+ int64_t bytes_received);
void NotifyCompleted(URLRequest* request, bool started);
void NotifyURLRequestDestroyed(URLRequest* request);
void NotifyPACScriptError(int line_number, const base::string16& error);
@@ -198,8 +201,16 @@
// This corresponds to URLRequestDelegate::OnResponseStarted.
virtual void OnResponseStarted(URLRequest* request) = 0;
- // Called every time we read raw bytes.
- virtual void OnRawBytesRead(const URLRequest& request, int bytes_read) = 0;
+ // Called when bytes are received from the network, such as after receiving
+ // headers or reading raw response bytes. This includes localhost requests.
+ // |bytes_received| is the number of bytes measured at the application layer
+ // that have been received over the network for this request since the last
+ // time OnNetworkBytesReceived was called. |bytes_received| will always be
+ // greater than 0.
+ // Currently, this is only implemented for HTTP transactions, and
+ // |bytes_received| does not include TLS overhead or TCP retransmits.
+ virtual void OnNetworkBytesReceived(const URLRequest& request,
+ int64_t bytes_received) = 0;
// Indicates that the URL request has been completed or failed.
// |started| indicates whether the request has been started. If false,