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:
@@ -353,9 +353,13 @@ class EngineMetrics {
|
||||
~EngineMetrics();
|
||||
|
||||
// Add a new SessionMetrics instance and return a pointer to the caller.
|
||||
// The new SessionMetrics instance is owned by this EngineMetrics instance
|
||||
// and will exist until RemoveSession is called or this object is deleted.
|
||||
SessionMetrics *AddSession();
|
||||
// A shared_ptr is used since it's possible that the SessionMetrics instance
|
||||
// may be in use after the EngineMetrics instance is closed. The EngineMetrics
|
||||
// instance will hold a shared_ptr reference to the SessionMetrics instance
|
||||
// until RemoveSession is called, the EngineMetrics instance is deleted, or
|
||||
// the SessionMetrics instance is marked as completed and ConsolidateSessions
|
||||
// removes it.
|
||||
std::shared_ptr<SessionMetrics> AddSession();
|
||||
|
||||
// Removes the metrics object for the given session id. This should only
|
||||
// be called when the SessionMetrics instance is no longer in use.
|
||||
|
||||
Reference in New Issue
Block a user