| 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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" |
| 13 #include "content/browser/download/download_manager_impl.h" |
| 12 #include "content/browser/loader/resource_handler.h" | 14 #include "content/browser/loader/resource_handler.h" |
| 13 #include "content/public/browser/download_interrupt_reasons.h" | 15 #include "content/public/browser/download_interrupt_reasons.h" |
| 14 #include "content/public/browser/download_manager.h" | |
| 15 #include "content/public/browser/download_save_info.h" | 16 #include "content/public/browser/download_save_info.h" |
| 16 #include "content/public/browser/download_url_parameters.h" | 17 #include "content/public/browser/download_url_parameters.h" |
| 17 | 18 |
| 18 namespace net { | 19 namespace net { |
| 19 class URLRequest; | 20 class URLRequest; |
| 20 } // namespace net | 21 } // namespace net |
| 21 | 22 |
| 22 namespace content { | 23 namespace content { |
| 23 class ByteStreamReader; | 24 class ByteStreamReader; |
| 24 class ByteStreamWriter; | 25 class ByteStreamWriter; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 void OnDataDownloaded(int bytes_downloaded) override; | 75 void OnDataDownloaded(int bytes_downloaded) override; |
| 75 | 76 |
| 76 void PauseRequest(); | 77 void PauseRequest(); |
| 77 void ResumeRequest(); | 78 void ResumeRequest(); |
| 78 | 79 |
| 79 // May result in this object being deleted by its owner. | 80 // May result in this object being deleted by its owner. |
| 80 void CancelRequest(); | 81 void CancelRequest(); |
| 81 | 82 |
| 82 std::string DebugString() const; | 83 std::string DebugString() const; |
| 83 | 84 |
| 85 void set_download_manager( |
| 86 base::WeakPtr<DownloadManagerImpl> download_manager) { |
| 87 download_manager_ = download_manager; |
| 88 } |
| 89 |
| 84 private: | 90 private: |
| 85 ~DownloadResourceHandler() override; | 91 ~DownloadResourceHandler() override; |
| 86 | 92 |
| 87 // Arrange for started_cb_ to be called on the UI thread with the | 93 // Arrange for started_cb_ to be called on the UI thread with the |
| 88 // below values, nulling out started_cb_. Should only be called | 94 // below values, nulling out started_cb_. Should only be called |
| 89 // on the IO thread. | 95 // on the IO thread. |
| 90 void CallStartedCB(DownloadItem* item, | 96 void CallStartedCB(DownloadItem* item, |
| 91 DownloadInterruptReason interrupt_reason); | 97 DownloadInterruptReason interrupt_reason); |
| 92 | 98 |
| 93 uint32 download_id_; | 99 uint32 download_id_; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 120 base::TimeDelta total_pause_time_; | 126 base::TimeDelta total_pause_time_; |
| 121 size_t last_buffer_size_; | 127 size_t last_buffer_size_; |
| 122 int64 bytes_read_; | 128 int64 bytes_read_; |
| 123 | 129 |
| 124 int pause_count_; | 130 int pause_count_; |
| 125 bool was_deferred_; | 131 bool was_deferred_; |
| 126 | 132 |
| 127 // For DCHECKing | 133 // For DCHECKing |
| 128 bool on_response_started_called_; | 134 bool on_response_started_called_; |
| 129 | 135 |
| 136 // DownloadManager passed in by the owner of DownloadResourceHandler. |
| 137 base::WeakPtr<DownloadManagerImpl> download_manager_; |
| 138 |
| 130 static const int kReadBufSize = 32768; // bytes | 139 static const int kReadBufSize = 32768; // bytes |
| 131 static const int kThrottleTimeMs = 200; // milliseconds | 140 static const int kThrottleTimeMs = 200; // milliseconds |
| 132 | 141 |
| 133 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); | 142 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); |
| 134 }; | 143 }; |
| 135 | 144 |
| 136 } // namespace content | 145 } // namespace content |
| 137 | 146 |
| 138 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_ | 147 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_ |
| OLD | NEW |