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 "plevent.h"
|
---|
52 |
|
---|
53 | #include <iprt/thread.h>
|
---|
54 |
|
---|
55 | /* be761f00-a3b0-11d2-996c-0080c7cb1080 */
|
---|
56 | #define NS_EVENTQUEUESERVICE_CID \
|
---|
57 | { 0xbe761f00, 0xa3b0, 0x11d2, \
|
---|
58 | {0x99, 0x6c, 0x00, 0x80, 0xc7, 0xcb, 0x10, 0x80} }
|
---|
59 |
|
---|
60 | #define NS_EVENTQUEUESERVICE_CONTRACTID "@mozilla.org/event-queue-service;1"
|
---|
61 | #define NS_EVENTQUEUESERVICE_CLASSNAME "Event Queue Service"
|
---|
62 |
|
---|
63 | #define NS_CURRENT_THREAD ((RTTHREAD)0)
|
---|
64 | #define NS_CURRENT_EVENTQ ((nsIEventQueue*)0)
|
---|
65 |
|
---|
66 | #define NS_UI_THREAD ((RTTHREAD)1)
|
---|
67 | #define NS_UI_THREAD_EVENTQ ((nsIEventQueue*)1)
|
---|
68 |
|
---|
69 | %}
|
---|
70 |
|
---|
71 | [scriptable, uuid(a6cf90dc-15b3-11d2-932e-00805f8add32)]
|
---|
72 | interface nsIEventQueueService : nsISupports
|
---|
73 | {
|
---|
74 | /**
|
---|
75 | * Creates and holds a native event queue for the current thread.
|
---|
76 | * "Native" queues have an associated callback mechanism which is
|
---|
77 | * automatically triggered when an event is posted. See plevent.c for
|
---|
78 | * details.
|
---|
79 | * @return NS_OK on success, or a host of failure indications
|
---|
80 | */
|
---|
81 | void createThreadEventQueue();
|
---|
82 |
|
---|
83 | /**
|
---|
84 | * Creates and hold a monitored event queue for the current thread.
|
---|
85 | * "Monitored" queues have no callback processing mechanism.
|
---|
86 | * @return NS_OK on success, or a host of failure indications
|
---|
87 | */
|
---|
88 | void createMonitoredThreadEventQueue();
|
---|
89 |
|
---|
90 | /**
|
---|
91 | * Somewhat misnamed, this method releases the service's hold on the event
|
---|
92 | * queue(s) for this thread. Subsequent attempts to access this thread's
|
---|
93 | * queue (GetThreadEventQueue, for example) may fail, though the queue itself
|
---|
94 | * will be destroyed only after all references to it are released and the
|
---|
95 | * queue itself is no longer actively processing events.
|
---|
96 | * @return nonsense.
|
---|
97 | */
|
---|
98 | void destroyThreadEventQueue();
|
---|
99 |
|
---|
100 | [noscript] nsIEventQueue createFromIThread(in RTTHREAD aThread,
|
---|
101 | in boolean aNative);
|
---|
102 |
|
---|
103 | [noscript] nsIEventQueue createFromPLEventQueue(in PLEventQueuePtr
|
---|
104 | aPLEventQueue);
|
---|
105 |
|
---|
106 | // Add a new event queue for the current thread, making it the "current"
|
---|
107 | // queue. Return that queue, addrefed.
|
---|
108 | nsIEventQueue pushThreadEventQueue();
|
---|
109 |
|
---|
110 | // release and disable the queue
|
---|
111 | void popThreadEventQueue(in nsIEventQueue aQueue);
|
---|
112 |
|
---|
113 | [noscript] nsIEventQueue getThreadEventQueue(in RTTHREAD aThread);
|
---|
114 |
|
---|
115 | /**
|
---|
116 | * @deprecated in favor of getSpecialEventQueue, since that's
|
---|
117 | * scriptable and this isn't.
|
---|
118 | *
|
---|
119 | * Check for any "magic" event queue constants (NS_CURRENT_EVENTQ,
|
---|
120 | * NS_UI_THREAD_EVENTQ) and return the real event queue that they
|
---|
121 | * represent, AddRef()ed. Otherwise, return the event queue passed
|
---|
122 | * in, AddRef()ed. This is not scriptable because the arguments in
|
---|
123 | * question may be magic constants rather than real nsIEventQueues.
|
---|
124 | *
|
---|
125 | * @arg queueOrConstant either a real event queue or a magic
|
---|
126 | * constant to be resolved
|
---|
127 | *
|
---|
128 | * @return a real event queue, AddRef()ed
|
---|
129 | */
|
---|
130 | [noscript] nsIEventQueue resolveEventQueue(in nsIEventQueue queueOrConstant);
|
---|
131 |
|
---|
132 | /**
|
---|
133 | * Returns the appropriate special event queue, AddRef()ed. Really
|
---|
134 | * just a scriptable version of ResolveEventQueue.
|
---|
135 | *
|
---|
136 | * @arg aQueue Either CURRENT_THREAD_EVENT_QUEUE or
|
---|
137 | * UI_THREAD_EVENT_QUEUE
|
---|
138 | * @return The requested nsIEventQueue, AddRef()ed
|
---|
139 | * @exception NS_ERROR_NULL_POINTER Zero pointer passed in for return value
|
---|
140 | * @exception NS_ERROR_ILLEGAL_VALUE Bogus constant passed in aQueue
|
---|
141 | * @exception NS_ERROR_FAILURE Error while calling
|
---|
142 | * GetThreadEventQueue()
|
---|
143 | */
|
---|
144 | nsIEventQueue getSpecialEventQueue(in long aQueue);
|
---|
145 |
|
---|
146 | const long CURRENT_THREAD_EVENT_QUEUE = 0;
|
---|
147 | const long UI_THREAD_EVENT_QUEUE = 1;
|
---|
148 |
|
---|
149 | };
|
---|