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

Side by Side Diff: chrome/browser/renderer_host/download_resource_handler.h

Issue 7237034: sql::MetaTable.next_download_id, DownloadManager::GetNextId() (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: " Created 9 years, 4 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 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 CHROME_BROWSER_RENDERER_HOST_DOWNLOAD_RESOURCE_HANDLER_H_ 5 #ifndef CHROME_BROWSER_RENDERER_HOST_DOWNLOAD_RESOURCE_HANDLER_H_
6 #define CHROME_BROWSER_RENDERER_HOST_DOWNLOAD_RESOURCE_HANDLER_H_ 6 #define CHROME_BROWSER_RENDERER_HOST_DOWNLOAD_RESOURCE_HANDLER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/timer.h" 12 #include "base/timer.h"
13 #include "chrome/browser/download/download_file.h" 13 #include "chrome/browser/download/download_file.h"
14 #include "chrome/browser/download/download_id.h"
15 #include "chrome/browser/download/download_manager.h"
14 #include "content/browser/renderer_host/global_request_id.h" 16 #include "content/browser/renderer_host/global_request_id.h"
15 #include "content/browser/renderer_host/resource_handler.h" 17 #include "content/browser/renderer_host/resource_handler.h"
16 18
17 class DownloadFileManager; 19 class DownloadFileManager;
18 class ResourceDispatcherHost; 20 class ResourceDispatcherHost;
19 struct DownloadBuffer; 21 struct DownloadBuffer;
20 22
21 namespace net { 23 namespace net {
22 class URLRequest; 24 class URLRequest;
23 } // namespace net 25 } // namespace net
24 26
25 // Forwards data to the download thread. 27 // Forwards data to the download thread.
26 class DownloadResourceHandler : public ResourceHandler { 28 class DownloadResourceHandler : public ResourceHandler {
27 public: 29 public:
28 DownloadResourceHandler(ResourceDispatcherHost* rdh, 30 DownloadResourceHandler(
29 int render_process_host_id, 31 ResourceDispatcherHost* rdh,
30 int render_view_id, 32 int render_process_host_id,
31 int request_id, 33 int render_view_id,
32 const GURL& url, 34 int request_id,
33 DownloadFileManager* download_file_manager, 35 const GURL& url,
34 net::URLRequest* request, 36 DownloadId dl_id,
35 bool save_as, 37 DownloadFileManager* download_file_manager,
36 const DownloadSaveInfo& save_info); 38 net::URLRequest* request,
39 bool save_as,
40 const DownloadSaveInfo& save_info);
37 41
38 virtual bool OnUploadProgress(int request_id, uint64 position, uint64 size); 42 virtual bool OnUploadProgress(int request_id, uint64 position, uint64 size);
39 43
40 // Not needed, as this event handler ought to be the final resource. 44 // Not needed, as this event handler ought to be the final resource.
41 virtual bool OnRequestRedirected(int request_id, const GURL& url, 45 virtual bool OnRequestRedirected(int request_id, const GURL& url,
42 ResourceResponse* response, bool* defer); 46 ResourceResponse* response, bool* defer);
43 47
44 // Send the download creation information to the download thread. 48 // Send the download creation information to the download thread.
45 virtual bool OnResponseStarted(int request_id, ResourceResponse* response); 49 virtual bool OnResponseStarted(int request_id, ResourceResponse* response);
46 50
(...skipping 21 matching lines...) Expand all
68 72
69 void CheckWriteProgress(); 73 void CheckWriteProgress();
70 74
71 std::string DebugString() const; 75 std::string DebugString() const;
72 76
73 private: 77 private:
74 virtual ~DownloadResourceHandler(); 78 virtual ~DownloadResourceHandler();
75 79
76 void StartPauseTimer(); 80 void StartPauseTimer();
77 81
78 int download_id_; 82 DownloadId download_id_;
79 GlobalRequestID global_id_; 83 GlobalRequestID global_id_;
80 int render_view_id_; 84 int render_view_id_;
81 scoped_refptr<net::IOBuffer> read_buffer_; 85 scoped_refptr<net::IOBuffer> read_buffer_;
82 std::string content_disposition_; 86 std::string content_disposition_;
83 int64 content_length_; 87 int64 content_length_;
84 DownloadFileManager* download_file_manager_; 88 DownloadFileManager* download_file_manager_;
85 net::URLRequest* request_; 89 net::URLRequest* request_;
86 bool save_as_; // Request was initiated via "Save As" by the user. 90 bool save_as_; // Request was initiated via "Save As" by the user.
87 DownloadSaveInfo save_info_; 91 DownloadSaveInfo save_info_;
88 scoped_ptr<DownloadBuffer> buffer_; 92 scoped_ptr<DownloadBuffer> buffer_;
89 ResourceDispatcherHost* rdh_; 93 ResourceDispatcherHost* rdh_;
90 bool is_paused_; 94 bool is_paused_;
91 base::OneShotTimer<DownloadResourceHandler> pause_timer_; 95 base::OneShotTimer<DownloadResourceHandler> pause_timer_;
92 base::TimeTicks download_start_time_; // used to collect stats. 96 base::TimeTicks download_start_time_; // used to collect stats.
93 static const int kReadBufSize = 32768; // bytes 97 static const int kReadBufSize = 32768; // bytes
94 static const size_t kLoadsToWrite = 100; // number of data buffers queued 98 static const size_t kLoadsToWrite = 100; // number of data buffers queued
95 static const int kThrottleTimeMs = 200; // milliseconds 99 static const int kThrottleTimeMs = 200; // milliseconds
96 100
97 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); 101 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler);
98 }; 102 };
99 103
100 #endif // CHROME_BROWSER_RENDERER_HOST_DOWNLOAD_RESOURCE_HANDLER_H_ 104 #endif // CHROME_BROWSER_RENDERER_HOST_DOWNLOAD_RESOURCE_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698