LCOV - code coverage report
Current view: top level - dom/base - DocGroup.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 16 29 55.2 %
Date: 2017-07-14 16:53:18 Functions: 6 8 75.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 file,
       5             :  * You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #include "mozilla/dom/DocGroup.h"
       8             : #include "mozilla/dom/TabGroup.h"
       9             : #include "mozilla/Telemetry.h"
      10             : #include "nsIDocShell.h"
      11             : 
      12             : namespace mozilla {
      13             : namespace dom {
      14             : 
      15             : /* static */ nsresult
      16         801 : DocGroup::GetKey(nsIPrincipal* aPrincipal, nsACString& aKey)
      17             : {
      18             :   // Use GetBaseDomain() to handle things like file URIs, IP address URIs,
      19             :   // etc. correctly.
      20         801 :   nsresult rv = aPrincipal->GetBaseDomain(aKey);
      21         801 :   if (NS_FAILED(rv)) {
      22             :     // We don't really know what to do here.  But we should be conservative,
      23             :     // otherwise it would be possible to reorder two events incorrectly in the
      24             :     // future if we interrupt at the DocGroup level, so to be safe, use an
      25             :     // empty string to classify all such documents as belonging to the same
      26             :     // DocGroup.
      27           0 :     aKey.Truncate();
      28             :   }
      29             : 
      30         801 :   return rv;
      31             : }
      32             : 
      33             : void
      34           0 : DocGroup::RemoveDocument(nsIDocument* aDocument)
      35             : {
      36           0 :   MOZ_ASSERT(NS_IsMainThread());
      37           0 :   MOZ_ASSERT(mDocuments.Contains(aDocument));
      38           0 :   mDocuments.RemoveElement(aDocument);
      39           0 : }
      40             : 
      41           5 : DocGroup::DocGroup(TabGroup* aTabGroup, const nsACString& aKey)
      42           5 :   : mKey(aKey), mTabGroup(aTabGroup)
      43             : {
      44             :   // This method does not add itself to mTabGroup->mDocGroups as the caller does it for us.
      45           5 : }
      46             : 
      47           0 : DocGroup::~DocGroup()
      48             : {
      49           0 :   MOZ_ASSERT(mDocuments.IsEmpty());
      50           0 :   if (!NS_IsMainThread()) {
      51           0 :     nsIEventTarget* target = EventTargetFor(TaskCategory::Other);
      52           0 :     NS_ProxyRelease("DocGroup::mReactionsStack", target, mReactionsStack.forget());
      53             :   }
      54             : 
      55           0 :   mTabGroup->mDocGroups.RemoveEntry(mKey);
      56           0 : }
      57             : 
      58             : nsresult
      59         135 : DocGroup::Dispatch(const char* aName,
      60             :                    TaskCategory aCategory,
      61             :                    already_AddRefed<nsIRunnable>&& aRunnable)
      62             : {
      63         135 :   return mTabGroup->Dispatch(aName, aCategory, Move(aRunnable));
      64             : }
      65             : 
      66             : nsISerialEventTarget*
      67         143 : DocGroup::EventTargetFor(TaskCategory aCategory) const
      68             : {
      69         143 :   return mTabGroup->EventTargetFor(aCategory);
      70             : }
      71             : 
      72             : AbstractThread*
      73           1 : DocGroup::AbstractMainThreadFor(TaskCategory aCategory)
      74             : {
      75           1 :   MOZ_RELEASE_ASSERT(NS_IsMainThread());
      76           1 :   return mTabGroup->AbstractMainThreadFor(aCategory);
      77             : }
      78             : 
      79             : bool*
      80           4 : DocGroup::GetValidAccessPtr()
      81             : {
      82           4 :   return mTabGroup->GetValidAccessPtr();
      83             : }
      84             : 
      85             : }
      86             : }

Generated by: LCOV version 1.13