Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1393)

Unified Diff: content/renderer/media/rtc_peer_connection_handler.cc

Issue 2668813002: Remove LazyInstance usage from media/ (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/rtc_peer_connection_handler.cc
diff --git a/content/renderer/media/rtc_peer_connection_handler.cc b/content/renderer/media/rtc_peer_connection_handler.cc
index 65e9e940169a2f2c439b45942f1574d62187f945..8caa6622cec2d3f9abb9d706019199fe9d2bef48 100644
--- a/content/renderer/media/rtc_peer_connection_handler.cc
+++ b/content/renderer/media/rtc_peer_connection_handler.cc
@@ -11,7 +11,6 @@
#include <vector>
#include "base/command_line.h"
-#include "base/lazy_instance.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
@@ -913,8 +912,11 @@ void ConvertConstraintsToWebrtcOfferOptions(
&output->ice_restart);
}
-base::LazyInstance<std::set<RTCPeerConnectionHandler*> >::Leaky
- g_peer_connection_handlers = LAZY_INSTANCE_INITIALIZER;
+std::set<RTCPeerConnectionHandler*>* GetPeerConnectionHandlers() {
+ static std::set<RTCPeerConnectionHandler*>* handlers =
+ new std::set<RTCPeerConnectionHandler*>();
+ return handlers;
+}
} // namespace
@@ -1095,8 +1097,7 @@ RTCPeerConnectionHandler::RTCPeerConnectionHandler(
is_closed_(false),
dependency_factory_(dependency_factory),
weak_factory_(this) {
- CHECK(client_),
- g_peer_connection_handlers.Get().insert(this);
+ CHECK(client_), GetPeerConnectionHandlers()->insert(this);
Mark Mentovai 2017/01/31 21:33:56 ; would be more usual than , here.
DaleCurtis 2017/01/31 22:04:33 Whoops, surprised that compiled. Done.
}
RTCPeerConnectionHandler::~RTCPeerConnectionHandler() {
@@ -1104,7 +1105,7 @@ RTCPeerConnectionHandler::~RTCPeerConnectionHandler() {
stop();
- g_peer_connection_handlers.Get().erase(this);
+ GetPeerConnectionHandlers()->erase(this);
if (peer_connection_tracker_)
peer_connection_tracker_->UnregisterPeerConnection(this);
@@ -1117,8 +1118,7 @@ void RTCPeerConnectionHandler::DestructAllHandlers() {
// Copy g_peer_connection_handlers since releasePeerConnectionHandler will
// remove an item.
std::set<RTCPeerConnectionHandler*> handlers(
- g_peer_connection_handlers.Get().begin(),
- g_peer_connection_handlers.Get().end());
+ GetPeerConnectionHandlers()->begin(), GetPeerConnectionHandlers()->end());
for (auto* handler : handlers)
handler->client_->releasePeerConnectionHandler();
}

Powered by Google App Engine
This is Rietveld 408576698