1999-04-06 01:06:07 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "nsIFileTransportService.h"
|
|
|
|
#include "nsIStreamListener.h"
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIInputStream.h"
|
|
|
|
#include "nsIThread.h"
|
1999-05-06 02:41:44 +04:00
|
|
|
#include "nsIEventQueue.h"
|
|
|
|
#include "nsIEventQueueService.h"
|
1999-04-06 01:06:07 +04:00
|
|
|
#include "prinrval.h"
|
1999-05-04 23:33:37 +04:00
|
|
|
#include "prmon.h"
|
1999-04-06 10:11:23 +04:00
|
|
|
#include "prio.h"
|
1999-04-06 01:06:07 +04:00
|
|
|
#include "nsIFileStream.h"
|
|
|
|
#include "nsFileSpec.h"
|
1999-04-06 05:45:24 +04:00
|
|
|
#include "nsIByteBufferInputStream.h"
|
1999-04-06 10:11:23 +04:00
|
|
|
#include "nsIThread.h"
|
|
|
|
#include "nsISupportsArray.h"
|
|
|
|
#include "nsITransport.h"
|
1999-04-06 01:06:07 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
|
1999-05-09 23:18:25 +04:00
|
|
|
#ifdef XP_PC
|
|
|
|
#define XPCOM_DLL "xpcom32.dll"
|
|
|
|
#define NETLIB_DLL "netwerk.dll"
|
|
|
|
#else
|
|
|
|
#ifdef XP_MAC
|
|
|
|
#include "nsMacRepository.h"
|
|
|
|
#else
|
|
|
|
#define XPCOM_DLL "libxpcom.so"
|
|
|
|
#define NETLIB_DLL "libnetwerk.so"
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
1999-04-06 01:06:07 +04:00
|
|
|
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
|
|
|
static NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID);
|
1999-05-09 23:18:25 +04:00
|
|
|
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUE_CID);
|
1999-04-06 01:06:07 +04:00
|
|
|
|
|
|
|
PRIntervalTime gDuration = 0;
|
1999-04-06 10:11:23 +04:00
|
|
|
PRUint32 gVolume = 0;
|
1999-04-06 01:06:07 +04:00
|
|
|
|
|
|
|
class nsReader : public nsIRunnable, public nsIStreamListener {
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
NS_IMETHOD Run() {
|
1999-05-09 23:18:25 +04:00
|
|
|
printf("waiting\n");
|
1999-05-04 23:33:37 +04:00
|
|
|
if (!mMonitor)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
PR_EnterMonitor(mMonitor);
|
1999-04-06 01:06:07 +04:00
|
|
|
if (mEventQueue == nsnull)
|
|
|
|
PR_CWait(this, PR_INTERVAL_NO_TIMEOUT);
|
1999-05-04 23:33:37 +04:00
|
|
|
PR_ExitMonitor(mMonitor);
|
1999-04-06 01:06:07 +04:00
|
|
|
|
1999-05-09 23:18:25 +04:00
|
|
|
printf("running\n");
|
1999-05-06 02:41:44 +04:00
|
|
|
|
|
|
|
// event loop
|
1999-05-06 23:47:55 +04:00
|
|
|
mEventQueue->EventLoop();
|
1999-05-06 02:41:44 +04:00
|
|
|
|
|
|
|
while (PR_TRUE) {
|
|
|
|
|
|
|
|
}
|
1999-05-09 23:18:25 +04:00
|
|
|
printf("quitting\n");
|
1999-04-06 01:06:07 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-06 10:11:23 +04:00
|
|
|
nsReader()
|
|
|
|
: mEventQueue(nsnull), mStartTime(0), mThread(nsnull)
|
|
|
|
{
|
1999-04-06 01:06:07 +04:00
|
|
|
NS_INIT_REFCNT();
|
1999-05-04 23:33:37 +04:00
|
|
|
mMonitor = PR_NewMonitor();
|
1999-04-06 01:06:07 +04:00
|
|
|
}
|
|
|
|
|
1999-04-06 10:11:23 +04:00
|
|
|
virtual ~nsReader() {
|
|
|
|
NS_IF_RELEASE(mThread);
|
1999-05-06 02:41:44 +04:00
|
|
|
NS_IF_RELEASE(mEventQueue);
|
1999-05-04 23:33:37 +04:00
|
|
|
PR_DestroyMonitor(mMonitor);
|
1999-04-06 10:11:23 +04:00
|
|
|
}
|
|
|
|
|
1999-04-06 01:06:07 +04:00
|
|
|
nsresult Init(nsIThread* thread) {
|
1999-05-06 02:41:44 +04:00
|
|
|
nsresult rv;
|
1999-04-06 10:11:23 +04:00
|
|
|
mThread = thread;
|
|
|
|
NS_ADDREF(mThread);
|
1999-04-06 01:06:07 +04:00
|
|
|
PRThread* prthread;
|
|
|
|
thread->GetPRThread(&prthread);
|
1999-05-04 23:33:37 +04:00
|
|
|
PR_EnterMonitor(mMonitor);
|
1999-05-09 23:18:25 +04:00
|
|
|
NS_WITH_SERVICE(nsIEventQueueService, eventQService, kEventQueueServiceCID, &rv);
|
1999-05-06 02:41:44 +04:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
rv = eventQService->GetThreadEventQueue(PR_CurrentThread(), &mEventQueue);
|
|
|
|
}
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
1999-04-06 01:06:07 +04:00
|
|
|
// wake up event loop
|
1999-05-04 23:33:37 +04:00
|
|
|
PR_Notify(mMonitor);
|
|
|
|
PR_ExitMonitor(mMonitor);
|
1999-04-06 01:06:07 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-05-06 02:41:44 +04:00
|
|
|
nsIEventQueue* GetEventQueue() { return mEventQueue; }
|
1999-04-06 01:06:07 +04:00
|
|
|
|
1999-04-06 10:11:23 +04:00
|
|
|
NS_IMETHOD OnStartBinding(nsISupports* context) {
|
1999-05-04 23:33:37 +04:00
|
|
|
PR_EnterMonitor(mMonitor);
|
1999-05-09 23:18:25 +04:00
|
|
|
printf("start binding\n");
|
1999-04-06 01:06:07 +04:00
|
|
|
mStartTime = PR_IntervalNow();
|
1999-05-04 23:33:37 +04:00
|
|
|
PR_ExitMonitor(mMonitor);
|
1999-04-06 01:06:07 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-06 10:11:23 +04:00
|
|
|
NS_IMETHOD OnDataAvailable(nsISupports* context,
|
1999-04-06 01:06:07 +04:00
|
|
|
nsIInputStream *aIStream,
|
1999-04-22 12:47:06 +04:00
|
|
|
PRUint32 aSourceOffset,
|
1999-04-06 01:06:07 +04:00
|
|
|
PRUint32 aLength) {
|
1999-05-04 23:33:37 +04:00
|
|
|
PR_EnterMonitor(mMonitor);
|
1999-04-06 01:06:07 +04:00
|
|
|
char buf[1025];
|
|
|
|
while (aLength > 0) {
|
|
|
|
PRUint32 amt;
|
|
|
|
nsresult rv = aIStream->Read(buf, 1024, &amt);
|
1999-05-09 23:18:25 +04:00
|
|
|
buf[amt] = '\0';
|
|
|
|
printf(buf);
|
1999-04-06 01:06:07 +04:00
|
|
|
aLength -= amt;
|
1999-04-06 10:11:23 +04:00
|
|
|
gVolume += amt;
|
1999-04-06 01:06:07 +04:00
|
|
|
}
|
1999-05-04 23:33:37 +04:00
|
|
|
PR_ExitMonitor(mMonitor);
|
1999-04-06 01:06:07 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-06 10:11:23 +04:00
|
|
|
NS_IMETHOD OnStopBinding(nsISupports* context,
|
1999-04-06 01:06:07 +04:00
|
|
|
nsresult aStatus,
|
|
|
|
nsIString* aMsg) {
|
1999-04-06 10:11:23 +04:00
|
|
|
nsresult rv;
|
1999-05-04 23:33:37 +04:00
|
|
|
PR_EnterMonitor(mMonitor);
|
1999-04-06 01:06:07 +04:00
|
|
|
if (aStatus == NS_OK) {
|
|
|
|
PRIntervalTime endTime = PR_IntervalNow();
|
|
|
|
gDuration += (endTime - mStartTime);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("stop binding, %d\n", aStatus);
|
|
|
|
}
|
1999-05-04 23:33:37 +04:00
|
|
|
PR_ExitMonitor(mMonitor);
|
1999-04-06 10:11:23 +04:00
|
|
|
|
|
|
|
// get me out of my event loop
|
|
|
|
rv = mThread->Interrupt();
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
return rv;
|
1999-04-06 01:06:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
1999-05-06 02:41:44 +04:00
|
|
|
nsIEventQueue* mEventQueue;
|
1999-04-06 01:06:07 +04:00
|
|
|
PRIntervalTime mStartTime;
|
1999-04-06 10:11:23 +04:00
|
|
|
nsIThread* mThread;
|
1999-05-04 23:33:37 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
PRMonitor* mMonitor;
|
1999-04-06 01:06:07 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF(nsReader);
|
|
|
|
NS_IMPL_RELEASE(nsReader);
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsReader::QueryInterface(const nsIID& aIID, void* *aInstancePtr)
|
|
|
|
{
|
|
|
|
if (NULL == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
if (aIID.Equals(nsIRunnable::GetIID()) ||
|
|
|
|
aIID.Equals(kISupportsIID)) {
|
|
|
|
*aInstancePtr = NS_STATIC_CAST(nsIRunnable*, this);
|
|
|
|
NS_ADDREF_THIS();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
if (aIID.Equals(nsIStreamListener::GetIID())) {
|
|
|
|
*aInstancePtr = NS_STATIC_CAST(nsIStreamListener*, this);
|
|
|
|
NS_ADDREF_THIS();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
1999-04-06 10:11:23 +04:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
Simulated_nsFileTransport_Run(nsReader* reader, const char* path)
|
|
|
|
{
|
|
|
|
// duplicate the work of nsFileTransport::Run here
|
|
|
|
|
|
|
|
#define NS_FILE_TRANSPORT_BUFFER_SIZE (4*1024)
|
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
nsISupports* fs;
|
|
|
|
nsIInputStream* fileStr = nsnull;
|
|
|
|
nsIByteBufferInputStream* bufStr = nsnull;
|
|
|
|
nsFileSpec spec(path);
|
1999-04-22 12:47:06 +04:00
|
|
|
PRUint32 sourceOffset = 0;
|
1999-04-06 10:11:23 +04:00
|
|
|
|
|
|
|
rv = reader->OnStartBinding(nsnull);
|
|
|
|
if (NS_FAILED(rv)) goto done; // XXX should this abort the transfer?
|
|
|
|
|
|
|
|
rv = NS_NewTypicalInputFileStream(&fs, spec);
|
|
|
|
if (NS_FAILED(rv)) goto done;
|
|
|
|
|
|
|
|
rv = fs->QueryInterface(nsIInputStream::GetIID(), (void**)&fileStr);
|
|
|
|
NS_RELEASE(fs);
|
|
|
|
if (NS_FAILED(rv)) goto done;
|
|
|
|
|
1999-04-13 22:10:15 +04:00
|
|
|
rv = NS_NewByteBufferInputStream(&bufStr, PR_FALSE, NS_FILE_TRANSPORT_BUFFER_SIZE);
|
1999-04-06 10:11:23 +04:00
|
|
|
if (NS_FAILED(rv)) goto done;
|
|
|
|
|
|
|
|
while (PR_TRUE) {
|
|
|
|
PRUint32 amt;
|
|
|
|
rv = bufStr->Fill(fileStr, &amt);
|
|
|
|
if (rv == NS_BASE_STREAM_EOF) {
|
|
|
|
rv = NS_OK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (NS_FAILED(rv)) break;
|
|
|
|
|
1999-04-22 12:47:06 +04:00
|
|
|
rv = reader->OnDataAvailable(nsnull, bufStr, sourceOffset, amt);
|
1999-04-06 10:11:23 +04:00
|
|
|
if (NS_FAILED(rv)) break;
|
1999-04-22 12:47:06 +04:00
|
|
|
|
|
|
|
sourceOffset += amt;
|
1999-04-06 10:11:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
NS_IF_RELEASE(bufStr);
|
|
|
|
NS_IF_RELEASE(fileStr);
|
|
|
|
|
|
|
|
rv = reader->OnStopBinding(nsnull, rv, nsnull);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-04-06 01:06:07 +04:00
|
|
|
void
|
1999-04-06 10:11:23 +04:00
|
|
|
SerialReadTest(char* dirName)
|
1999-04-06 01:06:07 +04:00
|
|
|
{
|
|
|
|
nsresult rv;
|
1999-04-06 10:11:23 +04:00
|
|
|
PRStatus status;
|
|
|
|
|
|
|
|
PRDir* dir = PR_OpenDir(dirName);
|
|
|
|
NS_ASSERTION(dir, "bad dir");
|
|
|
|
|
|
|
|
nsISupportsArray* threads;
|
|
|
|
rv = NS_NewISupportsArray(&threads);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_NewISupportsArray failed");
|
|
|
|
|
1999-04-06 01:06:07 +04:00
|
|
|
PRIntervalTime startTime = PR_IntervalNow();
|
1999-04-06 10:11:23 +04:00
|
|
|
PRDirEntry* entry;
|
|
|
|
while ((entry = PR_ReadDir(dir, PR_SKIP_BOTH)) != nsnull) {
|
|
|
|
nsFileSpec spec(dirName);
|
|
|
|
spec += entry->name;
|
1999-04-06 01:06:07 +04:00
|
|
|
|
1999-04-06 10:11:23 +04:00
|
|
|
nsReader* reader = new nsReader();
|
|
|
|
NS_ASSERTION(reader, "out of memory");
|
|
|
|
NS_ADDREF(reader);
|
1999-04-06 01:06:07 +04:00
|
|
|
|
1999-04-06 10:11:23 +04:00
|
|
|
nsIThread* readerThread;
|
|
|
|
rv = NS_NewThread(&readerThread, reader);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "new thread failed");
|
1999-04-06 01:06:07 +04:00
|
|
|
|
1999-04-06 10:11:23 +04:00
|
|
|
rv = reader->Init(readerThread);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "init failed");
|
1999-04-06 01:06:07 +04:00
|
|
|
|
1999-04-06 10:11:23 +04:00
|
|
|
nsIStreamListener* listener;
|
|
|
|
reader->QueryInterface(nsIStreamListener::GetIID(), (void**)&listener);
|
|
|
|
NS_ASSERTION(listener, "QI failed");
|
|
|
|
|
|
|
|
rv = Simulated_nsFileTransport_Run(reader, spec);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "Simulated_nsFileTransport_Run failed");
|
|
|
|
|
|
|
|
// the reader thread will hang on to these objects until it quits
|
|
|
|
NS_RELEASE(listener);
|
|
|
|
NS_RELEASE(readerThread);
|
|
|
|
NS_RELEASE(reader);
|
1999-04-06 01:06:07 +04:00
|
|
|
}
|
|
|
|
PRIntervalTime endTime = PR_IntervalNow();
|
1999-04-06 10:11:23 +04:00
|
|
|
printf("duration %d ms, volume %d\n",
|
|
|
|
PR_IntervalToMilliseconds(endTime - startTime),
|
|
|
|
gVolume);
|
|
|
|
gVolume = 0;
|
|
|
|
|
|
|
|
// now that we've forked all the async requests, wait until they're done
|
|
|
|
PRUint32 threadCount = threads->Count();
|
|
|
|
for (PRUint32 i = 0; i < threadCount; i++) {
|
|
|
|
nsIThread* thread = (nsIThread*)(*threads)[i];
|
|
|
|
thread->Join();
|
|
|
|
NS_RELEASE(thread);
|
|
|
|
}
|
|
|
|
NS_RELEASE(threads);
|
|
|
|
|
|
|
|
status = PR_CloseDir(dir);
|
|
|
|
NS_ASSERTION(status == PR_SUCCESS, "can't close dir");
|
1999-04-06 01:06:07 +04:00
|
|
|
}
|
|
|
|
|
1999-04-06 10:11:23 +04:00
|
|
|
void
|
|
|
|
ParallelReadTest(char* dirName, nsIFileTransportService* fts)
|
1999-04-06 01:06:07 +04:00
|
|
|
{
|
|
|
|
nsresult rv;
|
1999-04-06 10:11:23 +04:00
|
|
|
PRStatus status;
|
1999-04-06 01:06:07 +04:00
|
|
|
|
1999-04-06 10:11:23 +04:00
|
|
|
PRDir* dir = PR_OpenDir(dirName);
|
|
|
|
NS_ASSERTION(dir, "bad dir");
|
1999-04-06 01:06:07 +04:00
|
|
|
|
1999-04-06 10:11:23 +04:00
|
|
|
nsISupportsArray* threads;
|
|
|
|
rv = NS_NewISupportsArray(&threads);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_NewISupportsArray failed");
|
1999-04-06 01:06:07 +04:00
|
|
|
|
1999-04-06 10:11:23 +04:00
|
|
|
PRDirEntry* entry;
|
|
|
|
while ((entry = PR_ReadDir(dir, PR_SKIP_BOTH)) != nsnull) {
|
|
|
|
nsFileSpec spec(dirName);
|
|
|
|
spec += entry->name;
|
1999-04-06 01:06:07 +04:00
|
|
|
|
1999-04-06 10:11:23 +04:00
|
|
|
nsReader* reader = new nsReader();
|
|
|
|
NS_ASSERTION(reader, "out of memory");
|
|
|
|
NS_ADDREF(reader);
|
1999-04-06 01:06:07 +04:00
|
|
|
|
1999-04-06 10:11:23 +04:00
|
|
|
nsIThread* readerThread;
|
|
|
|
rv = NS_NewThread(&readerThread, reader);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "new thread failed");
|
1999-04-06 01:06:07 +04:00
|
|
|
|
1999-04-06 10:11:23 +04:00
|
|
|
rv = reader->Init(readerThread);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "init failed");
|
1999-04-06 01:06:07 +04:00
|
|
|
|
1999-04-06 10:11:23 +04:00
|
|
|
nsIStreamListener* listener;
|
|
|
|
reader->QueryInterface(nsIStreamListener::GetIID(), (void**)&listener);
|
|
|
|
NS_ASSERTION(listener, "QI failed");
|
|
|
|
|
1999-04-06 01:06:07 +04:00
|
|
|
nsITransport* trans;
|
1999-04-14 12:13:35 +04:00
|
|
|
rv = fts->CreateTransport(spec, &trans);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "create failed");
|
|
|
|
|
|
|
|
rv = trans->AsyncRead(nsnull, reader->GetEventQueue(), listener);
|
1999-04-06 10:11:23 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "AsyncRead failed");
|
|
|
|
|
|
|
|
// the reader thread will hang on to these objects until it quits
|
|
|
|
NS_RELEASE(trans);
|
|
|
|
NS_RELEASE(listener);
|
|
|
|
NS_RELEASE(reader);
|
|
|
|
threads->AppendElement(readerThread);
|
|
|
|
NS_RELEASE(readerThread);
|
|
|
|
}
|
|
|
|
|
|
|
|
// now that we've forked all the async requests, wait until they're done
|
|
|
|
PRUint32 threadCount = threads->Count();
|
|
|
|
for (PRUint32 i = 0; i < threadCount; i++) {
|
|
|
|
nsIThread* thread = (nsIThread*)(*threads)[i];
|
|
|
|
thread->Join();
|
|
|
|
NS_RELEASE(thread);
|
1999-04-06 01:06:07 +04:00
|
|
|
}
|
1999-04-06 10:11:23 +04:00
|
|
|
NS_RELEASE(threads);
|
|
|
|
|
|
|
|
status = PR_CloseDir(dir);
|
|
|
|
NS_ASSERTION(status == PR_SUCCESS, "can't close dir");
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
if (argc < 2) {
|
|
|
|
printf("usage: %s <dir-to-read-all-files-from>\n", argv[0]);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
char* dirName = argv[1];
|
|
|
|
|
|
|
|
// XXX why do I have to do this?!
|
1999-05-09 23:18:25 +04:00
|
|
|
nsComponentManager::RegisterComponent(kFileTransportServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE);
|
|
|
|
nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
|
1999-04-06 10:11:23 +04:00
|
|
|
rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup,
|
|
|
|
"components");
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
SerialReadTest(dirName);
|
|
|
|
ParallelReadTest(dirName, fts);
|
1999-04-06 01:06:07 +04:00
|
|
|
|
1999-04-13 22:10:15 +04:00
|
|
|
fts->ProcessPendingRequests();
|
1999-04-06 01:06:07 +04:00
|
|
|
|
1999-04-06 10:11:23 +04:00
|
|
|
printf("duration %d ms, volume %d\n",
|
|
|
|
PR_IntervalToMilliseconds(gDuration),
|
|
|
|
gVolume);
|
|
|
|
gVolume = 0;
|
1999-04-06 01:06:07 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|