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

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: Incorporated Randy's comments. 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 // Location within the resource at which to start the download.
84 void set_start_offset(int64 bytes) { start_offset_ = bytes; }
Randy Smith (Not in Mondays) 2011/11/16 21:40:25 It occurs to me to ask: Should this be in the cons
Randy Smith (Not in Mondays) 2011/11/16 21:40:25 Note that there's an awesome unit-test opportunity
ahendrickson 2011/11/19 20:18:04 We have a download ID at construction time (in Buf
ahendrickson 2011/11/19 20:18:04 Done. The unit test fails currently, but will suc
Randy Smith (Not in Mondays) 2011/11/21 02:10:17 We never have access to the DownloadItem on the IO
ahendrickson 2011/11/21 20:34:46 The unit test now succeeds.
ahendrickson 2011/11/21 20:34:46 Changed it to be in the constructor, so this sette
85
82 void CheckWriteProgress(); 86 void CheckWriteProgress();
83 87
84 std::string DebugString() const; 88 std::string DebugString() const;
85 89
86 private: 90 private:
87 virtual ~DownloadResourceHandler(); 91 virtual ~DownloadResourceHandler();
88 92
89 void StartPauseTimer(); 93 void StartPauseTimer();
90 void CallStartedCB(net::Error error); 94 void CallStartedCB(net::Error error);
91 95
92 DownloadId download_id_; 96 DownloadId download_id_;
93 GlobalRequestID global_id_; 97 GlobalRequestID global_id_;
94 int render_view_id_; 98 int render_view_id_;
95 scoped_refptr<net::IOBuffer> read_buffer_; 99 scoped_refptr<net::IOBuffer> read_buffer_;
96 std::string content_disposition_; 100 std::string content_disposition_;
97 int64 content_length_; 101 int64 content_length_;
98 DownloadFileManager* download_file_manager_; 102 DownloadFileManager* download_file_manager_;
99 net::URLRequest* request_; 103 net::URLRequest* request_;
100 bool save_as_; // Request was initiated via "Save As" by the user. 104 bool save_as_; // Request was initiated via "Save As" by the user.
101 OnStartedCallback started_cb_; 105 OnStartedCallback started_cb_;
102 DownloadSaveInfo save_info_; 106 DownloadSaveInfo save_info_;
103 scoped_refptr<content::DownloadBuffer> buffer_; 107 scoped_refptr<content::DownloadBuffer> buffer_;
104 ResourceDispatcherHost* rdh_; 108 ResourceDispatcherHost* rdh_;
105 bool is_paused_; 109 bool is_paused_;
106 base::OneShotTimer<DownloadResourceHandler> pause_timer_; 110 base::OneShotTimer<DownloadResourceHandler> pause_timer_;
107 base::TimeTicks download_start_time_; // used to collect stats. 111 base::TimeTicks download_start_time_; // used to collect stats.
108 base::TimeTicks last_read_time_; // used to collect stats. 112 base::TimeTicks last_read_time_; // used to collect stats.
109 size_t last_buffer_size_; // used to collect stats. 113 size_t last_buffer_size_; // used to collect stats.
114 int64 start_offset_;
110 static const int kReadBufSize = 32768; // bytes 115 static const int kReadBufSize = 32768; // bytes
111 static const int kThrottleTimeMs = 200; // milliseconds 116 static const int kThrottleTimeMs = 200; // milliseconds
112 117
113 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); 118 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler);
114 }; 119 };
115 120
116 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_ 121 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698