OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_types.h" | 14 #include "content/browser/download/download_types.h" |
15 #include "content/browser/renderer_host/resource_handler.h" | 15 #include "content/browser/renderer_host/resource_handler.h" |
| 16 #include "content/public/browser/download_manager.h" |
16 #include "content/public/browser/download_id.h" | 17 #include "content/public/browser/download_id.h" |
17 #include "content/public/browser/global_request_id.h" | 18 #include "content/public/browser/global_request_id.h" |
18 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
19 | 20 |
20 class DownloadFileManager; | 21 class DownloadFileManager; |
21 class DownloadRequestHandle; | 22 class DownloadRequestHandle; |
22 struct DownloadCreateInfo; | 23 struct DownloadCreateInfo; |
23 | 24 |
24 namespace content { | 25 namespace content { |
25 class DownloadBuffer; | 26 class DownloadBuffer; |
26 } | 27 } |
27 | 28 |
28 namespace net { | 29 namespace net { |
29 class URLRequest; | 30 class URLRequest; |
30 } // namespace net | 31 } // namespace net |
31 | 32 |
32 // Forwards data to the download thread. | 33 // Forwards data to the download thread. |
33 class DownloadResourceHandler : public ResourceHandler { | 34 class DownloadResourceHandler : public ResourceHandler { |
34 public: | 35 public: |
35 typedef base::Callback<void(content::DownloadId, net::Error)> | 36 typedef content::DownloadManager::OnStartedCallback OnStartedCallback; |
36 OnStartedCallback; | |
37 | 37 |
38 static const size_t kLoadsToWrite = 100; // number of data buffers queued | 38 static const size_t kLoadsToWrite = 100; // number of data buffers queued |
39 | 39 |
40 // started_cb will be called exactly once on the UI thread. | 40 // started_cb will be called exactly once on the UI thread. |
41 DownloadResourceHandler(int render_process_host_id, | 41 DownloadResourceHandler(int render_process_host_id, |
42 int render_view_id, | 42 int render_view_id, |
43 int request_id, | 43 int request_id, |
44 const GURL& url, | 44 const GURL& url, |
45 DownloadFileManager* download_file_manager, | 45 DownloadFileManager* download_file_manager, |
46 net::URLRequest* request, | 46 net::URLRequest* request, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 int64 bytes_read_; | 128 int64 bytes_read_; |
129 std::string accept_ranges_; | 129 std::string accept_ranges_; |
130 | 130 |
131 static const int kReadBufSize = 32768; // bytes | 131 static const int kReadBufSize = 32768; // bytes |
132 static const int kThrottleTimeMs = 200; // milliseconds | 132 static const int kThrottleTimeMs = 200; // milliseconds |
133 | 133 |
134 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); | 134 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); |
135 }; | 135 }; |
136 | 136 |
137 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_ | 137 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_ |
OLD | NEW |