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

Side by Side Diff: third_party/WebKit/Source/modules/webusb/USB.cpp

Issue 1876703002: Oilpan: Replace EAGERLY_FINALIZE in EventTarget's hierarchy with pre-finalizers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/webusb/USB.h" 5 #include "modules/webusb/USB.h"
6 6
7 #include "bindings/core/v8/CallbackPromiseAdapter.h" 7 #include "bindings/core/v8/CallbackPromiseAdapter.h"
8 #include "bindings/core/v8/ScriptPromise.h" 8 #include "bindings/core/v8/ScriptPromise.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "core/dom/DOMException.h" 10 #include "core/dom/DOMException.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 return devices; 71 return devices;
72 } 72 }
73 }; 73 };
74 74
75 } // namespace 75 } // namespace
76 76
77 USB::USB(LocalFrame& frame) 77 USB::USB(LocalFrame& frame)
78 : ContextLifecycleObserver(frame.document()) 78 : ContextLifecycleObserver(frame.document())
79 , m_client(USBController::from(frame).client()) 79 , m_client(USBController::from(frame).client())
80 { 80 {
81 ThreadState::current()->registerPreFinalizer(this);
81 if (m_client) 82 if (m_client)
82 m_client->addObserver(this); 83 m_client->addObserver(this);
83 } 84 }
84 85
85 USB::~USB() 86 USB::~USB()
86 { 87 {
88 }
89
90 void USB::dispose()
91 {
87 if (m_client) 92 if (m_client)
88 m_client->removeObserver(this); 93 m_client->removeObserver(this);
94 m_client = nullptr;
89 } 95 }
90 96
91 ScriptPromise USB::getDevices(ScriptState* scriptState) 97 ScriptPromise USB::getDevices(ScriptState* scriptState)
92 { 98 {
93 if (!m_client) 99 if (!m_client)
94 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(NotSupportedError)); 100 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(NotSupportedError));
95 101
96 String errorMessage; 102 String errorMessage;
97 if (!scriptState->getExecutionContext()->isSecureContext(errorMessage)) 103 if (!scriptState->getExecutionContext()->isSecureContext(errorMessage))
98 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(SecurityError, errorMessage)); 104 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(SecurityError, errorMessage));
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 dispatchEvent(USBConnectionEvent::create(EventTypeNames::disconnect, USBDevi ce::create(adoptPtr(device.release()), getExecutionContext()))); 159 dispatchEvent(USBConnectionEvent::create(EventTypeNames::disconnect, USBDevi ce::create(adoptPtr(device.release()), getExecutionContext())));
154 } 160 }
155 161
156 DEFINE_TRACE(USB) 162 DEFINE_TRACE(USB)
157 { 163 {
158 RefCountedGarbageCollectedEventTargetWithInlineData<USB>::trace(visitor); 164 RefCountedGarbageCollectedEventTargetWithInlineData<USB>::trace(visitor);
159 ContextLifecycleObserver::trace(visitor); 165 ContextLifecycleObserver::trace(visitor);
160 } 166 }
161 167
162 } // namespace blink 168 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698