Commit deae3258 authored by Lev Rumyantsev's avatar Lev Rumyantsev Committed by Commit Bot

arc: Receive NativeBridge metric from container

We will record it for UMA as the next step.

BUG=b:63134383
TEST=Debug print and check the received value.

Change-Id: If7590ceacfed4328ccead78922d44976ac29d9ff
Reviewed-on: https://chromium-review.googlesource.com/802998
Commit-Queue: Lev Rumyantsev <levarum@chromium.org>
Reviewed-by: default avatarJorge Lucangeli Obes <jorgelo@chromium.org>
Reviewed-by: default avatarYusuke Sato <yusukes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522007}
parent a9c769de
// Copyright 2016 The Chromium Authors. All rights reserved. // Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Next MinVersion: 3 // Next MinVersion: 4
module arc.mojom; module arc.mojom;
...@@ -39,11 +39,24 @@ struct BootProgressEvent { ...@@ -39,11 +39,24 @@ struct BootProgressEvent {
int64 uptimeMillis; int64 uptimeMillis;
}; };
// Next method ID: 1 [Extensible]
enum NativeBridgeType {
// Native bridge is not used.
NONE = 0,
// Using houdini translator.
HOUDINI = 1,
// Using ndk-translation translator.
NDK_TRANSLATION = 2,
};
// Next method ID: 2
interface MetricsHost { interface MetricsHost {
// Report boot progress events from ARC instance. // Reports boot progress events from ARC instance.
ReportBootProgress@0(array<BootProgressEvent> events, ReportBootProgress@0(array<BootProgressEvent> events,
[MinVersion=1] BootType boot_type); [MinVersion=1] BootType boot_type);
// Reports native bridge used by ARC instance.
[MinVersion=3] ReportNativeBridge@1(NativeBridgeType native_bridge_type);
}; };
// Next method ID: 2 // Next method ID: 2
......
...@@ -82,6 +82,7 @@ ArcMetricsService::ArcMetricsService(content::BrowserContext* context, ...@@ -82,6 +82,7 @@ ArcMetricsService::ArcMetricsService(content::BrowserContext* context,
ArcBridgeService* bridge_service) ArcBridgeService* bridge_service)
: arc_bridge_service_(bridge_service), : arc_bridge_service_(bridge_service),
process_observer_(this), process_observer_(this),
native_bridge_type_(NativeBridgeType::UNKNOWN),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
arc_bridge_service_->metrics()->SetHost(this); arc_bridge_service_->metrics()->SetHost(this);
arc_bridge_service_->process()->AddObserver(&process_observer_); arc_bridge_service_->process()->AddObserver(&process_observer_);
...@@ -188,6 +189,25 @@ void ArcMetricsService::ReportBootProgress( ...@@ -188,6 +189,25 @@ void ArcMetricsService::ReportBootProgress(
weak_ptr_factory_.GetWeakPtr(), std::move(events), boot_type)); weak_ptr_factory_.GetWeakPtr(), std::move(events), boot_type));
} }
void ArcMetricsService::ReportNativeBridge(
mojom::NativeBridgeType native_bridge_type) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
VLOG(2) << "Mojo native bridge type is " << native_bridge_type;
switch (native_bridge_type) {
case mojom::NativeBridgeType::NONE:
native_bridge_type_ = NativeBridgeType::NONE;
return;
case mojom::NativeBridgeType::HOUDINI:
native_bridge_type_ = NativeBridgeType::HOUDINI;
return;
case mojom::NativeBridgeType::NDK_TRANSLATION:
native_bridge_type_ = NativeBridgeType::NDK_TRANSLATION;
return;
}
NOTREACHED() << native_bridge_type;
}
ArcMetricsService::ProcessObserver::ProcessObserver( ArcMetricsService::ProcessObserver::ProcessObserver(
ArcMetricsService* arc_metrics_service) ArcMetricsService* arc_metrics_service)
: arc_metrics_service_(arc_metrics_service) {} : arc_metrics_service_(arc_metrics_service) {}
......
...@@ -31,6 +31,19 @@ class ArcBridgeService; ...@@ -31,6 +31,19 @@ class ArcBridgeService;
class ArcMetricsService : public KeyedService, class ArcMetricsService : public KeyedService,
public mojom::MetricsHost { public mojom::MetricsHost {
public: public:
// This is public for testing only.
enum class NativeBridgeType {
// Native bridge value has not been received from the container yet.
UNKNOWN = 0,
// Native bridge is not used.
NONE = 1,
// Using houdini translator.
HOUDINI = 2,
// Using ndk-translation translator.
NDK_TRANSLATION = 3,
COUNT
};
// Returns the factory instance for this class. // Returns the factory instance for this class.
static BrowserContextKeyedServiceFactory* GetFactory(); static BrowserContextKeyedServiceFactory* GetFactory();
...@@ -50,6 +63,11 @@ class ArcMetricsService : public KeyedService, ...@@ -50,6 +63,11 @@ class ArcMetricsService : public KeyedService,
// MetricsHost overrides. // MetricsHost overrides.
void ReportBootProgress(std::vector<mojom::BootProgressEventPtr> events, void ReportBootProgress(std::vector<mojom::BootProgressEventPtr> events,
mojom::BootType boot_type) override; mojom::BootType boot_type) override;
void ReportNativeBridge(mojom::NativeBridgeType native_bridge_type) override;
NativeBridgeType native_bridge_type_for_testing() const {
return native_bridge_type_;
}
private: private:
// Adapter to be able to also observe ProcessInstance events. // Adapter to be able to also observe ProcessInstance events.
...@@ -83,6 +101,8 @@ class ArcMetricsService : public KeyedService, ...@@ -83,6 +101,8 @@ class ArcMetricsService : public KeyedService,
ProcessObserver process_observer_; ProcessObserver process_observer_;
base::RepeatingTimer timer_; base::RepeatingTimer timer_;
NativeBridgeType native_bridge_type_;
// Always keep this the last member of this class to make sure it's the // Always keep this the last member of this class to make sure it's the
// first thing to be destructed. // first thing to be destructed.
base::WeakPtrFactory<ArcMetricsService> weak_ptr_factory_; base::WeakPtrFactory<ArcMetricsService> weak_ptr_factory_;
......
...@@ -224,5 +224,20 @@ TEST_F(ArcMetricsServiceTest, ReportBootProgress_InvalidBootType) { ...@@ -224,5 +224,20 @@ TEST_F(ArcMetricsServiceTest, ReportBootProgress_InvalidBootType) {
} }
} }
TEST_F(ArcMetricsServiceTest, ReportNativeBridge) {
EXPECT_EQ(metrics_service()->native_bridge_type_for_testing(),
ArcMetricsService::NativeBridgeType::UNKNOWN);
metrics_service()->ReportNativeBridge(mojom::NativeBridgeType::NONE);
EXPECT_EQ(metrics_service()->native_bridge_type_for_testing(),
ArcMetricsService::NativeBridgeType::NONE);
metrics_service()->ReportNativeBridge(mojom::NativeBridgeType::HOUDINI);
EXPECT_EQ(metrics_service()->native_bridge_type_for_testing(),
ArcMetricsService::NativeBridgeType::HOUDINI);
metrics_service()->ReportNativeBridge(
mojom::NativeBridgeType::NDK_TRANSLATION);
EXPECT_EQ(metrics_service()->native_bridge_type_for_testing(),
ArcMetricsService::NativeBridgeType::NDK_TRANSLATION);
}
} // namespace } // namespace
} // namespace arc } // namespace arc
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