From 1f8859ad6ec7ea807c0330ddf5559e13be5fb26c Mon Sep 17 00:00:00 2001 From: "rvargas@google.com" Date: Sat, 24 Jan 2009 01:54:05 +0000 Subject: Change URLRequest to use a ref-counted buffer for actual IO.The ref-counting will prevent the deletion / reuse of memorywhile the buffer is actually being used by pending IO.This seems a very intrusive change, but at least we will be ableto make sure that it works without having to chase every singledestruction of an URLRequest to make sure that any pending IOwas cancelled, and also allows us to avoid blocking onthe object destruction.BUG=5325 Review URL: http://codereview.chromium.org/18390 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8603 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/automation/url_request_slow_download_job.cc | 6 +++--- chrome/browser/automation/url_request_slow_download_job.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'chrome/browser/automation') diff --git a/chrome/browser/automation/url_request_slow_download_job.cc b/chrome/browser/automation/url_request_slow_download_job.cc index e1a2c84f0..71f71ca 100644 --- a/chrome/browser/automation/url_request_slow_download_job.cc +++ b/chrome/browser/automation/url_request_slow_download_job.cc @@ -72,7 +72,7 @@ void URLRequestSlowDownloadJob::StartAsync() { NotifyHeadersComplete(); } -bool URLRequestSlowDownloadJob::ReadRawData(char* buf, int buf_size, +bool URLRequestSlowDownloadJob::ReadRawData(net::IOBuffer* buf, int buf_size, int *bytes_read) { if (LowerCaseEqualsASCII(kFinishDownloadUrl, request_->url().spec().c_str())) { @@ -83,7 +83,7 @@ bool URLRequestSlowDownloadJob::ReadRawData(char* buf, int buf_size, if (should_send_second_chunk_) { DCHECK(buf_size > kSecondDownloadSize); for (int i = 0; i < kSecondDownloadSize; ++i) { - buf[i] = '*'; + buf->data()[i] = '*'; } *bytes_read = kSecondDownloadSize; should_send_second_chunk_ = false; @@ -93,7 +93,7 @@ bool URLRequestSlowDownloadJob::ReadRawData(char* buf, int buf_size, if (first_download_size_remaining_ > 0) { int send_size = std::min(first_download_size_remaining_, buf_size); for (int i = 0; i < send_size; ++i) { - buf[i] = '*'; + buf->data()[i] = '*'; } *bytes_read = send_size; first_download_size_remaining_ -= send_size; diff --git a/chrome/browser/automation/url_request_slow_download_job.h b/chrome/browser/automation/url_request_slow_download_job.h index cf0156d..847121e 100644 --- a/chrome/browser/automation/url_request_slow_download_job.h +++ b/chrome/browser/automation/url_request_slow_download_job.h @@ -25,7 +25,7 @@ class URLRequestSlowDownloadJob : public URLRequestJob { virtual void Start(); virtual bool GetMimeType(std::string* mime_type); virtual void GetResponseInfo(net::HttpResponseInfo* info); - virtual bool ReadRawData(char* buf, int buf_size, int *bytes_read); + virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int *bytes_read); static URLRequestJob* Factory(URLRequest* request, const std::string& scheme); -- cgit v1.1