LCOV - code coverage report
Current view: top level - dom/script - ModuleLoadRequest.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 41 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 11 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 "ModuleLoadRequest.h"
       8             : #include "ModuleScript.h"
       9             : #include "ScriptLoader.h"
      10             : 
      11             : namespace mozilla {
      12             : namespace dom {
      13             : 
      14           0 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ModuleLoadRequest)
      15           0 : NS_INTERFACE_MAP_END_INHERITING(ScriptLoadRequest)
      16             : 
      17           0 : NS_IMPL_CYCLE_COLLECTION_INHERITED(ModuleLoadRequest, ScriptLoadRequest,
      18             :                                    mBaseURL,
      19             :                                    mLoader,
      20             :                                    mParent,
      21             :                                    mModuleScript,
      22             :                                    mImports)
      23             : 
      24           0 : NS_IMPL_ADDREF_INHERITED(ModuleLoadRequest, ScriptLoadRequest)
      25           0 : NS_IMPL_RELEASE_INHERITED(ModuleLoadRequest, ScriptLoadRequest)
      26             : 
      27           0 : ModuleLoadRequest::ModuleLoadRequest(nsIScriptElement* aElement,
      28             :                                      uint32_t aVersion,
      29             :                                      CORSMode aCORSMode,
      30             :                                      const SRIMetadata& aIntegrity,
      31           0 :                                      ScriptLoader* aLoader)
      32             :   : ScriptLoadRequest(ScriptKind::Module,
      33             :                       aElement,
      34             :                       aVersion,
      35             :                       aCORSMode,
      36             :                       aIntegrity),
      37             :     mIsTopLevel(true),
      38           0 :     mLoader(aLoader)
      39           0 : {}
      40             : 
      41             : void
      42           0 : ModuleLoadRequest::Cancel()
      43             : {
      44           0 :   ScriptLoadRequest::Cancel();
      45           0 :   mModuleScript = nullptr;
      46           0 :   mProgress = ScriptLoadRequest::Progress::Ready;
      47           0 :   for (size_t i = 0; i < mImports.Length(); i++) {
      48           0 :     mImports[i]->Cancel();
      49             :   }
      50           0 :   mReady.RejectIfExists(NS_ERROR_FAILURE, __func__);
      51           0 : }
      52             : 
      53             : void
      54           0 : ModuleLoadRequest::SetReady()
      55             : {
      56             : #ifdef DEBUG
      57           0 :   for (size_t i = 0; i < mImports.Length(); i++) {
      58           0 :     MOZ_ASSERT(mImports[i]->IsReadyToRun());
      59             :   }
      60             : #endif
      61             : 
      62           0 :   ScriptLoadRequest::SetReady();
      63           0 :   mReady.ResolveIfExists(true, __func__);
      64           0 : }
      65             : 
      66             : void
      67           0 : ModuleLoadRequest::ModuleLoaded()
      68             : {
      69             :   // A module that was found to be marked as fetching in the module map has now
      70             :   // been loaded.
      71             : 
      72           0 :   mModuleScript = mLoader->GetFetchedModule(mURI);
      73           0 :   mLoader->StartFetchingModuleDependencies(this);
      74           0 : }
      75             : 
      76             : void
      77           0 : ModuleLoadRequest::DependenciesLoaded()
      78             : {
      79             :   // The module and all of its dependencies have been successfully fetched and
      80             :   // compiled.
      81             : 
      82           0 :   if (!mLoader->InstantiateModuleTree(this)) {
      83           0 :     LoadFailed();
      84           0 :     return;
      85             :   }
      86             : 
      87           0 :   SetReady();
      88           0 :   mLoader->ProcessLoadedModuleTree(this);
      89           0 :   mLoader = nullptr;
      90           0 :   mParent = nullptr;
      91             : }
      92             : 
      93             : void
      94           0 : ModuleLoadRequest::LoadFailed()
      95             : {
      96           0 :   Cancel();
      97           0 :   mLoader->ProcessLoadedModuleTree(this);
      98           0 :   mLoader = nullptr;
      99           0 :   mParent = nullptr;
     100           0 : }
     101             : 
     102             : } // dom namespace
     103             : } // mozilla namespace

Generated by: LCOV version 1.13