|
Hi, I am loading an URL to the browser in a separate thread . While launching the url using attached code (nsTestImpl.cpp) i am getting the following error !!!!! XPConnect wrapper thread use error... XPConnect WrappedNative is being accessed on multiple threads but the underlying native xpcom object does not have a nsIClassInfo with the 'THREADSAFE' flag set wrapper: [object nsXPCComponents @ 0x833af60] JS call stack... 0 [native frame] 1 anonymous(aWebProgress = [xpconnect wrapped nsIWebProgress @ 0x86d4d68], aRequest = [xpconnect wrapped nsIRequest @ 0x88a6a80], aStateFlags = 458753, aStatus = 0) ["chrome://navigator/content/nsBrowserStatusHandler.js":175] nsIWebProgressListener = undefined nsIChannel = undefined ctype = undefined msg = undefined channel = undefined location = undefined kErrorBindingAborted = undefined kErrorNetTimeout = undefined this = [object Object] this.defaultStatus = "" this.overLink = "" this.jsStatus = "" this.jsDefaultStatus = "" this.status = "" this.securityButton = [object XULElement @ 0x87356d8] this.isImage = [object XULElement @ 0x872a2c0] this.statusTextField = [object XULElement @ 0x86a3dc8] this.stopContext = [object XULElement @ 0x8729cf0] this.stopMenu = [object XULElement @ 0x8729828] this.stopButton = [object XULElement @ 0x8621200] this.statusMeter = [object XULElement @ 0x87317f0] this.throbberElement = [object XULElement @ 0x86b0908] this.urlBar = [object XULElement @ 0x865b848] 2 [native frame] Please do help me to solve the problem. Thanks and Regards S.Srinivasa Raghavan |
nsTestImpl::nsTestImpl( )
{
nsresult rv;
NS_INIT_ISUPPORTS();
nsCOMPtr<nsIThread> thread;
rv = NS_NewThread(getter_AddRefs(thread),this);
if(NS_SUCCEEDED(rv))
{
cout<<"success sucess "<<endl;
}
}
nsTestImpl::~nsTestImpl( )
{
}
NS_IMPL_ISUPPORTS3_CI(nsTestImpl, nsITest, nsIObserver, nsIRunnable);
NS_IMETHODIMP nsTestImpl::Run()
{
cout<<"thread is sleeping "<<endl;
PR_Sleep(PR_MillisecondsToInterval(30000));
cout<<"thread is awakened"<<endl;
launchURL();
return NS_OK;
}
NS_IMETHODIMP nsTestImpl::Observe(nsISupports *aSubject, const char *aTopic,
const PRUnichar *aData)
{
return NS_OK;
}
NS_IMETHODIMP nsTestImpl::launchURL()
{
nsresult rv;
nsCOMPtr<nsIWindowMediator>windowMediator =
do_GetService(NS_WINDOWMEDIATOR_CONTRACTID,&rv);
if((NS_SUCCEEDED(rv)) && (windowMediator))
{
cout<<"window mediator is obtained "<<rv<<endl;
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
nsCOMPtr<nsIXULWindow> xulWindow;
rv =
windowMediator->GetXULWindowEnumerator(nsnull,getter_AddRefs(windowEnumerator));
if(NS_SUCCEEDED(rv)&&(windowEnumerator))
{
cout<<"winenum is obtained"<<endl;
PRBool more;
while(NS_SUCCEEDED(windowEnumerator->HasMoreElements(&more))
&& more)
{
nsCOMPtr<nsISupports> nextWindow = nsnull;
rv =
windowEnumerator->GetNext(getter_AddRefs(nextWindow));
if(NS_SUCCEEDED(rv) && nextWindow)
{
xulWindow = do_QueryInterface(nextWindow,&rv);
nsCOMPtr<nsIDocShellTreeItem>docshellitem;
if(xulWindow)
{
rv =
xulWindow->GetPrimaryContentShell(getter_AddRefs(docshellitem));
cout<<"the docshell item is
"<<rv<<endl;
if(docshellitem)
{
nsCOMPtr<nsIDocShell>rootDocShell = do_QueryInterface(docshellitem,&rv);
cout<<"root doc shell is
"<<rv<<endl;
nsCOMPtr<nsIWebNavigation>webNav(do_QueryInterface(rootDocShell));
if(webNav)
{
nsCOMPtr<nsIURI>newuri;
nsCOMPtr<nsIURI>newuri; rv =
webNav->GetCurrentURI(getter_AddRefs(newuri));
if(NS_SUCCEEDED(rv)&&(newuri))
{
nsEmbedCString
url;
newuri->GetSpec((nsACString &)url);
cout<<"the url
is "<<url.get()<<endl;
char* seturl =
"http://arc-server/";
webNav->LoadURI(NS_ConvertASCIItoUCS2(seturl).get(),nsIWebNavigation::LOAD_FLAGS_NONE,nsnull,nsnull,nsnull);
}
}
}
}
}
}
}
}
return NS_OK;
}
