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

Side by Side Diff: content/browser/download/download_resource_handler.h

Issue 8404049: Added member data to classes to support download resumption. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup, and added fields to DownloadPersistentStoreInfo. Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_ 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_
6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_ 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/timer.h" 13 #include "base/timer.h"
14 #include "content/browser/download/download_file.h"
15 #include "content/browser/download/download_id.h" 14 #include "content/browser/download/download_id.h"
15 #include "content/browser/download/download_types.h"
16 #include "content/browser/renderer_host/global_request_id.h" 16 #include "content/browser/renderer_host/global_request_id.h"
17 #include "content/browser/renderer_host/resource_handler.h" 17 #include "content/browser/renderer_host/resource_handler.h"
18 #include "net/base/net_errors.h"
18 19
19 class DownloadFileManager; 20 class DownloadFileManager;
20 class ResourceDispatcherHost; 21 class ResourceDispatcherHost;
21 22
22 namespace content { 23 namespace content {
23 class DownloadBuffer; 24 class DownloadBuffer;
24 } 25 }
25 26
26 namespace net { 27 namespace net {
27 class URLRequest; 28 class URLRequest;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 const std::string& security_info); 73 const std::string& security_info);
73 virtual void OnRequestClosed(); 74 virtual void OnRequestClosed();
74 75
75 // If the content-length header is not present (or contains something other 76 // If the content-length header is not present (or contains something other
76 // than numbers), the incoming content_length is -1 (unknown size). 77 // than numbers), the incoming content_length is -1 (unknown size).
77 // Set the content length to 0 to indicate unknown size to DownloadManager. 78 // Set the content length to 0 to indicate unknown size to DownloadManager.
78 void set_content_length(const int64& content_length); 79 void set_content_length(const int64& content_length);
79 80
80 void set_content_disposition(const std::string& content_disposition); 81 void set_content_disposition(const std::string& content_disposition);
81 82
83 // How many bytes were read before this request was interrupted. Should be
84 // used only by |ResourceDispatcherHost::BeginDownload()|.
Randy Smith (Not in Mondays) 2011/11/16 18:29:27 I'd like to think about the interface to the IO an
ahendrickson 2011/11/19 20:18:03 Done.
85 void set_start_offset(int64 bytes) { start_offset_ = bytes; }
86
82 void CheckWriteProgress(); 87 void CheckWriteProgress();
83 88
84 std::string DebugString() const; 89 std::string DebugString() const;
85 90
86 private: 91 private:
87 virtual ~DownloadResourceHandler(); 92 virtual ~DownloadResourceHandler();
88 93
89 void StartPauseTimer(); 94 void StartPauseTimer();
90 void CallStartedCB(net::Error error); 95 void CallStartedCB(net::Error error);
91 96
92 DownloadId download_id_; 97 DownloadId download_id_;
93 GlobalRequestID global_id_; 98 GlobalRequestID global_id_;
94 int render_view_id_; 99 int render_view_id_;
95 scoped_refptr<net::IOBuffer> read_buffer_; 100 scoped_refptr<net::IOBuffer> read_buffer_;
96 std::string content_disposition_; 101 std::string content_disposition_;
97 int64 content_length_; 102 int64 content_length_;
98 DownloadFileManager* download_file_manager_; 103 DownloadFileManager* download_file_manager_;
99 net::URLRequest* request_; 104 net::URLRequest* request_;
100 bool save_as_; // Request was initiated via "Save As" by the user. 105 bool save_as_; // Request was initiated via "Save As" by the user.
101 OnStartedCallback started_cb_; 106 OnStartedCallback started_cb_;
102 DownloadSaveInfo save_info_; 107 DownloadSaveInfo save_info_;
103 scoped_refptr<content::DownloadBuffer> buffer_; 108 scoped_refptr<content::DownloadBuffer> buffer_;
104 ResourceDispatcherHost* rdh_; 109 ResourceDispatcherHost* rdh_;
105 bool is_paused_; 110 bool is_paused_;
106 base::OneShotTimer<DownloadResourceHandler> pause_timer_; 111 base::OneShotTimer<DownloadResourceHandler> pause_timer_;
107 base::TimeTicks download_start_time_; // used to collect stats. 112 base::TimeTicks download_start_time_; // used to collect stats.
108 base::TimeTicks last_read_time_; // used to collect stats. 113 base::TimeTicks last_read_time_; // used to collect stats.
109 size_t last_buffer_size_; // used to collect stats. 114 size_t last_buffer_size_; // used to collect stats.
115 int64 start_offset_;
110 static const int kReadBufSize = 32768; // bytes 116 static const int kReadBufSize = 32768; // bytes
111 static const int kThrottleTimeMs = 200; // milliseconds 117 static const int kThrottleTimeMs = 200; // milliseconds
112 118
113 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); 119 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler);
114 }; 120 };
115 121
116 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_ 122 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698