Skip to content

Commit

Permalink
Revert "Reland "Added network stats to GetActions RPC.""
Browse files Browse the repository at this point in the history
This reverts commit 4dca819.

Reason for revert:
Findit (https://goo.gl/kROfz5) identified this CL at revision 4dca819 as
the culprit for failures in the continuous build including:

Sample Failed Build: https://ci.chromium.org/b/8817802619839813777
Sample Failed Step: compile

If it is a false positive, please report it at https://bugs.chromium.org/p/chromium/issues/entry?status=Available&comment=Datastore+key+for+the+culprit+entity%3A+chromium.googlesource.com%2Fchromium%2Fsrc%2Frefs%2Fheads%2Fmain%2F4dca819619e3ec4129a5112ab836596f5a2230da&labels=Test-Findit-Wrong&components=Tools%3ETest%3EFindIt&summary=Wrongly+blame+4dca819619e3ec4129a5112ab836596f5a2230da

Original change's description:
> Reland "Added network stats to GetActions RPC."
>
> This is a reland of commit e31ba27
>
> Fixed type conversion warnings.
>
> Original change's description:
> > Added network stats to GetActions RPC.
> >
> > NextScriptActions requests will now contain some basic stats on the
> > network cost incurred by the previously received action response. This
> > is added to allow tracking the impact of client-side-execution on
> > overall response sizes, both per-response and aggregated over the
> > entire flow.
> >
> > Also cleaned up MockService and ProtocolUtilsTest.
> >
> > Bug: b/201970915
> > Change-Id: I6af7dea7f94dd40bc7de0fb6e726ba997a777949
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3545250
> > Reviewed-by: Luca Hunkeler <hluca@google.com>
> > Reviewed-by: Florian Gauger <fga@google.com>
> > Commit-Queue: Clemens Arbesser <arbesser@google.com>
> > Cr-Commit-Position: refs/heads/main@{#987899}
>
> Bug: b/201970915
> Change-Id: I967b42b2f7cb132866e13324058f4027da6ddad4
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3568162
> Reviewed-by: Luca Hunkeler <hluca@google.com>
> Commit-Queue: Clemens Arbesser <arbesser@google.com>
> Cr-Commit-Position: refs/heads/main@{#988498}


Change-Id: I60346d918a9a381cc6e4b3d956d0a539e636465b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: b/201970915, 1313078
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3569364
Reviewed-by: Lijin Shen <lazzzis@google.com>
Owners-Override: Lijin Shen <lazzzis@google.com>
Reviewed-by: Anthony Vallée-Dubois <anthonyvd@chromium.org>
Commit-Queue: Lijin Shen <lazzzis@google.com>
Cr-Commit-Position: refs/heads/main@{#988572}
  • Loading branch information
Findit authored and Chromium LUCI CQ committed Apr 4, 2022
1 parent 84dc75c commit 19e7a5a
Show file tree
Hide file tree
Showing 20 changed files with 387 additions and 494 deletions.
101 changes: 51 additions & 50 deletions components/autofill_assistant/browser/controller_unittest.cc

Large diffs are not rendered by default.

24 changes: 0 additions & 24 deletions components/autofill_assistant/browser/protocol_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ std::string ProtocolUtils::CreateNextScriptActionsRequest(
const std::string& script_payload,
const std::vector<ProcessedActionProto>& processed_actions,
const RoundtripTimingStats& timing_stats,
const RoundtripNetworkStats& network_stats,
const ClientContextProto& client_context) {
ScriptActionRequestProto request_proto;
request_proto.set_global_payload(global_payload);
Expand All @@ -212,7 +211,6 @@ std::string ProtocolUtils::CreateNextScriptActionsRequest(
next_request->add_processed_actions()->MergeFrom(processed_action);
}
*next_request->mutable_timing_stats() = timing_stats;
*next_request->mutable_network_stats() = network_stats;
*request_proto.mutable_client_context() = client_context;
std::string serialized_request_proto;
bool success = request_proto.SerializeToString(&serialized_request_proto);
Expand Down Expand Up @@ -968,26 +966,4 @@ std::string ProtocolUtils::CreateGetUserDataRequest(
return serialized_request_proto;
}

// static
RoundtripNetworkStats ProtocolUtils::ComputeNetworkStats(
const std::string& response,
const ServiceRequestSender::ResponseInfo& response_info,
const std::vector<std::unique_ptr<Action>>& actions) {
RoundtripNetworkStats stats;
stats.set_roundtrip_decoded_body_size_bytes(response.size());
stats.set_roundtrip_encoded_body_size_bytes(
response_info.encoded_body_length);
for (const auto& action : actions) {
RoundtripNetworkStats::ActionNetworkStats* action_stats =
stats.add_action_stats();
action_stats->set_action_info_case(
static_cast<int>(action->proto().action_info_case()));

std::string serialized_action;
action->proto().SerializeToString(&serialized_action);
action_stats->set_decoded_size_bytes(serialized_action.size());
}
return stats;
}

} // namespace autofill_assistant
9 changes: 0 additions & 9 deletions components/autofill_assistant/browser/protocol_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "components/autofill_assistant/browser/script.h"
#include "components/autofill_assistant/browser/script_parameters.h"
#include "components/autofill_assistant/browser/service.pb.h"
#include "components/autofill_assistant/browser/service/service_request_sender.h"
#include "components/autofill_assistant/browser/trigger_scripts/trigger_script.h"
#include "third_party/abseil-cpp/absl/types/optional.h"

Expand Down Expand Up @@ -65,7 +64,6 @@ class ProtocolUtils {
const std::string& script_payload,
const std::vector<ProcessedActionProto>& processed_actions,
const RoundtripTimingStats& timing_stats,
const RoundtripNetworkStats& network_stats,
const ClientContextProto& client_context);

// Create request to get the available trigger scripts for |url|.
Expand Down Expand Up @@ -133,13 +131,6 @@ class ProtocolUtils {
absl::optional<int>* trigger_condition_timeout_ms,
absl::optional<std::unique_ptr<ScriptParameters>>* script_parameters);

// Computes network stats for a roundtrip that returned |response| and
// |response_info|, which were successfully parsed into |actions|.
static RoundtripNetworkStats ComputeNetworkStats(
const std::string& response,
const ServiceRequestSender::ResponseInfo& response_info,
const std::vector<std::unique_ptr<Action>>& actions);

private:
// Checks that the |trigger_condition| is well-formed (e.g. does not contain
// regexes that cannot be compiled).
Expand Down
71 changes: 18 additions & 53 deletions components/autofill_assistant/browser/protocol_utils_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ class ProtocolUtilsTest : public testing::Test {
ClientContextProto client_context_proto_;
};

void AssertClientContext(const ClientContextProto& context) {
EXPECT_EQ("1,2,3", context.experiment_ids());
EXPECT_TRUE(context.is_cct());
EXPECT_EQ("v", context.chrome().chrome_version());
EXPECT_EQ(1, context.device_context().version().sdk_int());
EXPECT_EQ("ma", context.device_context().manufacturer());
EXPECT_EQ("mo", context.device_context().model());
EXPECT_FALSE(context.is_onboarding_shown());
EXPECT_FALSE(context.is_direct_action());
EXPECT_THAT(context.accounts_matching_status(),
Eq(ClientContextProto::UNKNOWN));
}

TEST_F(ProtocolUtilsTest, ScriptMissingPath) {
SupportedScriptProto script;
std::vector<std::unique_ptr<Script>> scripts;
Expand Down Expand Up @@ -115,7 +128,7 @@ TEST_F(ProtocolUtilsTest, CreateInitialScriptActionsRequest) {
EXPECT_THAT(initial.script_parameters(),
UnorderedElementsAreArray(parameters.ToProto()));

EXPECT_EQ(request.client_context(), client_context_proto_);
AssertClientContext(request.client_context());
EXPECT_EQ("global_payload", request.global_payload());
EXPECT_EQ("script_payload", request.script_payload());
EXPECT_EQ("bundle/path", initial.script_store_config().bundle_path());
Expand All @@ -126,24 +139,12 @@ TEST_F(ProtocolUtilsTest, CreateNextScriptActionsRequest) {
ScriptActionRequestProto request;
std::vector<ProcessedActionProto> processed_actions;
processed_actions.emplace_back(ProcessedActionProto());

RoundtripNetworkStats network_stats;
network_stats.set_roundtrip_encoded_body_size_bytes(12345);
network_stats.set_roundtrip_decoded_body_size_bytes(23456);
auto* action_stats = network_stats.add_action_stats();
action_stats->set_action_info_case(5);
action_stats->set_decoded_size_bytes(35);
action_stats = network_stats.add_action_stats();
action_stats->set_action_info_case(7);
action_stats->set_decoded_size_bytes(15);

EXPECT_TRUE(
request.ParseFromString(ProtocolUtils::CreateNextScriptActionsRequest(
"global_payload", "script_payload", processed_actions,
RoundtripTimingStats(), network_stats, client_context_proto_)));
RoundtripTimingStats(), client_context_proto_)));

EXPECT_EQ(request.client_context(), client_context_proto_);
EXPECT_EQ(request.next_request().network_stats(), network_stats);
AssertClientContext(request.client_context());
EXPECT_EQ(1, request.next_request().processed_actions().size());
}

Expand All @@ -153,7 +154,7 @@ TEST_F(ProtocolUtilsTest, CreateGetScriptsRequest) {
EXPECT_TRUE(request.ParseFromString(ProtocolUtils::CreateGetScriptsRequest(
GURL("http://example.com/"), client_context_proto_, parameters)));

EXPECT_EQ(request.client_context(), client_context_proto_);
AssertClientContext(request.client_context());
EXPECT_THAT(request.script_parameters(),
UnorderedElementsAreArray(parameters.ToProto()));
EXPECT_EQ("http://example.com/", request.url());
Expand Down Expand Up @@ -343,7 +344,7 @@ TEST_F(ProtocolUtilsTest, CreateGetTriggerScriptsRequest) {
request.ParseFromString(ProtocolUtils::CreateGetTriggerScriptsRequest(
GURL("http://example.com/"), client_context_proto_, parameters)));

EXPECT_EQ(request.client_context(), client_context_proto_);
AssertClientContext(request.client_context());
EXPECT_THAT(request.script_parameters(),
UnorderedElementsAreArray(
ScriptParameters(base::flat_map<std::string, std::string>{
Expand Down Expand Up @@ -628,40 +629,4 @@ TEST_F(ProtocolUtilsTest, CreateGetUserDataRequest) {
ElementsAre("VISA", "MASTERCARD"));
}

TEST_F(ProtocolUtilsTest, ComputeNetworkStats) {
ActionProto tell_action;
tell_action.mutable_tell()->set_message("Hello world!");
std::string serialized_tell_action;
tell_action.SerializeToString(&serialized_tell_action);

ActionProto stop_action;
stop_action.mutable_stop()->set_close_cct(false);
std::string serialized_stop_action;
stop_action.SerializeToString(&serialized_stop_action);

std::vector<std::unique_ptr<Action>> actions;
actions.push_back(ProtocolUtils::ParseAction(/* delegate = */ nullptr,
serialized_tell_action));
actions.push_back(ProtocolUtils::ParseAction(/* delegate = */ nullptr,
serialized_stop_action));

ServiceRequestSender::ResponseInfo response_info;
response_info.encoded_body_length = 20;

RoundtripNetworkStats expected_stats;
expected_stats.set_roundtrip_encoded_body_size_bytes(20);
expected_stats.set_roundtrip_decoded_body_size_bytes(28);
auto* action_stats = expected_stats.add_action_stats();
action_stats->set_action_info_case(11); // == tell
action_stats->set_decoded_size_bytes(serialized_tell_action.size());
action_stats = expected_stats.add_action_stats();
action_stats->set_action_info_case(35); // == stop
action_stats->set_decoded_size_bytes(serialized_stop_action.size());

EXPECT_EQ(ProtocolUtils::ComputeNetworkStats(
/* response = */ "This string is 28 bytes long", response_info,
actions),
expected_stats);
}

} // namespace autofill_assistant
12 changes: 4 additions & 8 deletions components/autofill_assistant/browser/script_executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -822,8 +822,8 @@ void ScriptExecutor::OnGetActions(
// Doesn't trigger when the script is completed.
roundtrip_timing_stats_.set_roundtrip_time_ms(
roundtrip_duration.InMilliseconds());
bool success = http_status == net::HTTP_OK &&
ProcessNextActionResponse(response, response_info);
bool success =
http_status == net::HTTP_OK && ProcessNextActionResponse(response);
if (should_stop_script_) {
// The last action forced the script to stop. Sending the result of the
// action is considered best effort in this situation. Report a successful
Expand Down Expand Up @@ -858,9 +858,7 @@ void ScriptExecutor::OnGetActions(
RunCallback(true);
}

bool ScriptExecutor::ProcessNextActionResponse(
const std::string& response,
const ServiceRequestSender::ResponseInfo& response_info) {
bool ScriptExecutor::ProcessNextActionResponse(const std::string& response) {
processed_actions_.clear();
actions_.clear();

Expand All @@ -873,8 +871,6 @@ bool ScriptExecutor::ProcessNextActionResponse(
return false;
}

roundtrip_network_stats_ =
ProtocolUtils::ComputeNetworkStats(response, response_info, actions_);
ReportPayloadsToListener();
if (should_update_scripts) {
ReportScriptsUpdateToListener(std::move(scripts));
Expand Down Expand Up @@ -969,7 +965,7 @@ void ScriptExecutor::GetNextActions() {
TriggerContext(
{delegate_->GetTriggerContext(), additional_context_.get()}),
last_global_payload_, last_script_payload_, processed_actions_,
roundtrip_timing_stats_, roundtrip_network_stats_,
roundtrip_timing_stats_,
base::BindOnce(&ScriptExecutor::OnGetActions,
weak_ptr_factory_.GetWeakPtr(), get_next_actions_start));
}
Expand Down
5 changes: 1 addition & 4 deletions components/autofill_assistant/browser/script_executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,7 @@ class ScriptExecutor : public ActionDelegate,
int http_status,
const std::string& response,
const ServiceRequestSender::ResponseInfo& response_info);
bool ProcessNextActionResponse(
const std::string& response,
const ServiceRequestSender::ResponseInfo& response_info);
bool ProcessNextActionResponse(const std::string& response);
void ReportPayloadsToListener();
void ReportScriptsUpdateToListener(
std::vector<std::unique_ptr<Script>> scripts);
Expand Down Expand Up @@ -394,7 +392,6 @@ class ScriptExecutor : public ActionDelegate,

base::TimeTicks batch_start_time_;
RoundtripTimingStats roundtrip_timing_stats_;
RoundtripNetworkStats roundtrip_network_stats_;

bool connection_warning_already_shown_ = false;
bool website_warning_already_shown_ = false;
Expand Down

0 comments on commit 19e7a5a

Please sign in to comment.