Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/xhr/XMLHttpRequest.cpp
Line
Count
Source (jump to first uncovered line)
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 "XMLHttpRequest.h"
8
#include "XMLHttpRequestMainThread.h"
9
#include "XMLHttpRequestWorker.h"
10
11
namespace mozilla {
12
namespace dom {
13
14
/* static */ already_AddRefed<XMLHttpRequest>
15
XMLHttpRequest::Constructor(const GlobalObject& aGlobal,
16
                            const MozXMLHttpRequestParameters& aParams,
17
                            ErrorResult& aRv)
18
0
{
19
0
  if (NS_IsMainThread()) {
20
0
    nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
21
0
    nsCOMPtr<nsIScriptObjectPrincipal> principal =
22
0
      do_QueryInterface(aGlobal.GetAsSupports());
23
0
    if (!global || ! principal) {
24
0
      aRv.Throw(NS_ERROR_FAILURE);
25
0
      return nullptr;
26
0
    }
27
0
28
0
    RefPtr<XMLHttpRequestMainThread> req = new XMLHttpRequestMainThread();
29
0
    req->Construct(principal->GetPrincipal(), global);
30
0
    req->InitParameters(aParams.mMozAnon, aParams.mMozSystem);
31
0
    return req.forget();
32
0
  }
33
0
34
0
  return XMLHttpRequestWorker::Construct(aGlobal, aParams, aRv);
35
0
}
36
37
} // dom namespace
38
} // mozilla namespace