/src/mozilla-central/dom/workers/WorkerError.h
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 | | #ifndef mozilla_dom_workers_WorkerError_h |
8 | | #define mozilla_dom_workers_WorkerError_h |
9 | | |
10 | | #include "WorkerCommon.h" |
11 | | #include "jsapi.h" |
12 | | |
13 | | namespace mozilla { |
14 | | |
15 | | class DOMEventTargetHelper; |
16 | | |
17 | | namespace dom { |
18 | | |
19 | | class WorkerErrorBase |
20 | | { |
21 | | public: |
22 | | nsString mMessage; |
23 | | nsString mFilename; |
24 | | uint32_t mLineNumber; |
25 | | uint32_t mColumnNumber; |
26 | | uint32_t mErrorNumber; |
27 | | |
28 | | WorkerErrorBase() |
29 | | : mLineNumber(0), |
30 | | mColumnNumber(0), |
31 | | mErrorNumber(0) |
32 | 0 | { } |
33 | | |
34 | | void AssignErrorBase(JSErrorBase* aReport); |
35 | | }; |
36 | | |
37 | | class WorkerErrorNote : public WorkerErrorBase |
38 | | { |
39 | | public: |
40 | | void AssignErrorNote(JSErrorNotes::Note* aNote); |
41 | | }; |
42 | | |
43 | | class WorkerPrivate; |
44 | | |
45 | | class WorkerErrorReport : public WorkerErrorBase |
46 | | { |
47 | | public: |
48 | | nsString mLine; |
49 | | uint32_t mFlags; |
50 | | JSExnType mExnType; |
51 | | bool mMutedError; |
52 | | nsTArray<WorkerErrorNote> mNotes; |
53 | | |
54 | | WorkerErrorReport() |
55 | | : mFlags(0), |
56 | | mExnType(JSEXN_ERR), |
57 | | mMutedError(false) |
58 | 0 | { } |
59 | | |
60 | | void AssignErrorReport(JSErrorReport* aReport); |
61 | | |
62 | | // aWorkerPrivate is the worker thread we're on (or the main thread, if null) |
63 | | // aTarget is the worker object that we are going to fire an error at |
64 | | // (if any). |
65 | | static void |
66 | | ReportError(JSContext* aCx, WorkerPrivate* aWorkerPrivate, |
67 | | bool aFireAtScope, DOMEventTargetHelper* aTarget, |
68 | | const WorkerErrorReport& aReport, uint64_t aInnerWindowId, |
69 | | JS::Handle<JS::Value> aException = JS::NullHandleValue); |
70 | | |
71 | | static void |
72 | | LogErrorToConsole(const WorkerErrorReport& aReport, uint64_t aInnerWindowId); |
73 | | |
74 | | static void |
75 | | CreateAndDispatchGenericErrorRunnableToParent(WorkerPrivate* aWorkerPrivate); |
76 | | }; |
77 | | |
78 | | } // dom namespace |
79 | | } // mozilla namespace |
80 | | |
81 | | #endif // mozilla_dom_workers_WorkerError_h |