js/src/vm/ErrorObject.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
michael@0 2 * vim: set ts=8 sts=4 et sw=4 tw=99:
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef vm_ErrorObject_h_
michael@0 8 #define vm_ErrorObject_h_
michael@0 9
michael@0 10 #include "jsobj.h"
michael@0 11
michael@0 12 #include "vm/Shape.h"
michael@0 13
michael@0 14 struct JSExnPrivate;
michael@0 15
michael@0 16 /*
michael@0 17 * Initialize the exception constructor/prototype hierarchy.
michael@0 18 */
michael@0 19 extern JSObject *
michael@0 20 js_InitExceptionClasses(JSContext *cx, JS::HandleObject obj);
michael@0 21
michael@0 22 namespace js {
michael@0 23
michael@0 24 class ErrorObject : public JSObject
michael@0 25 {
michael@0 26 static ErrorObject *
michael@0 27 createProto(JSContext *cx, JS::Handle<GlobalObject*> global, JSExnType type,
michael@0 28 JS::HandleObject proto);
michael@0 29
michael@0 30 /* For access to createProto. */
michael@0 31 friend JSObject *
michael@0 32 ::js_InitExceptionClasses(JSContext *cx, JS::HandleObject global);
michael@0 33
michael@0 34 /* For access to assignInitialShape. */
michael@0 35 friend bool
michael@0 36 EmptyShape::ensureInitialCustomShape<ErrorObject>(ExclusiveContext *cx,
michael@0 37 Handle<ErrorObject*> obj);
michael@0 38
michael@0 39 /*
michael@0 40 * Assign the initial error shape to the empty object. (This shape does
michael@0 41 * *not* include .message, which must be added separately if needed; see
michael@0 42 * ErrorObject::init.)
michael@0 43 */
michael@0 44 static Shape *
michael@0 45 assignInitialShape(ExclusiveContext *cx, Handle<ErrorObject*> obj);
michael@0 46
michael@0 47 static bool
michael@0 48 init(JSContext *cx, Handle<ErrorObject*> obj, JSExnType type,
michael@0 49 ScopedJSFreePtr<JSErrorReport> *errorReport, HandleString fileName, HandleString stack,
michael@0 50 uint32_t lineNumber, uint32_t columnNumber, HandleString message);
michael@0 51
michael@0 52 protected:
michael@0 53 static const uint32_t EXNTYPE_SLOT = 0;
michael@0 54 static const uint32_t ERROR_REPORT_SLOT = EXNTYPE_SLOT + 1;
michael@0 55 static const uint32_t FILENAME_SLOT = ERROR_REPORT_SLOT + 1;
michael@0 56 static const uint32_t LINENUMBER_SLOT = FILENAME_SLOT + 1;
michael@0 57 static const uint32_t COLUMNNUMBER_SLOT = LINENUMBER_SLOT + 1;
michael@0 58 static const uint32_t STACK_SLOT = COLUMNNUMBER_SLOT + 1;
michael@0 59 static const uint32_t MESSAGE_SLOT = STACK_SLOT + 1;
michael@0 60
michael@0 61 static const uint32_t RESERVED_SLOTS = MESSAGE_SLOT + 1;
michael@0 62
michael@0 63 public:
michael@0 64 static const Class class_;
michael@0 65
michael@0 66 // Create an error of the given type corresponding to the provided location
michael@0 67 // info. If |message| is non-null, then the error will have a .message
michael@0 68 // property with that value; otherwise the error will have no .message
michael@0 69 // property.
michael@0 70 static ErrorObject *
michael@0 71 create(JSContext *cx, JSExnType type, HandleString stack, HandleString fileName,
michael@0 72 uint32_t lineNumber, uint32_t columnNumber, ScopedJSFreePtr<JSErrorReport> *report,
michael@0 73 HandleString message);
michael@0 74
michael@0 75 JSExnType type() const {
michael@0 76 return JSExnType(getReservedSlot(EXNTYPE_SLOT).toInt32());
michael@0 77 }
michael@0 78
michael@0 79 JSErrorReport * getErrorReport() const {
michael@0 80 const Value &slot = getReservedSlot(ERROR_REPORT_SLOT);
michael@0 81 if (slot.isUndefined())
michael@0 82 return nullptr;
michael@0 83 return static_cast<JSErrorReport*>(slot.toPrivate());
michael@0 84 }
michael@0 85
michael@0 86 JSErrorReport * getOrCreateErrorReport(JSContext *cx);
michael@0 87
michael@0 88 inline JSString * fileName(JSContext *cx) const;
michael@0 89 inline uint32_t lineNumber() const;
michael@0 90 inline uint32_t columnNumber() const;
michael@0 91 inline JSString * stack(JSContext *cx) const;
michael@0 92
michael@0 93 JSString * getMessage() const {
michael@0 94 const HeapSlot &slot = getReservedSlotRef(MESSAGE_SLOT);
michael@0 95 return slot.isString() ? slot.toString() : nullptr;
michael@0 96 }
michael@0 97 };
michael@0 98
michael@0 99 } // namespace js
michael@0 100
michael@0 101 #endif // vm_ErrorObject_h_

mercurial