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

Unified Diff: third_party/WebKit/Source/modules/webusb/USBDevice.h

Issue 1820173002: Close USB device connections when the page is hidden. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased and fixed nit. 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/USBDevice.h
diff --git a/third_party/WebKit/Source/modules/webusb/USBDevice.h b/third_party/WebKit/Source/modules/webusb/USBDevice.h
index 00c879c4395a2b91e164edb34eb1d2b54f785d9c..7f30b5395835820c12b22995040694dfb7258c15 100644
--- a/third_party/WebKit/Source/modules/webusb/USBDevice.h
+++ b/third_party/WebKit/Source/modules/webusb/USBDevice.h
@@ -9,6 +9,8 @@
#include "bindings/core/v8/ScriptWrappable.h"
#include "bindings/modules/v8/UnionTypesModules.h"
#include "core/dom/ContextLifecycleObserver.h"
+#include "core/dom/Document.h"
+#include "core/page/PageLifecycleObserver.h"
#include "platform/heap/Handle.h"
#include "public/platform/modules/webusb/WebUSBDevice.h"
#include "public/platform/modules/webusb/WebUSBDeviceInfo.h"
@@ -25,7 +27,8 @@ class USBControlTransferParameters;
class USBDevice
: public GarbageCollectedFinalized<USBDevice>
, public ContextLifecycleObserver
- , public ScriptWrappable {
+ , public ScriptWrappable
+ , public PageLifecycleObserver {
WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(USBDevice);
DEFINE_WRAPPERTYPEINFO();
public:
@@ -85,14 +88,19 @@ public:
ScriptPromise isochronousTransferOut(ScriptState*, uint8_t endpointNumber, const ArrayBufferOrArrayBufferView& data, Vector<unsigned> packetLengths);
ScriptPromise reset(ScriptState*);
+ // ContextLifecycleObserver interface.
void contextDestroyed() override;
+ // PageLifecycleObserver interface.
+ void pageVisibilityChanged() override;
+
DECLARE_TRACE();
private:
int findConfigurationIndex(uint8_t configurationValue) const;
int findInterfaceIndex(uint8_t interfaceNumber) const;
int findAlternateIndex(size_t interfaceIndex, uint8_t alternateSetting) const;
+ bool ensurePageVisible(ScriptPromiseResolver*) const;
bool ensureNoDeviceOrInterfaceChangeInProgress(ScriptPromiseResolver*) const;
bool ensureDeviceConfigured(ScriptPromiseResolver*) const;
bool ensureInterfaceClaimed(uint8_t interfaceNumber, ScriptPromiseResolver*) const;
« no previous file with comments | « third_party/WebKit/LayoutTests/usb/usbDevice.html ('k') | third_party/WebKit/Source/modules/webusb/USBDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698