Bug 1245527 - Use PWebAuthnTransactionParent superclass for U2FTokenManager. r=keeler
authorJ.C. Jones <jjones@mozilla.com>
Fri, 25 Aug 2017 18:37:17 -0700
changeset 380317 f335590189063d61d09236c479f1c1d9241e7a33
parent 380316 bf6e51ea07a7ed46ee55f53bb67cf3ed7e7b1282
child 380318 dd315914f198f74605f6f3bb5311a12e66a1787f
push id32486
push userarchaeopteryx@coole-files.de
push dateWed, 13 Sep 2017 09:28:25 +0000
treeherdermozilla-central@987326974635 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskeeler
bugs1245527
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1245527 - Use PWebAuthnTransactionParent superclass for U2FTokenManager. r=keeler This is a change to permit interacting with the U2FTokenManager from the dom/U2F context in addition to the dom/WebAuthn one. MozReview-Commit-ID: BvP5BY2wVYi
dom/webauthn/U2FTokenManager.cpp
dom/webauthn/U2FTokenManager.h
--- a/dom/webauthn/U2FTokenManager.cpp
+++ b/dom/webauthn/U2FTokenManager.cpp
@@ -3,17 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/U2FTokenManager.h"
 #include "mozilla/dom/U2FTokenTransport.h"
 #include "mozilla/dom/U2FHIDTokenManager.h"
 #include "mozilla/dom/U2FSoftTokenManager.h"
-#include "mozilla/dom/WebAuthnTransactionParent.h"
+#include "mozilla/dom/PWebAuthnTransactionParent.h"
 #include "mozilla/MozPromise.h"
 #include "mozilla/dom/WebAuthnUtil.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/Unused.h"
 #include "hasht.h"
 #include "nsICryptoHash.h"
 #include "pkix/Input.h"
 #include "pkixutil.h"
@@ -160,17 +160,17 @@ U2FTokenManager::Get()
 void
 U2FTokenManager::AbortTransaction(const nsresult& aError)
 {
   Unused << mTransactionParent->SendCancel(aError);
   ClearTransaction();
 }
 
 void
-U2FTokenManager::MaybeClearTransaction(WebAuthnTransactionParent* aParent)
+U2FTokenManager::MaybeClearTransaction(PWebAuthnTransactionParent* aParent)
 {
   // Only clear if we've been requested to do so by our current transaction
   // parent.
   if (mTransactionParent == aParent) {
     ClearTransaction();
   }
 }
 
@@ -213,17 +213,17 @@ U2FTokenManager::GetTokenManagerImpl()
   }
 
   // TODO Use WebAuthnRequest to aggregate results from all transports,
   //      once we have multiple HW transport types.
   return new U2FHIDTokenManager();
 }
 
 void
-U2FTokenManager::Register(WebAuthnTransactionParent* aTransactionParent,
+U2FTokenManager::Register(PWebAuthnTransactionParent* aTransactionParent,
                           const WebAuthnTransactionInfo& aTransactionInfo)
 {
   MOZ_LOG(gU2FTokenManagerLog, LogLevel::Debug, ("U2FAuthRegister"));
 
   ClearTransaction();
   mTransactionParent = aTransactionParent;
   mTokenManagerImpl = GetTokenManagerImpl();
 
@@ -295,17 +295,17 @@ U2FTokenManager::MaybeAbortRegister(uint
     return;
   }
 
   mRegisterPromise.Complete();
   AbortTransaction(aError);
 }
 
 void
-U2FTokenManager::Sign(WebAuthnTransactionParent* aTransactionParent,
+U2FTokenManager::Sign(PWebAuthnTransactionParent* aTransactionParent,
                       const WebAuthnTransactionInfo& aTransactionInfo)
 {
   MOZ_LOG(gU2FTokenManagerLog, LogLevel::Debug, ("U2FAuthSign"));
 
   ClearTransaction();
   mTransactionParent = aTransactionParent;
   mTokenManagerImpl = GetTokenManagerImpl();
 
@@ -374,17 +374,17 @@ U2FTokenManager::MaybeAbortSign(uint64_t
     return;
   }
 
   mSignPromise.Complete();
   AbortTransaction(aError);
 }
 
 void
-U2FTokenManager::Cancel(WebAuthnTransactionParent* aParent)
+U2FTokenManager::Cancel(PWebAuthnTransactionParent* aParent)
 {
   if (mTransactionParent != aParent) {
     return;
   }
 
   mTokenManagerImpl->Cancel();
   ClearTransaction();
 }
--- a/dom/webauthn/U2FTokenManager.h
+++ b/dom/webauthn/U2FTokenManager.h
@@ -31,38 +31,38 @@ public:
   enum TransactionType
   {
     RegisterTransaction = 0,
     SignTransaction,
     NumTransactionTypes
   };
   NS_INLINE_DECL_REFCOUNTING(U2FTokenManager)
   static U2FTokenManager* Get();
-  void Register(WebAuthnTransactionParent* aTransactionParent,
+  void Register(PWebAuthnTransactionParent* aTransactionParent,
                 const WebAuthnTransactionInfo& aTransactionInfo);
-  void Sign(WebAuthnTransactionParent* aTransactionParent,
+  void Sign(PWebAuthnTransactionParent* aTransactionParent,
             const WebAuthnTransactionInfo& aTransactionInfo);
-  void Cancel(WebAuthnTransactionParent* aTransactionParent);
-  void MaybeClearTransaction(WebAuthnTransactionParent* aParent);
+  void Cancel(PWebAuthnTransactionParent* aTransactionParent);
+  void MaybeClearTransaction(PWebAuthnTransactionParent* aParent);
   static void Initialize();
 private:
   U2FTokenManager();
   ~U2FTokenManager();
   RefPtr<U2FTokenTransport> GetTokenManagerImpl();
   void AbortTransaction(const nsresult& aError);
   void ClearTransaction();
   void MaybeConfirmRegister(uint64_t aTransactionId,
                             U2FRegisterResult& aResult);
   void MaybeAbortRegister(uint64_t aTransactionId, const nsresult& aError);
   void MaybeConfirmSign(uint64_t aTransactionId, U2FSignResult& aResult);
   void MaybeAbortSign(uint64_t aTransactionId, const nsresult& aError);
   // Using a raw pointer here, as the lifetime of the IPC object is managed by
   // the PBackground protocol code. This means we cannot be left holding an
   // invalid IPC protocol object after the transaction is finished.
-  WebAuthnTransactionParent* mTransactionParent;
+  PWebAuthnTransactionParent* mTransactionParent;
   RefPtr<U2FTokenTransport> mTokenManagerImpl;
   MozPromiseRequestHolder<U2FRegisterPromise> mRegisterPromise;
   MozPromiseRequestHolder<U2FSignPromise> mSignPromise;
   // Guards the asynchronous promise resolution of token manager impls.
   // We don't need to protect this with a lock as it will only be modified
   // and checked on the PBackground thread in the parent process.
   uint64_t mTransactionId;
 };