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

Unified Diff: third_party/WebKit/Source/modules/webusb/USB.cpp

Issue 1848603002: Remove single observer assumption in WebUSBClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Register pre-finalizer. Created 4 years, 9 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: third_party/WebKit/Source/modules/webusb/USB.cpp
diff --git a/third_party/WebKit/Source/modules/webusb/USB.cpp b/third_party/WebKit/Source/modules/webusb/USB.cpp
index c35c88c26ad9ea79be0ff78cef6473005987e624..f299bb9755bc21260a5c9a63ae1d4c955d42b872 100644
--- a/third_party/WebKit/Source/modules/webusb/USB.cpp
+++ b/third_party/WebKit/Source/modules/webusb/USB.cpp
@@ -78,14 +78,19 @@ USB::USB(LocalFrame& frame)
: LocalFrameLifecycleObserver(&frame)
, m_client(USBController::from(frame).client())
{
+ ThreadState::current()->registerPreFinalizer(this);
if (m_client)
- m_client->setObserver(this);
+ m_client->addObserver(this);
}
USB::~USB()
{
+}
+
+void USB::dispose()
+{
if (m_client)
- m_client->setObserver(nullptr);
+ m_client->removeObserver(this);
haraken 2016/04/01 01:36:06 Shall we clear m_client here just in case? Then yo
}
ScriptPromise USB::getDevices(ScriptState* scriptState)
@@ -139,7 +144,7 @@ const AtomicString& USB::interfaceName() const
void USB::willDetachFrameHost()
{
if (m_client)
- m_client->setObserver(nullptr);
+ m_client->removeObserver(this);
m_client = nullptr;
}
« no previous file with comments | « third_party/WebKit/Source/modules/webusb/USB.h ('k') | third_party/WebKit/public/platform/modules/webusb/WebUSBClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698