Line data Source code
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
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef mozilla_dom_ProcessGlobal_h
8 : #define mozilla_dom_ProcessGlobal_h
9 :
10 : #include "mozilla/Attributes.h"
11 : #include "nsCOMPtr.h"
12 : #include "nsFrameMessageManager.h"
13 : #include "nsIScriptContext.h"
14 : #include "nsIScriptObjectPrincipal.h"
15 : #include "nsIScriptContext.h"
16 : #include "nsIClassInfo.h"
17 : #include "nsIRunnable.h"
18 : #include "nsIGlobalObject.h"
19 : #include "nsIScriptObjectPrincipal.h"
20 : #include "nsServiceManagerUtils.h"
21 : #include "nsWeakReference.h"
22 : #include "nsWrapperCache.h"
23 :
24 : namespace mozilla {
25 : namespace dom {
26 :
27 : class ProcessGlobal :
28 : public nsMessageManagerScriptExecutor,
29 : public nsIContentProcessMessageManager,
30 : public nsIGlobalObject,
31 : public nsIScriptObjectPrincipal,
32 : public nsSupportsWeakReference,
33 : public mozilla::dom::ipc::MessageManagerCallback,
34 : public nsWrapperCache
35 : {
36 : public:
37 : explicit ProcessGlobal(nsFrameMessageManager* aMessageManager);
38 :
39 : using mozilla::dom::ipc::MessageManagerCallback::GetProcessMessageManager;
40 :
41 : bool Init();
42 :
43 : static ProcessGlobal* Get();
44 :
45 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
46 1521 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(ProcessGlobal, nsIContentProcessMessageManager)
47 :
48 42 : NS_FORWARD_SAFE_NSIMESSAGELISTENERMANAGER(mMessageManager)
49 5 : NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager)
50 0 : NS_FORWARD_SAFE_NSISYNCMESSAGESENDER(mMessageManager)
51 0 : NS_FORWARD_SAFE_NSIMESSAGEMANAGERGLOBAL(mMessageManager)
52 10 : NS_FORWARD_SAFE_NSICONTENTPROCESSMESSAGEMANAGER(mMessageManager)
53 :
54 : virtual void LoadScript(const nsAString& aURL);
55 :
56 909 : virtual JSObject* GetGlobalJSObject() override
57 : {
58 909 : return mGlobal;
59 : }
60 0 : virtual nsIPrincipal* GetPrincipal() override { return mPrincipal; }
61 :
62 0 : virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override
63 : {
64 0 : MOZ_CRASH("ProcessGlobal doesn't use DOM bindings!");
65 : }
66 :
67 : void SetInitialProcessData(JS::HandleValue aInitialData);
68 :
69 : protected:
70 : virtual ~ProcessGlobal();
71 :
72 : private:
73 : bool mInitialized;
74 : RefPtr<nsFrameMessageManager> mMessageManager;
75 : };
76 :
77 : } // namespace dom
78 : } // namespace mozilla
79 :
80 : #endif // mozilla_dom_ProcessGlobal_h
|