Switch to using shared_ptr for Session Metrics
[ Merge from http://go/wvgerrit/71443 ] The assumption that the metrics will always outlive the CdmSession instance appears not to always hold (at least in a non-android multi-threaded solution). The shared_ptr ensures that the metrics are available even in these rare race conditions. BUG: http://b/123321465 Test: CDM unit tests. Also http://go/wvgerrit/71264 parallel tests. Change-Id: Iaa6a8f6c0fdc46a911789759d6e1228d849aa237
This commit is contained in:
@@ -156,9 +156,11 @@ TEST_F(EngineMetricsTest, EngineMetricsWithSessions) {
|
||||
->crypto_session_load_certificate_private_key_.Record(2.0, NO_ERROR);
|
||||
|
||||
// Create two sessions and record some metrics.
|
||||
SessionMetrics* session_metrics_1 = engine_metrics.AddSession();
|
||||
std::shared_ptr<SessionMetrics> session_metrics_1 =
|
||||
engine_metrics.AddSession();
|
||||
session_metrics_1->SetSessionId(kSessionId1);
|
||||
SessionMetrics* session_metrics_2 = engine_metrics.AddSession();
|
||||
std::shared_ptr<SessionMetrics> session_metrics_2 =
|
||||
engine_metrics.AddSession();
|
||||
session_metrics_2->SetSessionId(kSessionId2);
|
||||
// Record a CryptoMetrics metric in the session.
|
||||
session_metrics_2->GetCryptoMetrics()->crypto_session_generic_decrypt_
|
||||
@@ -184,7 +186,7 @@ TEST_F(EngineMetricsTest, EngineMetricsConsolidateSessions) {
|
||||
EngineMetrics engine_metrics;
|
||||
|
||||
// Create one more session than the max allowed closed sessions.
|
||||
std::vector<SessionMetrics*> session_metrics;
|
||||
std::vector<std::shared_ptr<SessionMetrics>> session_metrics;
|
||||
for (int i = 0; i < kMaxCompletedSessions + 1; i++) {
|
||||
session_metrics.push_back(engine_metrics.AddSession());
|
||||
session_metrics.back()->SetSessionId(std::to_string(i));
|
||||
@@ -208,7 +210,7 @@ TEST_F(EngineMetricsTest, EngineMetricsConsolidateSessionsNoClosedSessions) {
|
||||
EngineMetrics engine_metrics;
|
||||
|
||||
// Create one more session than the max allowed closed sessions.
|
||||
std::vector<SessionMetrics*> session_metrics;
|
||||
std::vector<std::shared_ptr<SessionMetrics>> session_metrics;
|
||||
for (int i = 0; i < kMaxCompletedSessions + 1; i++) {
|
||||
session_metrics.push_back(engine_metrics.AddSession());
|
||||
session_metrics.back()->SetSessionId(std::to_string(i));
|
||||
|
||||
Reference in New Issue
Block a user