Browse Source

*** empty log message ***

Mike Goslin 24 years ago
parent
commit
dea8d34556

+ 19 - 0
panda/src/downloader/downloader.I

@@ -110,6 +110,25 @@ get_bytes_written(void) const {
     return _total_bytes_written;
     return _total_bytes_written;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: Downloader::get_bytes_requested
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE int Downloader::
+get_bytes_requested(void) const {
+  if (_ever_initiated == false) {
+    downloader_cat.warning()
+      << "Downloader::get_bytes_requested() - Download has not been "
+      << "initiated" << endl;
+    return 0;
+  }
+  if (_current_status != NULL)
+    return _current_status->_total_bytes_requested;
+  else
+    return _total_bytes_requested;
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: Downloader::get_bytes_per_second
 //     Function: Downloader::get_bytes_per_second
 //       Access: Public
 //       Access: Public

+ 8 - 0
panda/src/downloader/downloader.cxx

@@ -67,6 +67,8 @@ Downloader(void) {
   _ever_initiated = false;
   _ever_initiated = false;
   _TCP_stack_initialized = false;
   _TCP_stack_initialized = false;
   _total_bytes_written = 0;
   _total_bytes_written = 0;
+  _total_bytes_requested = 0;
+  _total_bytes_requested = 0;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -433,6 +435,7 @@ cleanup(void) {
   disconnect_from_server();
   disconnect_from_server();
   _dest_stream.close();
   _dest_stream.close();
   _total_bytes_written = _current_status->_total_bytes_written;
   _total_bytes_written = _current_status->_total_bytes_written;
+  _total_bytes_requested = _current_status->_total_bytes_requested;
   delete _current_status;
   delete _current_status;
   // We must set this to NULL otherwise there is a bad pointer floating around
   // We must set this to NULL otherwise there is a bad pointer floating around
   _current_status = NULL;
   _current_status = NULL;
@@ -543,6 +546,8 @@ run(void) {
     fret = fast_receive(_socket, _current_status, _receive_size);
     fret = fast_receive(_socket, _current_status, _receive_size);
   }
   }
 
 
+  _current_status->_total_bytes_requested += _receive_size;
+
   // Check for end of file
   // Check for end of file
   if (fret == EU_eof) {
   if (fret == EU_eof) {
     if (_got_any_data == true) {
     if (_got_any_data == true) {
@@ -664,6 +669,8 @@ run_to_ram(void) {
     fret = fast_receive(_socket, _current_status, _receive_size);
     fret = fast_receive(_socket, _current_status, _receive_size);
   }
   }
 
 
+  _current_status->_total_bytes_requested += _receive_size;
+
   // Check for end of file
   // Check for end of file
   if (fret == EU_eof) {
   if (fret == EU_eof) {
     if (_got_any_data == true) {
     if (_got_any_data == true) {
@@ -1003,6 +1010,7 @@ DownloadStatus(char *buffer, int first_byte, int last_byte,
   // will get the total size of the file, not just the number
   // will get the total size of the file, not just the number
   // of bytes for this partial download
   // of bytes for this partial download
   _total_bytes_written = first_byte;
   _total_bytes_written = first_byte;
+  _total_bytes_requested = first_byte;
   _partial_content = partial_content;
   _partial_content = partial_content;
   reset();
   reset();
 }
 }

+ 3 - 0
panda/src/downloader/downloader.h

@@ -65,6 +65,7 @@ PUBLISHED:
   INLINE void set_disk_write_frequency(int frequency);
   INLINE void set_disk_write_frequency(int frequency);
   INLINE int get_disk_write_frequency(void) const;
   INLINE int get_disk_write_frequency(void) const;
   INLINE int get_bytes_written(void) const;
   INLINE int get_bytes_written(void) const;
+  INLINE int get_bytes_requested(void) const;
   INLINE float get_bytes_per_second(void) const;
   INLINE float get_bytes_per_second(void) const;
 
 
 private:
 private:
@@ -82,6 +83,7 @@ private:
     char *_next_in;
     char *_next_in;
     int _bytes_in_buffer;
     int _bytes_in_buffer;
     int _total_bytes_written;
     int _total_bytes_written;
+    int _total_bytes_requested;
     int _first_byte;
     int _first_byte;
     int _last_byte;
     int _last_byte;
     int _total_bytes;
     int _total_bytes;
@@ -124,6 +126,7 @@ private:
   DownloadStatus *_current_status;
   DownloadStatus *_current_status;
   bool _got_any_data;
   bool _got_any_data;
   int _total_bytes_written;
   int _total_bytes_written;
+  int _total_bytes_requested;
   bool _download_to_ram;
   bool _download_to_ram;
 
 
   double _tlast;
   double _tlast;