1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
---|
2 | /* ***** BEGIN LICENSE BLOCK *****
|
---|
3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
---|
4 | *
|
---|
5 | * The contents of this file are subject to the Mozilla Public License Version
|
---|
6 | * 1.1 (the "License"); you may not use this file except in compliance with
|
---|
7 | * the License. You may obtain a copy of the License at
|
---|
8 | * http://www.mozilla.org/MPL/
|
---|
9 | *
|
---|
10 | * Software distributed under the License is distributed on an "AS IS" basis,
|
---|
11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
---|
12 | * for the specific language governing rights and limitations under the
|
---|
13 | * License.
|
---|
14 | *
|
---|
15 | * The Original Code is Mozilla Communicator client code.
|
---|
16 | *
|
---|
17 | * The Initial Developer of the Original Code is
|
---|
18 | * Netscape Communications Corporation.
|
---|
19 | * Portions created by the Initial Developer are Copyright (C) 1998
|
---|
20 | * the Initial Developer. All Rights Reserved.
|
---|
21 | *
|
---|
22 | * Contributor(s):
|
---|
23 | * Rick Potts <[email protected]>
|
---|
24 | * David Matiskella <[email protected]>
|
---|
25 | * David Hyatt <[email protected]>
|
---|
26 | * Suresh Duddi <[email protected]>
|
---|
27 | * Scott Collins <[email protected]>
|
---|
28 | * Dan Matejka <[email protected]>
|
---|
29 | * Doug Turner <[email protected]>
|
---|
30 | * Ray Whitmer <[email protected]>
|
---|
31 | * Dan Mosedale <[email protected]>
|
---|
32 | *
|
---|
33 | * Alternatively, the contents of this file may be used under the terms of
|
---|
34 | * either of the GNU General Public License Version 2 or later (the "GPL"),
|
---|
35 | * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
---|
36 | * in which case the provisions of the GPL or the LGPL are applicable instead
|
---|
37 | * of those above. If you wish to allow use of your version of this file only
|
---|
38 | * under the terms of either the GPL or the LGPL, and not to allow others to
|
---|
39 | * use your version of this file under the terms of the MPL, indicate your
|
---|
40 | * decision by deleting the provisions above and replace them with the notice
|
---|
41 | * and other provisions required by the GPL or the LGPL. If you do not delete
|
---|
42 | * the provisions above, a recipient may use your version of this file under
|
---|
43 | * the terms of any one of the MPL, the GPL or the LGPL.
|
---|
44 | *
|
---|
45 | * ***** END LICENSE BLOCK ***** */
|
---|
46 |
|
---|
47 | #include "nsISupports.idl"
|
---|
48 | #include "nsIEventQueue.idl"
|
---|
49 |
|
---|
50 | %{C++
|
---|
51 | #include "prthread.h"
|
---|
52 | #include "plevent.h"
|
---|
53 |
|
---|
54 | /* be761f00-a3b0-11d2-996c-0080c7cb1080 */
|
---|
55 | #define NS_EVENTQUEUESERVICE_CID \
|
---|
56 | { 0xbe761f00, 0xa3b0, 0x11d2, \
|
---|
57 | {0x99, 0x6c, 0x00, 0x80, 0xc7, 0xcb, 0x10, 0x80} }
|
---|
58 |
|
---|
59 | #define NS_EVENTQUEUESERVICE_CONTRACTID "@mozilla.org/event-queue-service;1"
|
---|
60 | #define NS_EVENTQUEUESERVICE_CLASSNAME "Event Queue Service"
|
---|
61 |
|
---|
62 | #define NS_CURRENT_THREAD ((PRThread*)0)
|
---|
63 | #define NS_CURRENT_EVENTQ ((nsIEventQueue*)0)
|
---|
64 |
|
---|
65 | #define NS_UI_THREAD ((PRThread*)1)
|
---|
66 | #define NS_UI_THREAD_EVENTQ ((nsIEventQueue*)1)
|
---|
67 |
|
---|
68 | %}
|
---|
69 |
|
---|
70 | /* a forward decl */
|
---|
71 | interface nsIThread;
|
---|
72 |
|
---|
73 | [scriptable, uuid(a6cf90dc-15b3-11d2-932e-00805f8add32)]
|
---|
74 | interface nsIEventQueueService : nsISupports
|
---|
75 | {
|
---|
76 | /**
|
---|
77 | * Creates and holds a native event queue for the current thread.
|
---|
78 | * "Native" queues have an associated callback mechanism which is
|
---|
79 | * automatically triggered when an event is posted. See plevent.c for
|
---|
80 | * details.
|
---|
81 | * @return NS_OK on success, or a host of failure indications
|
---|
82 | */
|
---|
83 | void createThreadEventQueue();
|
---|
84 |
|
---|
85 | /**
|
---|
86 | * Creates and hold a monitored event queue for the current thread.
|
---|
87 | * "Monitored" queues have no callback processing mechanism.
|
---|
88 | * @return NS_OK on success, or a host of failure indications
|
---|
89 | */
|
---|
90 | void createMonitoredThreadEventQueue();
|
---|
91 |
|
---|
92 | /**
|
---|
93 | * Somewhat misnamed, this method releases the service's hold on the event
|
---|
94 | * queue(s) for this thread. Subsequent attempts to access this thread's
|
---|
95 | * queue (GetThreadEventQueue, for example) may fail, though the queue itself
|
---|
96 | * will be destroyed only after all references to it are released and the
|
---|
97 | * queue itself is no longer actively processing events.
|
---|
98 | * @return nonsense.
|
---|
99 | */
|
---|
100 | void destroyThreadEventQueue();
|
---|
101 |
|
---|
102 | nsIEventQueue createFromIThread(in nsIThread aThread,
|
---|
103 | in boolean aNative);
|
---|
104 |
|
---|
105 | [noscript] nsIEventQueue createFromPLEventQueue(in PLEventQueuePtr
|
---|
106 | aPLEventQueue);
|
---|
107 |
|
---|
108 | // Add a new event queue for the current thread, making it the "current"
|
---|
109 | // queue. Return that queue, addrefed.
|
---|
110 | nsIEventQueue pushThreadEventQueue();
|
---|
111 |
|
---|
112 | // release and disable the queue
|
---|
113 | void popThreadEventQueue(in nsIEventQueue aQueue);
|
---|
114 |
|
---|
115 | [noscript] nsIEventQueue getThreadEventQueue(in PRThreadPtr aThread);
|
---|
116 |
|
---|
117 | /**
|
---|
118 | * @deprecated in favor of getSpecialEventQueue, since that's
|
---|
119 | * scriptable and this isn't.
|
---|
120 | *
|
---|
121 | * Check for any "magic" event queue constants (NS_CURRENT_EVENTQ,
|
---|
122 | * NS_UI_THREAD_EVENTQ) and return the real event queue that they
|
---|
123 | * represent, AddRef()ed. Otherwise, return the event queue passed
|
---|
124 | * in, AddRef()ed. This is not scriptable because the arguments in
|
---|
125 | * question may be magic constants rather than real nsIEventQueues.
|
---|
126 | *
|
---|
127 | * @arg queueOrConstant either a real event queue or a magic
|
---|
128 | * constant to be resolved
|
---|
129 | *
|
---|
130 | * @return a real event queue, AddRef()ed
|
---|
131 | */
|
---|
132 | [noscript] nsIEventQueue resolveEventQueue(in nsIEventQueue queueOrConstant);
|
---|
133 |
|
---|
134 | /**
|
---|
135 | * Returns the appropriate special event queue, AddRef()ed. Really
|
---|
136 | * just a scriptable version of ResolveEventQueue.
|
---|
137 | *
|
---|
138 | * @arg aQueue Either CURRENT_THREAD_EVENT_QUEUE or
|
---|
139 | * UI_THREAD_EVENT_QUEUE
|
---|
140 | * @return The requested nsIEventQueue, AddRef()ed
|
---|
141 | * @exception NS_ERROR_NULL_POINTER Zero pointer passed in for return value
|
---|
142 | * @exception NS_ERROR_ILLEGAL_VALUE Bogus constant passed in aQueue
|
---|
143 | * @exception NS_ERROR_FAILURE Error while calling
|
---|
144 | * GetThreadEventQueue()
|
---|
145 | */
|
---|
146 | nsIEventQueue getSpecialEventQueue(in long aQueue);
|
---|
147 |
|
---|
148 | const long CURRENT_THREAD_EVENT_QUEUE = 0;
|
---|
149 | const long UI_THREAD_EVENT_QUEUE = 1;
|
---|
150 |
|
---|
151 | };
|
---|