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

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

Issue 10074001: Initial implementation of the ByteStream refactor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 3a9a5c77e363e772d0d63bd6dac3684e30f80064..1ec581c4874628cca95abe70e9029f2342527dff 100644
--- a/content/browser/download/download_resource_handler.h
+++ b/content/browser/download/download_resource_handler.h
@@ -18,12 +18,13 @@
#include "content/public/browser/global_request_id.h"
#include "net/base/net_errors.h"
+class DataLoanIOBuffer;
class DownloadFileManager;
class DownloadRequestHandle;
struct DownloadCreateInfo;
namespace content {
-class DownloadBuffer;
+class ByteStream;
}
namespace net {
@@ -35,8 +36,6 @@ class DownloadResourceHandler : public ResourceHandler {
public:
typedef content::DownloadManager::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,
@@ -87,8 +86,6 @@ class DownloadResourceHandler : public ResourceHandler {
void set_content_disposition(const std::string& content_disposition);
- void CheckWriteProgress();
-
std::string DebugString() const;
private:
@@ -99,7 +96,6 @@ class DownloadResourceHandler : public ResourceHandler {
const std::string& security_info,
int response_code);
- void StartPauseTimer();
void CallStartedCB(content::DownloadId id, net::Error error);
// Generates a DownloadId and calls DownloadFileManager.
@@ -107,10 +103,12 @@ class DownloadResourceHandler : public ResourceHandler {
const DownloadRequestHandle& handle);
void set_download_id(content::DownloadId id);
+ // Pause or resume the associated request as indicated by the output_pipe_.
+ void ThrottleRequest();
+
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_;
@@ -118,10 +116,13 @@ class DownloadResourceHandler : public ResourceHandler {
// This is used only on the UI thread.
OnStartedCallback started_cb_;
content::DownloadSaveInfo save_info_;
- scoped_refptr<content::DownloadBuffer> buffer_;
- bool is_paused_;
base::OneShotTimer<DownloadResourceHandler> pause_timer_;
+ // Data flow
+ scoped_refptr<net::IOBuffer> read_buffer_; // From URLRequest.
+ scoped_refptr<content::ByteStream> output_pipe_; // To rest of system.
+ bool is_paused_;
+
// The following are used to collect stats.
base::TimeTicks download_start_time_;
base::TimeTicks last_read_time_;
@@ -129,6 +130,8 @@ class DownloadResourceHandler : public ResourceHandler {
int64 bytes_read_;
std::string accept_ranges_;
+ base::WeakPtrFactory<DownloadResourceHandler> weak_factory_;
+
static const int kReadBufSize = 32768; // bytes
static const int kThrottleTimeMs = 200; // milliseconds

Powered by Google App Engine
This is Rietveld 408576698