Implement range reading for NetworkReaderProxy.

The feature is not yet actually used, but will be used for range reading
of DriveFileStreamReader.

BUG=127129
TEST=Ran unit_tests

Review URL: https://chromiumcodereview.appspot.com/14493008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@196636 0039d316-1c4b-4281-b951-d872f2087c98
int ReadInternal(ScopedVector<std::string>* pending_data,
                 net::IOBuffer* buffer, int buffer_length) {
  size_t index = 0;
  int offset = 0;
  for (; index < pending_data->size() && offset < buffer_length; ++index) {
    const std::string& chunk = *(*pending_data)[index];
    DCHECK(!chunk.empty());

    size_t bytes_to_read = std::min(
        chunk.size(), static_cast<size_t>(buffer_length - offset));
    std::memmove(buffer->data() + offset, chunk.data(), bytes_to_read);
    offset += bytes_to_read;
    if (bytes_to_read < chunk.size()) {
      (*pending_data)[index]->erase(0, bytes_to_read);
      break;
    }
  }

  pending_data->erase(pending_data->begin(), pending_data->begin() + index);

  return offset;
}

int ReadInternal(ScopedVector<std::string>* pending_data,
                 net::IOBuffer* buffer, int buffer_length) {
  size_t index = 0;
  int offset = 0;
  for (; index < pending_data->size() && offset < buffer_length; ++index) {
    const std::string& chunk = *(*pending_data)[index];
    DCHECK(!chunk.empty());

    size_t bytes_to_read = std::min(
        chunk.size(), static_cast<size_t>(buffer_length - offset));
    std::memmove(buffer->data() + offset, chunk.data(), bytes_to_read);
    offset += bytes_to_read;
    if (bytes_to_read < chunk.size()) {
      (*pending_data)[index]->erase(0, bytes_to_read);
      break;
    }
  }

  pending_data->erase(pending_data->begin(), pending_data->begin() + index);

  return offset;
}
