Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(485)

Unified Diff: content/browser/download/download_resource_handler.h

Issue 10392111: Use ByteStream in downloads system to decouple source and sink. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed lack of virtual keyword on destructor. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/download/download_resource_handler.h
diff --git a/content/browser/download/download_resource_handler.h b/content/browser/download/download_resource_handler.h
index 66b69b761b1ca2da65da6487b0c00fdf5c297072..ef9254f1f76e942f64cc39b056856762cd9321a3 100644
--- a/content/browser/download/download_resource_handler.h
+++ b/content/browser/download/download_resource_handler.h
@@ -24,7 +24,8 @@ class DownloadRequestHandle;
struct DownloadCreateInfo;
namespace content {
-class DownloadBuffer;
+class ByteStreamWriter;
+class ByteStreamReader;
}
namespace net {
@@ -36,17 +37,16 @@ class DownloadResourceHandler : public ResourceHandler {
public:
typedef content::DownloadUrlParameters::OnStartedCallback OnStartedCallback;
- static const size_t kLoadsToWrite = 100; // number of data buffers queued
-
// started_cb will be called exactly once on the UI thread.
- DownloadResourceHandler(int render_process_host_id,
- int render_view_id,
- int request_id,
- const GURL& url,
- DownloadFileManager* download_file_manager,
- net::URLRequest* request,
- const OnStartedCallback& started_cb,
- const content::DownloadSaveInfo& save_info);
+ DownloadResourceHandler(
+ int render_process_host_id,
+ int render_view_id,
+ int request_id,
+ const GURL& url,
+ scoped_refptr<DownloadFileManager> download_file_manager,
+ net::URLRequest* request,
+ const OnStartedCallback& started_cb,
+ const content::DownloadSaveInfo& save_info);
virtual bool OnUploadProgress(int request_id,
uint64 position,
@@ -92,21 +92,11 @@ class DownloadResourceHandler : public ResourceHandler {
private:
virtual ~DownloadResourceHandler();
- void OnResponseCompletedInternal(int request_id,
- const net::URLRequestStatus& status,
- const std::string& security_info,
- int response_code);
-
- void CheckWriteProgressLater();
- void CheckWriteProgress();
- void MaybeResumeRequest();
+ // Arrange for started_cb_ to be called on the UI thread with the
+ // below values, nulling out started_cb_. Should only be called
+ // on the IO thread.
void CallStartedCB(content::DownloadId id, net::Error error);
- // Generates a DownloadId and calls DownloadFileManager.
- void StartOnUIThread(scoped_ptr<DownloadCreateInfo> info,
- const DownloadRequestHandle& handle);
- void SetDownloadID(content::DownloadId id);
-
// If the content-length header is not present (or contains something other
// than numbers), the incoming content_length is -1 (unknown size).
// Set the content length to 0 to indicate unknown size to DownloadManager.
@@ -114,23 +104,26 @@ class DownloadResourceHandler : public ResourceHandler {
void SetContentDisposition(const std::string& content_disposition);
- content::DownloadId download_id_;
content::GlobalRequestID global_id_;
int render_view_id_;
- scoped_refptr<net::IOBuffer> read_buffer_;
std::string content_disposition_;
int64 content_length_;
- DownloadFileManager* download_file_manager_;
+ scoped_refptr<DownloadFileManager> download_file_manager_;
net::URLRequest* request_;
- // This is used only on the UI thread.
+ // This is read only on the IO thread, but may only
+ // be called on the UI thread.
OnStartedCallback started_cb_;
content::DownloadSaveInfo save_info_;
- scoped_refptr<content::DownloadBuffer> buffer_;
- base::OneShotTimer<DownloadResourceHandler> check_write_progress_timer_;
+
+ // Data flow
+ scoped_refptr<net::IOBuffer> read_buffer_; // From URLRequest.
+ scoped_ptr<content::ByteStreamWriter> stream_writer_; // To rest of system.
// The following are used to collect stats.
base::TimeTicks download_start_time_;
base::TimeTicks last_read_time_;
+ base::TimeTicks last_stream_pause_time_;
+ base::TimeDelta total_pause_time_;
size_t last_buffer_size_;
int64 bytes_read_;
std::string accept_ranges_;

Powered by Google App Engine
This is Rietveld 408576698