| 1 | | //* |
|---|
| 2 | | //* Overhaul Handler |
|---|
| 3 | | //* |
|---|
| 4 | | //* The overhaul handler object is instantiated as soon as we are in |
|---|
| 5 | | //* overhaul mode. The constructor arranges all information such that |
|---|
| 6 | | //* the object will run in an event-driven fashion, completing the |
|---|
| 7 | | //* process and displaying the web page to the user. |
|---|
| 8 | | //* |
|---|
| 9 | | |
|---|
| 10 | | |
|---|
| 11 | | |
|---|
| 12 | | function overhaul_handler(clientHostArray, clientPortArray, url , filename, chunks_held, md5_list,numChunk){ |
|---|
| | 1 | /** |
|---|
| | 2 | * Overhaul Handler |
|---|
| | 3 | * |
|---|
| | 4 | * The overhaul handler object is instantiated as soon as we are in |
|---|
| | 5 | * overhaul mode. The constructor arranges all information such that |
|---|
| | 6 | * the object will run in an event-driven fashion, completing the |
|---|
| | 7 | * process and displaying the web page to the user. |
|---|
| | 8 | * |
|---|
| | 9 | * Parameters: |
|---|
| | 10 | * clientHostArray - An array of host IP addresses. |
|---|
| | 11 | * clientPortArray - An array of host Ports, where each index corresponds |
|---|
| | 12 | * with the same host's IP address in clientHostArray. |
|---|
| | 13 | * url - The fully-qualified URL of the page being loaded. |
|---|
| | 14 | * filename - the name of the file being loaded. |
|---|
| | 15 | * chunks_held - An array of boolean values: false means that the indexed |
|---|
| | 16 | * chunk number is not present on this client, true means |
|---|
| | 17 | * it is present. |
|---|
| | 18 | * md5_list - The list of MD5 checksums for each chunk of the complete |
|---|
| | 19 | * document. |
|---|
| | 20 | */ |
|---|
| | 21 | function overhaul_handler(clientHostArray, clientPortArray, url, filename, |
|---|
| | 22 | chunks_held, md5_list) { |
|---|
| 15 | | // counter for the raw datas |
|---|
| | 25 | var receivedDataArray = new Array(); // The content of the page, in chunks |
|---|
| | 26 | overhaul_replyer(receivedDataArray); |
|---|
| | 27 | |
|---|
| | 28 | var availableList; // Tracks remote availability of chunks |
|---|
| | 29 | availableList = new overhaul_info(clientHostArray, clientPortArray, url, this); |
|---|
| | 30 | availableList.sendInfoRequests(); |
|---|
| | 31 | |
|---|
| | 32 | // Loop until web page is complete |
|---|
| | 33 | var numChunk = md5_list.size(); |
|---|
| 17 | | |
|---|
| 18 | | //raw data(unmodified) and GROBAL |
|---|
| 19 | | var receivedDataArray=new Array(); |
|---|
| 20 | | overhaul_replyer(receivedDataArray); |
|---|
| 21 | | //modified data |
|---|
| 22 | | //please WAIT!! |
|---|
| 23 | | |
|---|
| 24 | | var availableList=new Array(); |
|---|
| 25 | | |
|---|
| 26 | | //get double array which client have which chunks |
|---|
| 27 | | var info= new overhaul_info(clientHostArray,clientPortArray, url, this); |
|---|
| 28 | | info.sendInfoRequests(); |
|---|
| 29 | | |
|---|
| 30 | | //loop until all of the data get |
|---|
| 31 | | for(countChunk=0;countChunk<numChunk;countChunk++){ |
|---|
| 32 | | if(chunks_held[countChunk]!=null){ |
|---|
| 33 | | receivedDataArray[countChunk]=chunks_held[countChunk]; |
|---|
| 34 | | break; |
|---|
| 35 | | } |
|---|
| 36 | | else{ |
|---|
| | 35 | for(countChunk = 0; countChunk < numChunk; countChunk++) { |
|---|
| | 36 | if(chunks_held[countChunk] != null) |
|---|
| | 37 | receivedDataArray[countChunk] = chunks_held[countChunk]; |
|---|
| | 38 | else { |
|---|
| 94 | | /* |
|---|
| 95 | | BLOCK REMOVED - code moved to bind_stream_to_listener |
|---|
| 96 | | in overhaul_util.js |
|---|
| 97 | | |
|---|
| 98 | | var instream = Components.classes["@mozilla.org/scriptableinputstream;1"] |
|---|
| 99 | | .createInstance(Components.interfaces.nsIScriptableInputStream); |
|---|
| 100 | | instream.init(stream); |
|---|
| 101 | | |
|---|
| 102 | | var pump = Components.classes["@mozilla.org/network/input-stream-pump;1"]. |
|---|
| 103 | | createInstance(Components.interfaces.nsIInputStreamPump); |
|---|
| 104 | | pump.init(stream, -1, -1, 0, 0, true); |
|---|
| 105 | | pump.asyncRead(dataListener,null); |
|---|
| 106 | | */ |
|---|