Changing the debug robot to be able to cope with the parser push model.

Updated the robot sink apis.
Fixed the global url holder in the destructor of the parser.
Changed the robot observer to set a flag when completed parsing of a
url so that it doesn't create lottsa little parsers.
This commit is contained in:
jevering
1998-05-28 00:21:34 +00:00
parent 4924af4ba4
commit f1174128f0
8 changed files with 236 additions and 118 deletions

View File

@@ -38,6 +38,7 @@ public:
NS_IMETHOD ProcessLink(const nsString& aURLSpec);
NS_IMETHOD VerifyDirectory (const char * verify_dir);
NS_IMETHOD ReadyForNextUrl(void);
};
@@ -46,6 +47,7 @@ static nsVoidArray * g_duplicateList;
static int g_iProcessed;
static int g_iMaxProcess = 5000;
static PRBool g_bHitTop;
static PRBool g_bReadyForNextUrl;
NS_IMPL_ISUPPORTS(RobotSinkObserver, kIRobotSinkObserverIID);
@@ -54,6 +56,12 @@ NS_IMETHODIMP RobotSinkObserver::VerifyDirectory(const char * verify_dir)
return NS_OK;
}
NS_IMETHODIMP RobotSinkObserver::ReadyForNextUrl(void)
{
g_bReadyForNextUrl = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP RobotSinkObserver::ProcessLink(const nsString& aURLSpec)
{
if (!g_bHitTop) {
@@ -156,11 +164,15 @@ extern "C" NS_EXPORT int DebugRobot(
sink->AddObserver(myObserver);
parser->SetContentSink(sink);
g_bReadyForNextUrl = PR_FALSE;
parser->Parse(url);
if (yieldProc != NULL)
(*yieldProc)(url->GetSpec());
while (!g_bReadyForNextUrl) {
if (yieldProc != NULL)
(*yieldProc)(url->GetSpec());
}
if (ww)
ww->LoadURL(url->GetSpec());
ww->LoadURL(url->GetSpec());
NS_RELEASE(sink);
NS_RELEASE(parser);
NS_RELEASE(url);