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

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

Issue 2108033005: Specify WTF:: prefix for bind() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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/ScriptPromise.h" 7 #include "bindings/core/v8/ScriptPromise.h"
8 #include "bindings/core/v8/ScriptPromiseResolver.h" 8 #include "bindings/core/v8/ScriptPromiseResolver.h"
9 #include "core/dom/DOMException.h" 9 #include "core/dom/DOMException.h"
10 #include "core/dom/Document.h" 10 #include "core/dom/Document.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 } 49 }
50 50
51 } // namespace 51 } // namespace
52 52
53 USB::USB(LocalFrame& frame) 53 USB::USB(LocalFrame& frame)
54 : ContextLifecycleObserver(frame.document()) 54 : ContextLifecycleObserver(frame.document())
55 , m_clientBinding(this) 55 , m_clientBinding(this)
56 { 56 {
57 ThreadState::current()->registerPreFinalizer(this); 57 ThreadState::current()->registerPreFinalizer(this);
58 frame.serviceRegistry()->connectToRemoteService(mojo::GetProxy(&m_deviceMana ger)); 58 frame.serviceRegistry()->connectToRemoteService(mojo::GetProxy(&m_deviceMana ger));
59 m_deviceManager.set_connection_error_handler(createBaseCallback(bind(&USB::o nDeviceManagerConnectionError, wrapWeakPersistent(this)))); 59 m_deviceManager.set_connection_error_handler(createBaseCallback(WTF::bind(&U SB::onDeviceManagerConnectionError, wrapWeakPersistent(this))));
60 m_deviceManager->SetClient(m_clientBinding.CreateInterfacePtrAndBind()); 60 m_deviceManager->SetClient(m_clientBinding.CreateInterfacePtrAndBind());
61 } 61 }
62 62
63 USB::~USB() 63 USB::~USB()
64 { 64 {
65 // |m_deviceManager| and |m_chooserService| may still be valid but there 65 // |m_deviceManager| and |m_chooserService| may still be valid but there
66 // should be no more outstanding requests to them because each holds a 66 // should be no more outstanding requests to them because each holds a
67 // persistent handle to this object. 67 // persistent handle to this object.
68 DCHECK(m_deviceManagerRequests.isEmpty()); 68 DCHECK(m_deviceManagerRequests.isEmpty());
69 DCHECK(m_chooserServiceRequests.isEmpty()); 69 DCHECK(m_chooserServiceRequests.isEmpty());
(...skipping 11 matching lines...) Expand all
81 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 81 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
82 ScriptPromise promise = resolver->promise(); 82 ScriptPromise promise = resolver->promise();
83 if (!m_deviceManager) { 83 if (!m_deviceManager) {
84 resolver->reject(DOMException::create(NotSupportedError)); 84 resolver->reject(DOMException::create(NotSupportedError));
85 } else { 85 } else {
86 String errorMessage; 86 String errorMessage;
87 if (!scriptState->getExecutionContext()->isSecureContext(errorMessage)) { 87 if (!scriptState->getExecutionContext()->isSecureContext(errorMessage)) {
88 resolver->reject(DOMException::create(SecurityError, errorMessage)); 88 resolver->reject(DOMException::create(SecurityError, errorMessage));
89 } else { 89 } else {
90 m_deviceManagerRequests.add(resolver); 90 m_deviceManagerRequests.add(resolver);
91 m_deviceManager->GetDevices(nullptr, createBaseCallback(bind(&USB::o nGetDevices, wrapPersistent(this), wrapPersistent(resolver)))); 91 m_deviceManager->GetDevices(nullptr, createBaseCallback(WTF::bind(&U SB::onGetDevices, wrapPersistent(this), wrapPersistent(resolver))));
92 } 92 }
93 } 93 }
94 return promise; 94 return promise;
95 } 95 }
96 96
97 ScriptPromise USB::requestDevice(ScriptState* scriptState, const USBDeviceReques tOptions& options) 97 ScriptPromise USB::requestDevice(ScriptState* scriptState, const USBDeviceReques tOptions& options)
98 { 98 {
99 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 99 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
100 ScriptPromise promise = resolver->promise(); 100 ScriptPromise promise = resolver->promise();
101 101
102 if (!m_chooserService) { 102 if (!m_chooserService) {
103 LocalFrame* frame = getExecutionContext() ? toDocument(getExecutionConte xt())->frame() : nullptr; 103 LocalFrame* frame = getExecutionContext() ? toDocument(getExecutionConte xt())->frame() : nullptr;
104 if (!frame) { 104 if (!frame) {
105 resolver->reject(DOMException::create(NotSupportedError)); 105 resolver->reject(DOMException::create(NotSupportedError));
106 return promise; 106 return promise;
107 } 107 }
108 frame->serviceRegistry()->connectToRemoteService(mojo::GetProxy(&m_choos erService)); 108 frame->serviceRegistry()->connectToRemoteService(mojo::GetProxy(&m_choos erService));
109 m_chooserService.set_connection_error_handler(createBaseCallback(bind(&U SB::onChooserServiceConnectionError, wrapWeakPersistent(this)))); 109 m_chooserService.set_connection_error_handler(createBaseCallback(WTF::bi nd(&USB::onChooserServiceConnectionError, wrapWeakPersistent(this))));
110 } 110 }
111 111
112 String errorMessage; 112 String errorMessage;
113 if (!scriptState->getExecutionContext()->isSecureContext(errorMessage)) { 113 if (!scriptState->getExecutionContext()->isSecureContext(errorMessage)) {
114 resolver->reject(DOMException::create(SecurityError, errorMessage)); 114 resolver->reject(DOMException::create(SecurityError, errorMessage));
115 } else if (!UserGestureIndicator::consumeUserGesture()) { 115 } else if (!UserGestureIndicator::consumeUserGesture()) {
116 resolver->reject(DOMException::create(SecurityError, "Must be handling a user gesture to show a permission request.")); 116 resolver->reject(DOMException::create(SecurityError, "Must be handling a user gesture to show a permission request."));
117 } else { 117 } else {
118 Vector<usb::DeviceFilterPtr> filters; 118 Vector<usb::DeviceFilterPtr> filters;
119 if (options.hasFilters()) { 119 if (options.hasFilters()) {
120 filters.reserveCapacity(options.filters().size()); 120 filters.reserveCapacity(options.filters().size());
121 for (const auto& filter : options.filters()) 121 for (const auto& filter : options.filters())
122 filters.append(convertDeviceFilter(filter)); 122 filters.append(convertDeviceFilter(filter));
123 } 123 }
124 m_chooserServiceRequests.add(resolver); 124 m_chooserServiceRequests.add(resolver);
125 m_chooserService->GetPermission(std::move(filters), createBaseCallback(b ind(&USB::onGetPermission, wrapPersistent(this), wrapPersistent(resolver)))); 125 m_chooserService->GetPermission(std::move(filters), createBaseCallback(W TF::bind(&USB::onGetPermission, wrapPersistent(this), wrapPersistent(resolver))) );
126 } 126 }
127 return promise; 127 return promise;
128 } 128 }
129 129
130 ExecutionContext* USB::getExecutionContext() const 130 ExecutionContext* USB::getExecutionContext() const
131 { 131 {
132 return ContextLifecycleObserver::getExecutionContext(); 132 return ContextLifecycleObserver::getExecutionContext();
133 } 133 }
134 134
135 const AtomicString& USB::interfaceName() const 135 const AtomicString& USB::interfaceName() const
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 DEFINE_TRACE(USB) 227 DEFINE_TRACE(USB)
228 { 228 {
229 EventTargetWithInlineData::trace(visitor); 229 EventTargetWithInlineData::trace(visitor);
230 ContextLifecycleObserver::trace(visitor); 230 ContextLifecycleObserver::trace(visitor);
231 visitor->trace(m_deviceManagerRequests); 231 visitor->trace(m_deviceManagerRequests);
232 visitor->trace(m_chooserServiceRequests); 232 visitor->trace(m_chooserServiceRequests);
233 visitor->trace(m_deviceCache); 233 visitor->trace(m_deviceCache);
234 } 234 }
235 235
236 } // namespace blink 236 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698