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

Side by Side Diff: third_party/WebKit/Source/modules/nfc/NFC.cpp

Issue 2049003002: Wrap GCed raw pointer parameters of WTF::bind with Persistent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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/nfc/NFC.h" 5 #include "modules/nfc/NFC.h"
6 6
7 #include "bindings/core/v8/JSONValuesForV8.h" 7 #include "bindings/core/v8/JSONValuesForV8.h"
8 #include "bindings/core/v8/ScriptPromiseResolver.h" 8 #include "bindings/core/v8/ScriptPromiseResolver.h"
9 #include "bindings/core/v8/V8ArrayBuffer.h" 9 #include "bindings/core/v8/V8ArrayBuffer.h"
10 #include "core/dom/DOMArrayBuffer.h" 10 #include "core/dom/DOMArrayBuffer.h"
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 488
489 nfc::NFCMessagePtr message = nfc::NFCMessage::From(pushMessage); 489 nfc::NFCMessagePtr message = nfc::NFCMessage::From(pushMessage);
490 if (!message) 490 if (!message)
491 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(SyntaxError)); 491 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(SyntaxError));
492 492
493 if (!setURL(scriptState->getExecutionContext()->getSecurityOrigin()->toStrin g(), message)) 493 if (!setURL(scriptState->getExecutionContext()->getSecurityOrigin()->toStrin g(), message))
494 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(SyntaxError)); 494 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(SyntaxError));
495 495
496 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 496 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
497 m_requests.add(resolver); 497 m_requests.add(resolver);
498 auto callback = createBaseCallback(bind(&NFC::OnRequestCompleted, this, reso lver)); 498 auto callback = createBaseCallback(bind(&NFC::OnRequestCompleted, wrapPersis tent(this), wrapPersistent(resolver)));
499 m_nfc->Push(std::move(message), nfc::NFCPushOptions::From(options), callback ); 499 m_nfc->Push(std::move(message), nfc::NFCPushOptions::From(options), callback );
500 500
501 return resolver->promise(); 501 return resolver->promise();
502 } 502 }
503 503
504 ScriptPromise NFC::cancelPush(ScriptState* scriptState, const String& target) 504 ScriptPromise NFC::cancelPush(ScriptState* scriptState, const String& target)
505 { 505 {
506 String errorMessage; 506 String errorMessage;
507 if (!scriptState->getExecutionContext()->isSecureContext(errorMessage)) 507 if (!scriptState->getExecutionContext()->isSecureContext(errorMessage))
508 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(SecurityError, errorMessage)); 508 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(SecurityError, errorMessage));
509 509
510 if (!m_nfc) 510 if (!m_nfc)
511 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(NotSupportedError)); 511 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(NotSupportedError));
512 512
513 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 513 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
514 m_requests.add(resolver); 514 m_requests.add(resolver);
515 auto callback = createBaseCallback(bind(&NFC::OnRequestCompleted, this, reso lver)); 515 auto callback = createBaseCallback(bind(&NFC::OnRequestCompleted, wrapPersis tent(this), wrapPersistent(resolver)));
516 m_nfc->CancelPush(mojo::toNFCPushTarget(target), callback); 516 m_nfc->CancelPush(mojo::toNFCPushTarget(target), callback);
517 517
518 return resolver->promise(); 518 return resolver->promise();
519 } 519 }
520 520
521 ScriptPromise NFC::watch(ScriptState* scriptState, MessageCallback* callback, co nst NFCWatchOptions& options) 521 ScriptPromise NFC::watch(ScriptState* scriptState, MessageCallback* callback, co nst NFCWatchOptions& options)
522 { 522 {
523 // TODO(shalamov): To be implemented. 523 // TODO(shalamov): To be implemented.
524 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::crea te(NotSupportedError)); 524 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::crea te(NotSupportedError));
525 } 525 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 } 580 }
581 581
582 DEFINE_TRACE(NFC) 582 DEFINE_TRACE(NFC)
583 { 583 {
584 PageLifecycleObserver::trace(visitor); 584 PageLifecycleObserver::trace(visitor);
585 ContextLifecycleObserver::trace(visitor); 585 ContextLifecycleObserver::trace(visitor);
586 visitor->trace(m_requests); 586 visitor->trace(m_requests);
587 } 587 }
588 588
589 } // namespace blink 589 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698