| 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 class ResourceDispatcherHost; | 23 class ResourceDispatcherHost; |
| 23 struct DownloadCreateInfo; | 24 struct DownloadCreateInfo; |
| 24 | 25 |
| 25 namespace content { | 26 namespace content { |
| 26 class DownloadBuffer; | 27 class DownloadBuffer; |
| 27 } | 28 } |
| 28 | 29 |
| 29 namespace net { | 30 namespace net { |
| 30 class URLRequest; | 31 class URLRequest; |
| 31 } // namespace net | 32 } // namespace net |
| 32 | 33 |
| 33 // Forwards data to the download thread. | 34 // Forwards data to the download thread. |
| 34 class DownloadResourceHandler : public ResourceHandler { | 35 class DownloadResourceHandler : public ResourceHandler { |
| 35 public: | 36 public: |
| 36 typedef base::Callback<void(content::DownloadId, net::Error)> | 37 typedef content::DownloadManager::OnStartedCallback OnStartedCallback; |
| 37 OnStartedCallback; | |
| 38 | 38 |
| 39 static const size_t kLoadsToWrite = 100; // number of data buffers queued | 39 static const size_t kLoadsToWrite = 100; // number of data buffers queued |
| 40 | 40 |
| 41 // started_cb will be called exactly once on the UI thread. | 41 // started_cb will be called exactly once on the UI thread. |
| 42 DownloadResourceHandler(ResourceDispatcherHost* rdh, | 42 DownloadResourceHandler(ResourceDispatcherHost* rdh, |
| 43 int render_process_host_id, | 43 int render_process_host_id, |
| 44 int render_view_id, | 44 int render_view_id, |
| 45 int request_id, | 45 int request_id, |
| 46 const GURL& url, | 46 const GURL& url, |
| 47 DownloadFileManager* download_file_manager, | 47 DownloadFileManager* download_file_manager, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 int64 bytes_read_; | 131 int64 bytes_read_; |
| 132 std::string accept_ranges_; | 132 std::string accept_ranges_; |
| 133 | 133 |
| 134 static const int kReadBufSize = 32768; // bytes | 134 static const int kReadBufSize = 32768; // bytes |
| 135 static const int kThrottleTimeMs = 200; // milliseconds | 135 static const int kThrottleTimeMs = 200; // milliseconds |
| 136 | 136 |
| 137 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); | 137 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); |
| 138 }; | 138 }; |
| 139 | 139 |
| 140 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_ | 140 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_ |
| OLD | NEW |