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

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

Issue 2595503002: Record the data use by content type (Closed)
Patch Set: fixed nits Created 4 years 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
Index: components/data_use_measurement/core/data_use_network_delegate_unittest.cc
diff --git a/components/data_use_measurement/core/data_use_network_delegate_unittest.cc b/components/data_use_measurement/core/data_use_network_delegate_unittest.cc
index eef737fd8864f7578d3111a46f5e118e81c4eb1c..ede1347dc5fc51fbe38800e8eca47e04b1f5a071 100644
--- a/components/data_use_measurement/core/data_use_network_delegate_unittest.cc
+++ b/components/data_use_measurement/core/data_use_network_delegate_unittest.cc
@@ -20,8 +20,8 @@ namespace data_use_measurement {
namespace {
-class UserRequestUserDataForTesting : public base::SupportsUserData::Data,
- public URLRequestClassifier {
+class TestURLRequestClassifier : public base::SupportsUserData::Data,
+ public URLRequestClassifier {
public:
static const void* const kUserDataKey;
@@ -30,7 +30,13 @@ class UserRequestUserDataForTesting : public base::SupportsUserData::Data,
}
static void MarkAsUserRequest(net::URLRequest* request) {
- request->SetUserData(kUserDataKey, new UserRequestUserDataForTesting());
+ request->SetUserData(kUserDataKey, new TestURLRequestClassifier());
+ }
+
+ DataUseUserData::DataUseContentType GetContentType(
+ const net::URLRequest& request,
+ const net::HttpResponseHeaders& response_headers) const override {
+ return DataUseUserData::OTHER;
}
};
@@ -53,8 +59,8 @@ class TestDataUseAscriber : public DataUseAscriber {
};
// static
-const void* const UserRequestUserDataForTesting::kUserDataKey =
- &UserRequestUserDataForTesting::kUserDataKey;
+const void* const TestURLRequestClassifier::kUserDataKey =
+ &TestURLRequestClassifier::kUserDataKey;
// This function requests a URL, and makes it return a known response. If
// |from_user| is true, it attaches a ResourceRequestInfo to the URLRequest,
@@ -91,7 +97,7 @@ std::unique_ptr<net::URLRequest> RequestURL(
GURL("http://example.com"), net::DEFAULT_PRIORITY, &test_delegate));
if (from_user) {
- UserRequestUserDataForTesting::MarkAsUserRequest(request.get());
+ TestURLRequestClassifier::MarkAsUserRequest(request.get());
} else {
request->SetUserData(
data_use_measurement::DataUseUserData::kUserDataKey,
@@ -108,11 +114,10 @@ class DataUseNetworkDelegateTest : public testing::Test {
public:
DataUseNetworkDelegateTest()
: context_(true),
- data_use_network_delegate_(
- base::MakeUnique<net::TestNetworkDelegate>(),
- &test_data_use_ascriber_,
- base::MakeUnique<UserRequestUserDataForTesting>(),
- metrics::UpdateUsagePrefCallbackType()) {
+ data_use_network_delegate_(base::MakeUnique<net::TestNetworkDelegate>(),
+ &test_data_use_ascriber_,
+ base::MakeUnique<TestURLRequestClassifier>(),
+ metrics::UpdateUsagePrefCallbackType()) {
context_.set_client_socket_factory(&mock_socket_factory_);
context_.set_network_delegate(&data_use_network_delegate_);
context_.Init();

Powered by Google App Engine
This is Rietveld 408576698