[Bbs2ch-cvs 46] CVS update: bbs2chreader/components

Back to archive index

flyson flyso****@users*****
2005年 11月 5日 (土) 02:01:12 JST


Index: bbs2chreader/components/nsBbs2chChannel.js
diff -u bbs2chreader/components/nsBbs2chChannel.js:1.5 bbs2chreader/components/nsBbs2chChannel.js:1.6
--- bbs2chreader/components/nsBbs2chChannel.js:1.5	Fri Oct 28 00:26:21 2005
+++ bbs2chreader/components/nsBbs2chChannel.js	Sat Nov  5 02:01:12 2005
@@ -82,31 +82,20 @@
 		this._context = aContext;
 		if(this.loadGroup) this.loadGroup.addRequest(this, this._context);
 
-			// HTTP キャッシュ
-		var cacheService = Components.classes["@mozilla.org/network/cache-service;1"]
-								.getService(Components.interfaces.nsICacheService);
-		var cacheSession = cacheService.createSession("HTTP", 
-								Components.interfaces.nsICache.STORE_ANYWHERE, true);
-		cacheSession.doomEntriesIfExpired = false;
-
-		this._cacheMode = false;
-			// キャッシュモード
-		if(this.loadFlags & 4096) this._cacheMode = true;
-
-			// this.onCacheEntryAvailable を実行
-		cacheSession.asyncOpenCacheEntry(this.URI.spec,
-						Components.interfaces.nsICache.ACCESS_READ_WRITE, this);
+			// 呼び出し元のスレッド処理後にスタート
+		var timer = Components.classes["@mozilla.org/timer;1"]
+						.createInstance(Components.interfaces.nsITimer);
+		var timerCallback = {};
+		timerCallback._context = this;
+		timerCallback.observe = function(aTimer){
+			var context = this._context;
+			context.requestStart();
+			context._observer.init(context);
+		}
+		timer.init(timerCallback, 0, timer.TYPE_ONE_SHOT);
 	},
 
 	cancel: function(aStatus){
-			// キャッシュエントリがあるときは閉じる
-		if(this._cacheOutputStream){
-			this._cacheOutputStream.close();
-		}
-		if(this._cacheEntry){
-			this._cacheEntry.close();
-		}
-		
 		if(this._isPending){
 			this._isPending = false;
 
@@ -121,34 +110,6 @@
 		this.status = aStatus;
 	},
 
-	onCacheEntryAvailable: function(aDescriptor, aAccessGranted, aStatus){
-		this.requestStart();
-
-		if(this._cacheMode){
-			try{
-					// キャッシュからデータを取得して書き出す
-				var inputStream = aDescriptor.openInputStream(0, -1, 0);
-				var scriptableInputStream = Components.classes["@mozilla.org/scriptableinputstream;1"]
-							.createInstance(Components.interfaces.nsIScriptableInputStream);
-				scriptableInputStream.init(inputStream);
-				var cacheContent = scriptableInputStream.read(scriptableInputStream.available());
-				this.requestRespond(cacheContent, cacheContent.length);
-				scriptableInputStream.close();
-				inputStream.close();
-				aDescriptor.close();
-				this.requestEnd();
-				return;
-			}catch(ex){
-					// キャッシュからデータを取得できない場合は通常モード
-				this._cacheMode = false;
-			}
-		}
-
-		this._cacheEntry = aDescriptor;
-		this._cacheOutputStream = aDescriptor.openOutputStream(0, -1, 0);
-		this._observer.init(this);
-	},
-
 	init: function(aURI, aContentType, aContentCharset, aObserver){
 		this.URI = aURI;
 		this.originalURI = aURI;
@@ -168,16 +129,6 @@
 	},
 
 	requestRespond: function(aData, aDataLength){
-		if(!this._cacheMode){
-			try{
-				this._cacheOutputStream.write(aData, aDataLength);
-			}catch(ex){
-				this._cacheOutputStream.close();
-				this._cacheEntry.close();
-				this._cacheMode = true;
-			}
-		}
-
 		this._stringStream.setData(aData, aDataLength);
 		this._streamListener.onDataAvailable(this, this._context,
 					this._stringStream, this._dataSize, aDataLength);
@@ -186,16 +137,6 @@
 	},
 
 	requestEnd: function(){
-		if(!this._cacheMode){
-			this._cacheOutputStream.close();
-			this._cacheOutputStream = null;
-			this._cacheEntry.setMetaDataElement("request-method", "GET");
-			this._cacheEntry.setMetaDataElement("response-head", "HTTP/1.1 200 OK\r\n");
-			this._cacheEntry.markValid();
-			this._cacheEntry.close();
-			this._cacheEntry = null;
-		}
-
 		this._streamListener.onStopRequest(this, this._context, Components.results.NS_OK);
 		if(this.loadGroup){
 			try{


bbs2ch-cvs メーリングリストの案内
Back to archive index