Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Mullvad Browser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
The Tor Project
Applications
Mullvad Browser
Commits
f7516c37
Commit
f7516c37
authored
26 years ago
by
rods%netscape.com
Browse files
Options
Downloads
Patches
Plain Diff
AppCores are now mantained in a nsVoidArray
parent
c2e6ccb3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
xpfe/AppCores/src/nsAppCoresManager.cpp
+99
-158
99 additions, 158 deletions
xpfe/AppCores/src/nsAppCoresManager.cpp
xpfe/AppCores/src/nsAppCoresManager.h
+3
-10
3 additions, 10 deletions
xpfe/AppCores/src/nsAppCoresManager.h
with
102 additions
and
168 deletions
xpfe/AppCores/src/nsAppCoresManager.cpp
+
99
−
158
View file @
f7516c37
...
...
@@ -88,27 +88,23 @@ static NS_DEFINE_IID(kAppCoresFactoryCID, NS_APPCORESFACTORY_CID);
static
NS_DEFINE_IID
(
kMailCoreFactoryCID
,
NS_MAILCOREFACTORY_CID
);
static
SDL_TaskList
*
gTasks
=
nsnull
;
static
SDL_TaskList
*
gNextReadyTask
=
nsnull
;
/////////////////////////////////////////////////////////////////////////
// nsAppCoresManager
/////////////////////////////////////////////////////////////////////////
nsAppCoresManager
::
nsAppCoresManager
()
{
mScriptObject
=
nsnull
;
IncInstanceCount
();
NS_INIT_REFCNT
();
mScriptObject
=
nsnull
;
IncInstanceCount
();
NS_INIT_REFCNT
();
}
//--------------------------------------------------------
nsAppCoresManager
::~
nsAppCoresManager
()
{
DecInstanceCount
();
DecInstanceCount
();
}
...
...
@@ -121,41 +117,36 @@ NS_IMPL_RELEASE(nsAppCoresManager)
NS_IMETHODIMP
nsAppCoresManager
::
QueryInterface
(
REFNSIID
aIID
,
void
**
aInstancePtr
)
{
if
(
aInstancePtr
==
NULL
)
{
return
NS_ERROR_NULL_POINTER
;
}
if
(
aInstancePtr
==
NULL
)
{
return
NS_ERROR_NULL_POINTER
;
}
// Always NULL result, in case of failure
*
aInstancePtr
=
NULL
;
// Always NULL result, in case of failure
*
aInstancePtr
=
NULL
;
if
(
aIID
.
Equals
(
kIAppCoresManagerIID
)
)
{
nsIDOMAppCoresManager
*
tmp
=
this
;
*
aInstancePtr
=
(
void
*
)
tmp
;
AddRef
();
return
NS_OK
;
}
else
if
(
aIID
.
Equals
(
kIScriptObjectOwnerIID
))
{
nsIScriptObjectOwner
*
tmp
=
this
;
*
aInstancePtr
=
(
void
*
)
tmp
;
AddRef
();
return
NS_OK
;
}
else
if
(
aIID
.
Equals
(
kISupportsIID
)
)
{
nsIDOMAppCoresManager
*
tmp1
=
this
;
nsISupports
*
tmp2
=
tmp1
;
if
(
aIID
.
Equals
(
kIAppCoresManagerIID
)
)
{
nsIDOMAppCoresManager
*
tmp
=
this
;
*
aInstancePtr
=
(
void
*
)
tmp
;
AddRef
();
return
NS_OK
;
}
else
if
(
aIID
.
Equals
(
kIScriptObjectOwnerIID
))
{
nsIScriptObjectOwner
*
tmp
=
this
;
*
aInstancePtr
=
(
void
*
)
tmp
;
AddRef
();
return
NS_OK
;
}
else
if
(
aIID
.
Equals
(
kISupportsIID
)
)
{
nsIDOMAppCoresManager
*
tmp1
=
this
;
nsISupports
*
tmp2
=
tmp1
;
*
aInstancePtr
=
(
void
*
)
tmp2
;
AddRef
();
return
NS_OK
;
}
*
aInstancePtr
=
(
void
*
)
tmp2
;
AddRef
();
return
NS_OK
;
}
return
NS_NOINTERFACE
;
return
NS_NOINTERFACE
;
}
...
...
@@ -163,20 +154,17 @@ nsAppCoresManager::QueryInterface(REFNSIID aIID,void** aInstancePtr)
NS_IMETHODIMP
nsAppCoresManager
::
GetScriptObject
(
nsIScriptContext
*
aContext
,
void
**
aScriptObject
)
{
nsresult
res
=
NS_OK
;
if
(
nsnull
==
mScriptObject
)
{
nsIScriptGlobalObject
*
global
=
aContext
->
GetGlobalObject
();
res
=
NS_NewScriptAppCoresManager
(
aContext
,
(
nsISupports
*
)(
nsIDOMAppCoresManager
*
)
this
,
global
,
(
void
**
)
&
mScriptObject
);
NS_IF_RELEASE
(
global
);
}
nsresult
res
=
NS_OK
;
if
(
nsnull
==
mScriptObject
)
{
nsIScriptGlobalObject
*
global
=
aContext
->
GetGlobalObject
();
res
=
NS_NewScriptAppCoresManager
(
aContext
,
(
nsISupports
*
)(
nsIDOMAppCoresManager
*
)
this
,
global
,
(
void
**
)
&
mScriptObject
);
NS_IF_RELEASE
(
global
);
}
*
aScriptObject
=
mScriptObject
;
return
res
;
*
aScriptObject
=
mScriptObject
;
return
res
;
}
//--------------------------------------------------------
...
...
@@ -191,118 +179,74 @@ nsAppCoresManager::SetScriptObject(void *aScriptObject)
NS_IMETHODIMP
nsAppCoresManager
::
Startup
()
{
/***************************************/
/* Add us to the Javascript Name Space */
/***************************************/
/* Add us to the Javascript Name Space */
/***************************************/
nsIScriptNameSetRegistry
*
registry
;
nsresult
result
=
nsServiceManager
::
GetService
(
kCScriptNameSetRegistryCID
,
kIScriptNameSetRegistryIID
,
(
nsISupports
**
)
&
registry
);
if
(
NS_OK
==
result
)
{
nsAppCoresNameSet
*
nameSet
=
new
nsAppCoresNameSet
();
registry
->
AddExternalNameSet
(
nameSet
);
/* FIX - do we need to release this service? When we do, it get deleted,and our name is lost. */
}
return
result
;
}
nsIScriptNameSetRegistry
*
registry
;
nsresult
result
=
nsServiceManager
::
GetService
(
kCScriptNameSetRegistryCID
,
kIScriptNameSetRegistryIID
,
(
nsISupports
**
)
&
registry
);
if
(
NS_OK
==
result
)
{
nsAppCoresNameSet
*
nameSet
=
new
nsAppCoresNameSet
();
registry
->
AddExternalNameSet
(
nameSet
);
/* FIX - do we need to release this service? When we do, it get deleted,and our name is lost. */
}
return
result
;
static
PRBool
CleanUp
(
void
*
aElement
,
void
*
aData
)
{
nsIDOMBaseAppCore
*
appCore
=
(
nsIDOMBaseAppCore
*
)
aElement
;
NS_RELEASE
(
appCore
);
return
PR_TRUE
;
}
//--------------------------------------------------------
NS_IMETHODIMP
nsAppCoresManager
::
Shutdown
()
{
return
NS_OK
;
mList
.
EnumerateForwards
(
CleanUp
,
nsnull
);
return
NS_OK
;
}
//--------------------------------------------------------
NS_IMETHODIMP
nsAppCoresManager
::
Add
(
nsIDOMBaseAppCore
*
a
Task
)
nsAppCoresManager
::
Add
(
nsIDOMBaseAppCore
*
a
AppCore
)
{
if
(
aTask
==
NULL
)
return
NS_ERROR_FAILURE
;
/* Check to see if we already have this task in our list */
SDL_TaskList
*
node
=
gTasks
;
nsString
nodeIDString
;
nsString
addIDString
;
aTask
->
GetId
(
addIDString
);
while
(
node
!=
NULL
)
{
node
->
task
->
GetId
(
nodeIDString
);
if
(
nodeIDString
==
addIDString
)
{
/*we already have this ID in our list, ignore */
return
NS_OK
;
}
node
=
node
->
next
;
if
(
aAppCore
==
NULL
)
return
NS_ERROR_FAILURE
;
/* Check to see if we already have this task in our list */
nsString
nodeIDString
;
nsString
addIDString
;
aAppCore
->
GetId
(
addIDString
);
PRInt32
i
;
for
(
i
=
0
;
i
<
mList
.
Count
();
i
++
)
{
((
nsIDOMBaseAppCore
*
)
mList
[
i
])
->
GetId
(
nodeIDString
);
if
(
nodeIDString
==
addIDString
)
{
/*we already have this ID in our list, ignore */
return
NS_ERROR_FAILURE
;
}
}
/* add the task to our list */
SDL_TaskList
*
taskNode
=
(
SDL_TaskList
*
)
PR_MALLOC
(
sizeof
(
SDL_TaskList
));
aTask
->
AddRef
();
taskNode
->
next
=
gTasks
;
taskNode
->
task
=
aTask
;
gTasks
=
taskNode
;
aAppCore
->
AddRef
();
mList
.
AppendElement
(
aAppCore
);
/* Lets set the next task to run to this one */
gNextReadyTask
=
taskNode
;
return
NS_OK
;
return
NS_OK
;
}
//--------------------------------------------------------
NS_IMETHODIMP
nsAppCoresManager
::
Remove
(
nsIDOMBaseAppCore
*
a
Task
)
nsAppCoresManager
::
Remove
(
nsIDOMBaseAppCore
*
a
AppCore
)
{
if
(
aTask
==
NULL
)
return
NS_ERROR_FAILURE
;
/* Remove from our list */
SDL_TaskList
*
node
=
gTasks
;
SDL_TaskList
*
lastnode
=
gTasks
;
nsString
nodeIDString
;
nsString
doomedIDString
;
aTask
->
GetId
(
doomedIDString
);
while
(
node
!=
NULL
)
{
node
->
task
->
GetId
(
nodeIDString
);
if
(
nodeIDString
==
doomedIDString
)
{
/* we want to delete this node */
if
(
node
==
gTasks
)
{
gTasks
=
node
->
next
;
}
else
{
lastnode
->
next
=
node
->
next
;
}
node
->
task
->
Release
();
PR_DELETE
(
node
);
break
;
}
lastnode
=
node
;
node
=
node
->
next
;
}
return
NS_OK
;
return
(
mList
.
RemoveElement
(
aAppCore
)
?
NS_OK
:
NS_ERROR_FAILURE
);
}
...
...
@@ -310,25 +254,22 @@ nsAppCoresManager::Remove(nsIDOMBaseAppCore* aTask)
NS_IMETHODIMP
nsAppCoresManager
::
Find
(
const
nsString
&
aId
,
nsIDOMBaseAppCore
**
aReturn
)
{
*
aReturn
=
nsnull
;
SDL_TaskList
*
node
=
gTasks
;
nsString
nodeIDString
;
while
(
node
!=
NULL
)
{
node
->
task
->
GetId
(
nodeIDString
);
if
(
nodeIDString
==
aId
)
{
*
aReturn
=
node
->
task
;
node
->
task
->
AddRef
();
break
;
}
node
=
node
->
next
;
*
aReturn
=
nsnull
;
nsString
nodeIDString
;
PRInt32
i
;
for
(
i
=
0
;
i
<
mList
.
Count
();
i
++
)
{
nsIDOMBaseAppCore
*
appCore
=
(
nsIDOMBaseAppCore
*
)
mList
.
ElementAt
(
i
);
appCore
->
GetId
(
nodeIDString
);
if
(
nodeIDString
==
aId
)
{
NS_ADDREF
(
appCore
);
*
aReturn
=
appCore
;
return
NS_OK
;
}
}
return
NS_OK
;
return
NS_OK
;
}
...
...
This diff is collapsed.
Click to expand it.
xpfe/AppCores/src/nsAppCoresManager.h
+
3
−
10
View file @
f7516c37
...
...
@@ -24,6 +24,7 @@
#include
"nsIScriptObjectOwner.h"
#include
"nsIDOMAppCoresManager.h"
#include
"prio.h"
#include
"nsVoidArray.h"
class
nsIScriptContext
;
class
nsIDOMBaseAppCore
;
...
...
@@ -31,15 +32,6 @@ class nsIDOMBaseAppCore;
////////////////////////////////////////////////////////////////////////////////
// nsAppCoresManager:
////////////////////////////////////////////////////////////////////////////////
typedef
struct
_SDL_TaskList
SDL_TaskList
;
typedef
struct
_SDL_TaskList
{
nsIDOMBaseAppCore
*
task
;
SDL_TaskList
*
next
;
}
SDL_TaskList
;
class
nsAppCoresManager
:
public
nsIScriptObjectOwner
,
public
nsIDOMAppCoresManager
{
public:
...
...
@@ -63,7 +55,8 @@ class nsAppCoresManager : public nsIScriptObjectOwner, public nsIDOMAppCoresMana
NS_IMETHOD
Find
(
const
nsString
&
aId
,
nsIDOMBaseAppCore
**
aReturn
);
private:
void
*
mScriptObject
;
void
*
mScriptObject
;
nsVoidArray
mList
;
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment