LCOV - code coverage report
Current view: top level - dom/payments - PaymentRequestManager.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 3 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim:set ts=2 sw=2 sts=2 et cindent: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef mozilla_dom_PaymentRequestManager_h
       8             : #define mozilla_dom_PaymentRequestManager_h
       9             : 
      10             : #include "nsISupports.h"
      11             : #include "PaymentRequest.h"
      12             : #include "mozilla/dom/PaymentRequestBinding.h"
      13             : #include "mozilla/dom/PaymentRequestUpdateEventBinding.h"
      14             : #include "mozilla/dom/PaymentResponseBinding.h"
      15             : #include "nsCOMPtr.h"
      16             : #include "nsTArray.h"
      17             : 
      18             : namespace mozilla {
      19             : namespace dom {
      20             : 
      21             : class PaymentRequestChild;
      22             : class IPCPaymentActionRequest;
      23             : 
      24             : /*
      25             :  *  PaymentRequestManager is a singleton used to manage the created PaymentRequests.
      26             :  *  It is also the communication agent to chrome proces.
      27             :  */
      28             : class PaymentRequestManager final
      29             : {
      30             : public:
      31           0 :   NS_INLINE_DECL_REFCOUNTING(PaymentRequestManager)
      32             : 
      33             :   static already_AddRefed<PaymentRequestManager> GetSingleton();
      34             : 
      35             :   already_AddRefed<PaymentRequest>
      36             :   GetPaymentRequestById(const nsAString& aRequestId);
      37             : 
      38             :   /*
      39             :    *  This method is used to create PaymentRequest object and send corresponding
      40             :    *  data to chrome process for internal payment creation, such that content
      41             :    *  process can ask specific task by sending requestId only.
      42             :    */
      43             :   nsresult
      44             :   CreatePayment(nsPIDOMWindowInner* aWindow,
      45             :                 const Sequence<PaymentMethodData>& aMethodData,
      46             :                 const PaymentDetailsInit& aDetails,
      47             :                 const PaymentOptions& aOptions,
      48             :                 PaymentRequest** aRequest);
      49             : 
      50             :   nsresult CanMakePayment(const nsAString& aRequestId);
      51             :   nsresult ShowPayment(const nsAString& aRequestId);
      52             :   nsresult AbortPayment(const nsAString& aRequestId);
      53             :   nsresult CompletePayment(const nsAString& aRequestId,
      54             :                            const PaymentComplete& aComplete);
      55             :   nsresult UpdatePayment(const nsAString& aRequestId,
      56             :                          const PaymentDetailsUpdate& aDetails);
      57             : 
      58             :   nsresult RespondPayment(const IPCPaymentActionResponse& aResponse);
      59             :   nsresult ChangeShippingAddress(const nsAString& aRequestId,
      60             :                                  const IPCPaymentAddress& aAddress);
      61             :   nsresult ChangeShippingOption(const nsAString& aRequestId,
      62             :                                 const nsAString& aOption);
      63             : 
      64             :   nsresult
      65             :   ReleasePaymentChild(PaymentRequestChild* aPaymentChild);
      66             : 
      67             : private:
      68           0 :   PaymentRequestManager() = default;
      69           0 :   ~PaymentRequestManager() = default;
      70             : 
      71             :   nsresult GetPaymentChild(PaymentRequest* aRequest,
      72             :                            PaymentRequestChild** aPaymentChild);
      73             :   nsresult ReleasePaymentChild(PaymentRequest* aRequest);
      74             : 
      75             :   nsresult SendRequestPayment(PaymentRequest* aRequest,
      76             :                               const IPCPaymentActionRequest& action,
      77             :                               bool aReleaseAfterSend = false);
      78             : 
      79             :   // The container for the created PaymentRequests
      80             :   nsTArray<RefPtr<PaymentRequest>> mRequestQueue;
      81             :   nsRefPtrHashtable<nsRefPtrHashKey<PaymentRequest>, PaymentRequestChild> mPaymentChildHash;
      82             : };
      83             : 
      84             : } // end of namespace dom
      85             : } // end of namespace mozilla
      86             : 
      87             : #endif

Generated by: LCOV version 1.13