Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Unified Diff: components/data_use_measurement/core/data_use_network_delegate.cc

Issue 2354323002: Propagate network delegate events to ChromeDataUseAscriber. (Closed)
Patch Set: new lines Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/data_use_measurement/core/data_use_network_delegate.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/data_use_measurement/core/data_use_network_delegate.cc
diff --git a/components/data_use_measurement/core/data_use_network_delegate.cc b/components/data_use_measurement/core/data_use_network_delegate.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e7cb035ab08b61daec1763aecb1c38866393bb96
--- /dev/null
+++ b/components/data_use_measurement/core/data_use_network_delegate.cc
@@ -0,0 +1,54 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/data_use_measurement/core/data_use_network_delegate.h"
+
+#include <memory>
+#include <utility>
+
+#include "components/data_use_measurement/core/data_use_ascriber.h"
+#include "net/url_request/url_request.h"
+
+namespace data_use_measurement {
+DataUseNetworkDelegate::DataUseNetworkDelegate(
+ std::unique_ptr<NetworkDelegate> nested_network_delegate,
+ DataUseAscriber* ascriber)
+ : net::LayeredNetworkDelegate(std::move(nested_network_delegate)),
+ ascriber_(ascriber) {
+ DCHECK(ascriber);
+}
+
+DataUseNetworkDelegate::~DataUseNetworkDelegate() {}
+
+void DataUseNetworkDelegate::OnBeforeURLRequestInternal(
+ net::URLRequest* request,
+ const net::CompletionCallback& callback,
+ GURL* new_url) {
+ ascriber_->OnBeforeUrlRequest(request);
+}
+
+void DataUseNetworkDelegate::OnBeforeRedirectInternal(
+ net::URLRequest* request,
+ const GURL& new_location) {
+ ascriber_->OnBeforeRedirect(request, new_location);
+}
+
+void DataUseNetworkDelegate::OnNetworkBytesReceivedInternal(
+ net::URLRequest* request,
+ int64_t bytes_received) {
+ ascriber_->OnNetworkBytesReceived(request, bytes_received);
+}
+
+void DataUseNetworkDelegate::OnNetworkBytesSentInternal(
+ net::URLRequest* request,
+ int64_t bytes_sent) {
+ ascriber_->OnNetworkBytesSent(request, bytes_sent);
+}
+
+void DataUseNetworkDelegate::OnCompletedInternal(net::URLRequest* request,
+ bool started) {
+ ascriber_->OnUrlRequestCompleted(request, started);
+}
+
+} // namespace data_use_measurement
« no previous file with comments | « components/data_use_measurement/core/data_use_network_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698