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

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

Issue 2463453002: "Fix" remaining connection error handlers in Blink (Closed)
Patch Set: Created 4 years, 1 month 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"
11 #include "core/dom/DOMException.h" 11 #include "core/dom/DOMException.h"
12 #include "core/dom/Document.h" 12 #include "core/dom/Document.h"
13 #include "core/dom/ExceptionCode.h" 13 #include "core/dom/ExceptionCode.h"
14 #include "core/frame/LocalDOMWindow.h" 14 #include "core/frame/LocalDOMWindow.h"
15 #include "modules/nfc/NFCError.h" 15 #include "modules/nfc/NFCError.h"
16 #include "modules/nfc/NFCMessage.h" 16 #include "modules/nfc/NFCMessage.h"
17 #include "modules/nfc/NFCPushOptions.h" 17 #include "modules/nfc/NFCPushOptions.h"
18 #include "platform/mojo/MojoHelper.h" 18 #include "platform/mojo/MojoHelper.h"
19 #include "public/platform/InterfaceProvider.h" 19 #include "public/platform/InterfaceProvider.h"
20 #include "public/platform/Platform.h"
20 21
21 namespace mojom = device::nfc::mojom::blink; 22 namespace mojom = device::nfc::mojom::blink;
22 23
23 namespace { 24 namespace {
24 const char kJsonMimePrefix[] = "application/"; 25 const char kJsonMimePrefix[] = "application/";
25 const char kJsonMimeType[] = "application/json"; 26 const char kJsonMimeType[] = "application/json";
26 const char kOpaqueMimeType[] = "application/octet-stream"; 27 const char kOpaqueMimeType[] = "application/octet-stream";
27 const char kPlainTextMimeType[] = "text/plain"; 28 const char kPlainTextMimeType[] = "text/plain";
28 const char kPlainTextMimePrefix[] = "text/"; 29 const char kPlainTextMimePrefix[] = "text/";
29 const char kCharSetUTF8[] = ";charset=UTF-8"; 30 const char kCharSetUTF8[] = ";charset=UTF-8";
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 return; 555 return;
555 556
556 m_requests.remove(resolver); 557 m_requests.remove(resolver);
557 if (error.is_null()) 558 if (error.is_null())
558 resolver->resolve(); 559 resolver->resolve();
559 else 560 else
560 resolver->reject(NFCError::take(resolver, error->error_type)); 561 resolver->reject(NFCError::take(resolver, error->error_type));
561 } 562 }
562 563
563 void NFC::OnConnectionError() { 564 void NFC::OnConnectionError() {
565 if (!Platform::current()) {
566 // TODO(rockot): Clean this up once renderer shutdown sequence is fixed.
567 return;
568 }
569
564 m_nfc.reset(); 570 m_nfc.reset();
565 571
566 // If NFCService is not available or disappears when NFC hardware is 572 // If NFCService is not available or disappears when NFC hardware is
567 // disabled, reject promise with NotSupportedError exception. 573 // disabled, reject promise with NotSupportedError exception.
568 for (ScriptPromiseResolver* resolver : m_requests) 574 for (ScriptPromiseResolver* resolver : m_requests)
569 resolver->reject( 575 resolver->reject(
570 NFCError::take(resolver, mojom::NFCErrorType::NOT_SUPPORTED)); 576 NFCError::take(resolver, mojom::NFCErrorType::NOT_SUPPORTED));
571 577
572 m_requests.clear(); 578 m_requests.clear();
573 } 579 }
574 580
575 void NFC::OnWatch(mojo::WTFArray<uint32_t> ids, mojom::NFCMessagePtr) { 581 void NFC::OnWatch(mojo::WTFArray<uint32_t> ids, mojom::NFCMessagePtr) {
576 // TODO(shalamov): Not implemented. 582 // TODO(shalamov): Not implemented.
577 } 583 }
578 584
579 DEFINE_TRACE(NFC) { 585 DEFINE_TRACE(NFC) {
580 PageVisibilityObserver::trace(visitor); 586 PageVisibilityObserver::trace(visitor);
581 ContextLifecycleObserver::trace(visitor); 587 ContextLifecycleObserver::trace(visitor);
582 visitor->trace(m_requests); 588 visitor->trace(m_requests);
583 } 589 }
584 590
585 } // namespace blink 591 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698