ipc/testshell/XPCShellEnvironment.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 #ifndef _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_
michael@0 6 #define _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_
michael@0 7
michael@0 8 #include "base/basictypes.h"
michael@0 9
michael@0 10 #include <string>
michael@0 11 #include <stdio.h>
michael@0 12
michael@0 13 #include "nsAutoJSValHolder.h"
michael@0 14 #include "nsCOMPtr.h"
michael@0 15 #include "nsDebug.h"
michael@0 16 #include "nsString.h"
michael@0 17 #include "nsJSPrincipals.h"
michael@0 18 #include "nsContentUtils.h"
michael@0 19 #include "js/TypeDecls.h"
michael@0 20
michael@0 21 struct JSPrincipals;
michael@0 22
michael@0 23 namespace mozilla {
michael@0 24 namespace ipc {
michael@0 25
michael@0 26 class XPCShellEnvironment
michael@0 27 {
michael@0 28 public:
michael@0 29 static XPCShellEnvironment* CreateEnvironment();
michael@0 30 ~XPCShellEnvironment();
michael@0 31
michael@0 32 void ProcessFile(JSContext *cx, JS::Handle<JSObject*> obj,
michael@0 33 const char *filename, FILE *file, bool forceTTY);
michael@0 34 bool EvaluateString(const nsString& aString,
michael@0 35 nsString* aResult = nullptr);
michael@0 36
michael@0 37 JSPrincipals* GetPrincipal() {
michael@0 38 return nsJSPrincipals::get(nsContentUtils::GetSystemPrincipal());
michael@0 39 }
michael@0 40
michael@0 41 JSObject* GetGlobalObject() {
michael@0 42 return mGlobalHolder.ToJSObject();
michael@0 43 }
michael@0 44
michael@0 45 void SetIsQuitting() {
michael@0 46 mQuitting = true;
michael@0 47 }
michael@0 48 bool IsQuitting() {
michael@0 49 return mQuitting;
michael@0 50 }
michael@0 51
michael@0 52 protected:
michael@0 53 XPCShellEnvironment();
michael@0 54 bool Init();
michael@0 55
michael@0 56 private:
michael@0 57 nsAutoJSValHolder mGlobalHolder;
michael@0 58
michael@0 59 bool mQuitting;
michael@0 60 };
michael@0 61
michael@0 62 } /* namespace ipc */
michael@0 63 } /* namespace mozilla */
michael@0 64
michael@0 65 #endif /* _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_ */

mercurial