Global Metrics

path: .metrics.nargs.average
old: 2.8125
new: 1.0

path: .metrics.nargs.sum
old: 45.0
new: 4.0

path: .metrics.cyclomatic.sum
old: 63.0
new: 11.0

path: .metrics.cyclomatic.average
old: 3.3157894736842106
new: 1.8333333333333333

path: .metrics.mi.mi_sei
old: -30.70259161268502
new: 38.74870185263583

path: .metrics.mi.mi_visual_studio
old: 5.51848530272457
new: 35.201614256639516

path: .metrics.mi.mi_original
old: 9.436609867659016
new: 60.19476037885357

path: .metrics.nexits.average
old: 1.375
new: 1.5

path: .metrics.nexits.sum
old: 22.0
new: 6.0

path: .metrics.cognitive.average
old: 3.3125
new: 1.25

path: .metrics.cognitive.sum
old: 53.0
new: 5.0

path: .metrics.loc.cloc
old: 45.0
new: 10.0

path: .metrics.loc.blank
old: 37.0
new: 15.0

path: .metrics.loc.ploc
old: 313.0
new: 52.0

path: .metrics.loc.sloc
old: 395.0
new: 77.0

path: .metrics.loc.lloc
old: 99.0
new: 23.0

path: .metrics.nom.total
old: 16.0
new: 4.0

path: .metrics.nom.functions
old: 15.0
new: 4.0

path: .metrics.nom.closures
old: 1.0
new: 0.0

path: .metrics.halstead.vocabulary
old: 282.0
new: 61.0

path: .metrics.halstead.effort
old: 716670.1920207205
new: 24479.975022850685

path: .metrics.halstead.estimated_program_length
old: 2163.731848257743
new: 311.13338933483533

path: .metrics.halstead.length
old: 1920.0
new: 247.0

path: .metrics.halstead.N2
old: 832.0
new: 94.0

path: .metrics.halstead.level
old: 0.021806318681318684
new: 0.05984042553191489

path: .metrics.halstead.bugs
old: 2.6694695600604423
new: 0.2810300272624841

path: .metrics.halstead.purity_ratio
old: 1.1269436709675744
new: 1.2596493495337462

path: .metrics.halstead.n1
old: 28.0
new: 16.0

path: .metrics.halstead.time
old: 39815.010667817805
new: 1359.9986123805936

path: .metrics.halstead.difficulty
old: 45.85826771653543
new: 16.711111111111112

path: .metrics.halstead.n2
old: 254.0
new: 45.0

path: .metrics.halstead.N1
old: 1088.0
new: 153.0

path: .metrics.halstead.volume
old: 15627.938596605683
new: 1464.892122378033

Spaces Data

Minimal test - lines (13, 77)

path: .spaces[0].metrics.nom.functions
old: 1.0
new: 4.0

path: .spaces[0].metrics.nom.total
old: 1.0
new: 4.0

path: .spaces[0].metrics.loc.sloc
old: 11.0
new: 65.0

path: .spaces[0].metrics.loc.cloc
old: 3.0
new: 4.0

path: .spaces[0].metrics.loc.blank
old: 0.0
new: 13.0

path: .spaces[0].metrics.loc.lloc
old: 3.0
new: 23.0

path: .spaces[0].metrics.loc.ploc
old: 8.0
new: 48.0

path: .spaces[0].metrics.cognitive.average
old: 3.0
new: 1.25

path: .spaces[0].metrics.cognitive.sum
old: 3.0
new: 5.0

path: .spaces[0].metrics.mi.mi_original
old: 102.65893123878548
new: 63.3407412449513

path: .spaces[0].metrics.mi.mi_visual_studio
old: 60.03446271274004
new: 37.04136914909433

path: .spaces[0].metrics.mi.mi_sei
old: 109.09501872178171
new: 35.44458502849898

path: .spaces[0].metrics.halstead.n1
old: 13.0
new: 16.0

path: .spaces[0].metrics.halstead.purity_ratio
old: 2.069565004992666
new: 1.1673235892565492

path: .spaces[0].metrics.halstead.difficulty
old: 8.357142857142858
new: 17.5609756097561

path: .spaces[0].metrics.halstead.volume
old: 232.98948760600993
new: 1417.392273442032

path: .spaces[0].metrics.halstead.time
old: 108.1736906742189
new: 1382.8217301873483

path: .spaces[0].metrics.halstead.N2
old: 18.0
new: 90.0

path: .spaces[0].metrics.halstead.n2
old: 14.0
new: 41.0

path: .spaces[0].metrics.halstead.bugs
old: 0.05197663746495015
new: 0.2841654100297851

path: .spaces[0].metrics.halstead.vocabulary
old: 27.0
new: 57.0

path: .spaces[0].metrics.halstead.estimated_program_length
old: 101.40868524464064
new: 283.65963218934144

path: .spaces[0].metrics.halstead.N1
old: 31.0
new: 153.0

path: .spaces[0].metrics.halstead.length
old: 49.0
new: 243.0

path: .spaces[0].metrics.halstead.level
old: 0.11965811965811964
new: 0.05694444444444444

path: .spaces[0].metrics.halstead.effort
old: 1947.12643213594
new: 24890.791143372273

path: .spaces[0].metrics.nargs.sum
old: 1.0
new: 4.0

path: .spaces[0].metrics.nexits.average
old: 2.0
new: 1.5

path: .spaces[0].metrics.nexits.sum
old: 2.0
new: 6.0

path: .spaces[0].metrics.cyclomatic.average
old: 5.0
new: 2.0

path: .spaces[0].metrics.cyclomatic.sum
old: 5.0
new: 10.0

Code

namespace mozilla {

/* static */ void GeckoProcessManager::Init() {
  BaseNatives::Init();
  ConnectionManager::Init();
}

NS_IMPL_ISUPPORTS(GeckoProcessManager::ConnectionManager, nsIObserver)

NS_IMETHODIMP GeckoProcessManager::ConnectionManager::Observe(
    nsISupports* aSubject, const char* aTopic, const char16_t* aData) {
  java::GeckoProcessManager::ConnectionManager::LocalRef connMgr(mJavaConnMgr);
  if (!connMgr) {
    return NS_OK;
  }

  if (!strcmp("application-foreground", aTopic)) {
    connMgr->OnForeground();
    return NS_OK;
  }

  if (!strcmp("application-background", aTopic)) {
    connMgr->OnBackground();
    return NS_OK;
  }

  if (!strcmp(NS_NETWORK_LINK_TOPIC, aTopic)) {
    const nsDependentString state(aData);
    // state can be up, down, or unknown. For the purposes of socket process
    // prioritization, we treat unknown as being up.
    const bool isUp = !state.EqualsLiteral(NS_NETWORK_LINK_DATA_DOWN);
    connMgr->OnNetworkStateChange(isUp);
    return NS_OK;
  }

  return NS_OK;
}

/* static */ void GeckoProcessManager::ConnectionManager::AttachTo(
    java::GeckoProcessManager::ConnectionManager::Param aInstance) {
  RefPtr native(new ConnectionManager());
  BaseNatives::AttachNative(aInstance, native);

  native->mJavaConnMgr = aInstance;

  nsCOMPtr obsServ(services::GetObserverService());
  obsServ->AddObserver(native, "application-background", false);
  obsServ->AddObserver(native, "application-foreground", false);
}

void GeckoProcessManager::ConnectionManager::ObserveNetworkNotifications() {
  nsCOMPtr obsServ(services::GetObserverService());
  obsServ->AddObserver(this, NS_NETWORK_LINK_TOPIC, false);

  const bool isUp = java::GeckoAppShell::IsNetworkLinkUp();

  java::GeckoProcessManager::ConnectionManager::LocalRef connMgr(mJavaConnMgr);
  if (!connMgr) {
    return;
  }

  connMgr->OnNetworkStateChange(isUp);
}

}  // namespace mozilla