Commit 7b589285 authored by Ryan Sturm's avatar Ryan Sturm Committed by Commit Bot

Reland "Adding device memory in kb to the client config request"

(a) device info should be in the batch summary of the request for PLM
(b) I'd like separate Device Info messages in case they diverge, which seems like a distinct possibility.

Patchset 1 is what landed yesterday.

This is a reland of 1e920b32
Original change's description:
> Adding device memory in kb to the client config request
>
> pingback will also have this information
>
> Bug: 793373
> Change-Id: I0c999c35b5e968f6b2e19696a08a722b3399d0d9
> Reviewed-on: https://chromium-review.googlesource.com/823176
> Reviewed-by: Tarun Bansal <tbansal@chromium.org>
> Commit-Queue: Ryan Sturm <ryansturm@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#524203}

Bug: 793373
Change-Id: I4d3f6854b3b28c5c412388e27b0851e767e5f8b4
Reviewed-on: https://chromium-review.googlesource.com/830133Reviewed-by: default avatarDoug Arnett <dougarnett@chromium.org>
Commit-Queue: Ryan Sturm <ryansturm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#524441}
parent 9a9c9a9a
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "base/metrics/histogram_functions.h" #include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/sys_info.h"
#include "base/values.h" #include "base/values.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h"
...@@ -383,6 +384,11 @@ void DataReductionProxyConfigServiceClient::RetrieveRemoteConfig() { ...@@ -383,6 +384,11 @@ void DataReductionProxyConfigServiceClient::RetrieveRemoteConfig() {
request.set_telephony_network_operator( request.set_telephony_network_operator(
net::android::GetTelephonyNetworkOperator()); net::android::GetTelephonyNetworkOperator());
#endif #endif
data_reduction_proxy::ConfigDeviceInfo* device_info =
request.mutable_device_info();
device_info->set_total_device_memory_kb(
base::SysInfo::AmountOfPhysicalMemory() / 1024);
const std::string& session_key = request_options_->GetSecureSession(); const std::string& session_key = request_options_->GetSecureSession();
if (!session_key.empty()) if (!session_key.empty())
request.set_session_key(request_options_->GetSecureSession()); request.set_session_key(request_options_->GetSecureSession());
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/rand_util.h" #include "base/rand_util.h"
#include "base/sys_info.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_page_load_timing.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_page_load_timing.h"
...@@ -131,11 +132,15 @@ void AddDataToPageloadMetrics(const DataReductionProxyData& request_data, ...@@ -131,11 +132,15 @@ void AddDataToPageloadMetrics(const DataReductionProxyData& request_data,
// Adds |current_time| as the metrics sent time to |request_data|, and returns // Adds |current_time| as the metrics sent time to |request_data|, and returns
// the serialized request. // the serialized request.
std::string AddTimeAndSerializeRequest( std::string AddBatchInfoAndSerializeRequest(
RecordPageloadMetricsRequest* request_data, RecordPageloadMetricsRequest* request_data,
base::Time current_time) { base::Time current_time) {
request_data->set_allocated_metrics_sent_time( request_data->set_allocated_metrics_sent_time(
protobuf_parser::CreateTimestampFromTime(current_time).release()); protobuf_parser::CreateTimestampFromTime(current_time).release());
data_reduction_proxy::PageloadDeviceInfo* device_info =
request_data->mutable_device_info();
device_info->set_total_device_memory_kb(
base::SysInfo::AmountOfPhysicalMemory() / 1024);
std::string serialized_request; std::string serialized_request;
request_data->SerializeToString(&serialized_request); request_data->SerializeToString(&serialized_request);
return serialized_request; return serialized_request;
...@@ -185,7 +190,7 @@ void DataReductionProxyPingbackClient::CreateFetcherForDataAndStart() { ...@@ -185,7 +190,7 @@ void DataReductionProxyPingbackClient::CreateFetcherForDataAndStart() {
DCHECK(!current_fetcher_); DCHECK(!current_fetcher_);
DCHECK_GE(metrics_request_.pageloads_size(), 1); DCHECK_GE(metrics_request_.pageloads_size(), 1);
std::string serialized_request = std::string serialized_request =
AddTimeAndSerializeRequest(&metrics_request_, CurrentTime()); AddBatchInfoAndSerializeRequest(&metrics_request_, CurrentTime());
metrics_request_.Clear(); metrics_request_.Clear();
net::NetworkTrafficAnnotationTag traffic_annotation = net::NetworkTrafficAnnotationTag traffic_annotation =
net::DefineNetworkTrafficAnnotation("data_reduction_proxy_pingback", R"( net::DefineNetworkTrafficAnnotation("data_reduction_proxy_pingback", R"(
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "base/metrics/field_trial.h" #include "base/metrics/field_trial.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/sys_info.h"
#include "base/test/histogram_tester.h" #include "base/test/histogram_tester.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data.h"
...@@ -221,6 +222,9 @@ TEST_F(DataReductionProxyPingbackClientTest, VerifyPingbackContent) { ...@@ -221,6 +222,9 @@ TEST_F(DataReductionProxyPingbackClientTest, VerifyPingbackContent) {
PageloadMetrics_EffectiveConnectionType_EFFECTIVE_CONNECTION_TYPE_OFFLINE, PageloadMetrics_EffectiveConnectionType_EFFECTIVE_CONNECTION_TYPE_OFFLINE,
pageload_metrics.effective_connection_type()); pageload_metrics.effective_connection_type());
EXPECT_EQ(std::string(), pageload_metrics.holdback_group()); EXPECT_EQ(std::string(), pageload_metrics.holdback_group());
EXPECT_EQ(base::SysInfo::AmountOfPhysicalMemory() / 1024,
batched_request.device_info().total_device_memory_kb());
test_fetcher->delegate()->OnURLFetchComplete(test_fetcher); test_fetcher->delegate()->OnURLFetchComplete(test_fetcher);
histogram_tester().ExpectUniqueSample(kHistogramSucceeded, true, 1); histogram_tester().ExpectUniqueSample(kHistogramSucceeded, true, 1);
EXPECT_FALSE(factory()->GetFetcherByID(0)); EXPECT_FALSE(factory()->GetFetcherByID(0));
...@@ -293,6 +297,8 @@ TEST_F(DataReductionProxyPingbackClientTest, VerifyTwoPingbacksBatchedContent) { ...@@ -293,6 +297,8 @@ TEST_F(DataReductionProxyPingbackClientTest, VerifyTwoPingbacksBatchedContent) {
EXPECT_EQ(batched_request.pageloads_size(), 2); EXPECT_EQ(batched_request.pageloads_size(), 2);
EXPECT_EQ(current_time, protobuf_parser::TimestampToTime( EXPECT_EQ(current_time, protobuf_parser::TimestampToTime(
batched_request.metrics_sent_time())); batched_request.metrics_sent_time()));
EXPECT_EQ(base::SysInfo::AmountOfPhysicalMemory() / 1024,
batched_request.device_info().total_device_memory_kb());
// Verify the content of both pingbacks. // Verify the content of both pingbacks.
for (size_t i = 0; i < 2; ++i) { for (size_t i = 0; i < 2; ++i) {
......
...@@ -115,6 +115,12 @@ message ProxyServer { ...@@ -115,6 +115,12 @@ message ProxyServer {
optional ProxyType type = 4; optional ProxyType type = 4;
} }
// Information about the device the user is on.
message ConfigDeviceInfo {
// Kilobytes of total device memory.
optional int64 total_device_memory_kb = 1;
}
// Request object to create a client configuration object. // Request object to create a client configuration object.
message CreateClientConfigRequest { message CreateClientConfigRequest {
// An enum representing the type of user regarding whether they are dogfooding // An enum representing the type of user regarding whether they are dogfooding
...@@ -143,6 +149,9 @@ message CreateClientConfigRequest { ...@@ -143,6 +149,9 @@ message CreateClientConfigRequest {
// The DogfoodGroup of the user. // The DogfoodGroup of the user.
// Added in M65. // Added in M65.
optional DogfoodGroup dogfood_group = 4; optional DogfoodGroup dogfood_group = 4;
// Added in M65.
optional ConfigDeviceInfo device_info = 5;
} }
// Build version information. // Build version information.
......
...@@ -10,12 +10,21 @@ import "client_config.proto"; ...@@ -10,12 +10,21 @@ import "client_config.proto";
package data_reduction_proxy; package data_reduction_proxy;
// Information about the device the user is on.
message PageloadDeviceInfo {
// Kilobytes of total device memory.
optional int64 total_device_memory_kb = 1;
}
// Request message to record metrics for one or more pageloads. // Request message to record metrics for one or more pageloads.
message RecordPageloadMetricsRequest { message RecordPageloadMetricsRequest {
// The pageload metrics to record. // The pageload metrics to record.
repeated PageloadMetrics pageloads = 1; repeated PageloadMetrics pageloads = 1;
// Time metrics were sent. // Time metrics were sent.
optional Timestamp metrics_sent_time = 2; optional Timestamp metrics_sent_time = 2;
// Added in M65.
optional PageloadDeviceInfo device_info = 3;
} }
// Metrics for a single pageload. // Metrics for a single pageload.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment