svnno****@sourc*****
svnno****@sourc*****
2008年 7月 5日 (土) 03:41:20 JST
Revision: 428 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=bbs2ch&view=rev&rev=428 Author: flyson Date: 2008-07-05 03:41:20 +0900 (Sat, 05 Jul 2008) Log Message: ----------- [04_BRANCH] nsIThread を廃止して Fx3 で動くようにした Modified Paths: -------------- branches/bbs2chreader/04_BRANCH/components/b2rServer.js -------------- next part -------------- Modified: branches/bbs2chreader/04_BRANCH/components/b2rServer.js =================================================================== --- branches/bbs2chreader/04_BRANCH/components/b2rServer.js 2008-04-22 13:18:06 UTC (rev 427) +++ branches/bbs2chreader/04_BRANCH/components/b2rServer.js 2008-07-04 18:41:20 UTC (rev 428) @@ -148,10 +148,12 @@ return; } - this._thread = XPC.createInstance("@mozilla.org/thread;1", "nsIThread"); - this._thread.init(this, 0, Ci.nsIThread.PRIORITY_NORMAL, - Ci.nsIThread.SCOPE_GLOBAL, Ci.nsIThread.STATE_JOINABLE); - dump("b2rServer.start\n"); + var port = XPC.getService("@mozilla.org/bbs2ch-service;1", "nsIBbs2chService").serverURL.port; + var serverSocket = XPC.createInstance("@mozilla.org/network/server-socket;1", "nsIServerSocket"); + serverSocket.init(port, true, 10); + serverSocket.asyncListen(this); + + dump("b2rServer.run : Start Listening Port " + port + "\n"); }, stop: function(){ @@ -163,30 +165,6 @@ }, - // ********** ********* implements nsIRunnable ********** ********** - - run: function (){ - var eventQueueService = XPC.getService("@mozilla.org/event-queue-service;1", "nsIEventQueueService"); - this._eventQueue = eventQueueService.createFromIThread(this.currentThread, false); - - var port = XPC.getService("@mozilla.org/bbs2ch-service;1", "nsIBbs2chService").serverURL.port; - var serverSocket = XPC.createInstance("@mozilla.org/network/server-socket;1", "nsIServerSocket"); - serverSocket.init(port, true, 10); - serverSocket.asyncListen(this); - - dump("b2rServer.run : Start Listening Port " + port + "\n"); - this._listening = true; - this._eventQueue.eventLoop(); - this._listening = false; - serverSocket.close(); - this._eventQueue.processPendingEvents(); - this._eventQueue.stopAcceptingEvents(); - this._eventQueue.processPendingEvents(); - this._eventQueue = null; - dump("b2rServer.run : Stop Listening Port " + port + "\n"); - }, - - // ********** ********* implements nsIServerSocketListener ********** ********** onSocketAccepted: function(aServerSocket, aTransport){ @@ -297,14 +275,9 @@ this._getData = new Array(); this._requestBuffer = ""; - this._input.asyncWait(this, 0, 0, this._getMainThread()); + this._input.asyncWait(this, 0, 0, Cc["@mozilla.org/thread-manager;1"].getService().mainThread); }, - _getMainThread: function(){ - var eventQueueService = XPC.getService("@mozilla.org/event-queue-service;1", "nsIEventQueueService"); - return eventQueueService.getSpecialEventQueue(Ci.nsIEventQueueService.UI_THREAD_EVENT_QUEUE); - }, - onInputStreamReady: function(aInput){ var available = aInput.available(); var bInputStream = XPC.createInstance("@mozilla.org/binaryinputstream;1", "nsIBinaryInputStream"); @@ -313,7 +286,7 @@ if((/\r\n\r\n/).test(this._requestBuffer)){ this._parseRequestData(); }else{ - this._input.asyncWait(this, 0, 0, this._getMainThread()); + this._input.asyncWait(this, 0, 0, Cc["@mozilla.org/thread-manager;1"].getService().mainThread); } },