LCOV - code coverage report
Current view: top level - dom/ipc - URLClassifierParent.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 28 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 10 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       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             : #include "URLClassifierParent.h"
       8             : #include "nsComponentManagerUtils.h"
       9             : #include "mozilla/Unused.h"
      10             : 
      11             : using namespace mozilla;
      12             : using namespace mozilla::dom;
      13             : 
      14             : /////////////////////////////////////////////////////////////////////
      15             : //URLClassifierParent.
      16             : 
      17           0 : NS_IMPL_ISUPPORTS(URLClassifierParent, nsIURIClassifierCallback)
      18             : 
      19             : mozilla::ipc::IPCResult
      20           0 : URLClassifierParent::StartClassify(nsIPrincipal* aPrincipal,
      21             :                                    bool aUseTrackingProtection,
      22             :                                    bool* aSuccess)
      23             : {
      24           0 :   *aSuccess = false;
      25           0 :   nsresult rv = NS_OK;
      26             :   // Note that in safe mode, the URL classifier service isn't available, so we
      27             :   // should handle the service not being present gracefully.
      28             :   nsCOMPtr<nsIURIClassifier> uriClassifier =
      29           0 :     do_GetService(NS_URICLASSIFIERSERVICE_CONTRACTID, &rv);
      30           0 :   if (NS_SUCCEEDED(rv)) {
      31           0 :     rv = uriClassifier->Classify(aPrincipal, nullptr, aUseTrackingProtection,
      32           0 :                                  this, aSuccess);
      33             :   }
      34           0 :   if (NS_FAILED(rv) || !*aSuccess) {
      35             :     // We treat the case where we fail to classify and the case where the
      36             :     // classifier returns successfully but doesn't perform a lookup as the
      37             :     // classification not yielding any results, so we just kill the child actor
      38             :     // without ever calling out callback in both cases.
      39             :     // This means that code using this in the child process will only get a hit
      40             :     // on its callback if some classification actually happens.
      41           0 :     *aSuccess = false;
      42           0 :     ClassificationFailed();
      43             :   }
      44           0 :   return IPC_OK();
      45             : }
      46             : 
      47             : void
      48           0 : URLClassifierParent::ActorDestroy(ActorDestroyReason aWhy)
      49             : {
      50           0 :   mIPCOpen = false;
      51           0 : }
      52             : 
      53             : /////////////////////////////////////////////////////////////////////
      54             : //URLClassifierLocalParent.
      55             : 
      56           0 : NS_IMPL_ISUPPORTS(URLClassifierLocalParent, nsIURIClassifierCallback)
      57             : 
      58             : mozilla::ipc::IPCResult
      59           0 : URLClassifierLocalParent::StartClassify(nsIURI* aURI, const nsACString& aTables)
      60             : {
      61           0 :   nsresult rv = NS_OK;
      62             :   // Note that in safe mode, the URL classifier service isn't available, so we
      63             :   // should handle the service not being present gracefully.
      64             :   nsCOMPtr<nsIURIClassifier> uriClassifier =
      65           0 :     do_GetService(NS_URICLASSIFIERSERVICE_CONTRACTID, &rv);
      66           0 :   if (NS_SUCCEEDED(rv)) {
      67           0 :     MOZ_ASSERT(aURI);
      68           0 :     rv = uriClassifier->AsyncClassifyLocalWithTables(aURI, aTables, this);
      69             :   }
      70           0 :   if (NS_FAILED(rv)) {
      71             :     // Cannot do ClassificationFailed() because the child side
      72             :     // is expecting a callback. Only the second parameter will
      73             :     // be used, which is the "matched list". We treat "unable
      74             :     // to classify" as "not on any list".
      75           0 :     OnClassifyComplete(NS_OK, EmptyCString(), EmptyCString(), EmptyCString());
      76             :   }
      77           0 :   return IPC_OK();
      78             : }
      79             : 
      80             : void
      81           0 : URLClassifierLocalParent::ActorDestroy(ActorDestroyReason aWhy)
      82             : {
      83           0 :   mIPCOpen = false;
      84           0 : }

Generated by: LCOV version 1.13