| 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/timer/timer.h" | 12 #include "base/timer/timer.h" |
| 13 #include "content/browser/loader/resource_handler.h" | 13 #include "content/browser/loader/resource_handler.h" |
| 14 #include "content/public/browser/download_interrupt_reasons.h" |
| 14 #include "content/public/browser/download_manager.h" | 15 #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 #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 | |
| 20 | 19 |
| 21 namespace net { | 20 namespace net { |
| 22 class URLRequest; | 21 class URLRequest; |
| 23 } // namespace net | 22 } // namespace net |
| 24 | 23 |
| 25 namespace content { | 24 namespace content { |
| 26 class ByteStreamWriter; | 25 class ByteStreamWriter; |
| 27 class ByteStreamReader; | 26 class ByteStreamReader; |
| 28 class DownloadRequestHandle; | 27 class DownloadRequestHandle; |
| 29 struct DownloadCreateInfo; | 28 struct DownloadCreateInfo; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 void CancelRequest(); | 86 void CancelRequest(); |
| 88 | 87 |
| 89 std::string DebugString() const; | 88 std::string DebugString() const; |
| 90 | 89 |
| 91 private: | 90 private: |
| 92 virtual ~DownloadResourceHandler(); | 91 virtual ~DownloadResourceHandler(); |
| 93 | 92 |
| 94 // 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 |
| 95 // below values, nulling out started_cb_. Should only be called | 94 // below values, nulling out started_cb_. Should only be called |
| 96 // on the IO thread. | 95 // on the IO thread. |
| 97 void CallStartedCB(DownloadItem* item, net::Error error); | 96 void CallStartedCB(DownloadItem* item, |
| 97 DownloadInterruptReason interrupt_reason); |
| 98 | 98 |
| 99 uint32 download_id_; | 99 uint32 download_id_; |
| 100 // This is read only on the IO thread, but may only | 100 // This is read only on the IO thread, but may only |
| 101 // be called on the UI thread. | 101 // be called on the UI thread. |
| 102 DownloadUrlParameters::OnStartedCallback started_cb_; | 102 DownloadUrlParameters::OnStartedCallback started_cb_; |
| 103 scoped_ptr<DownloadSaveInfo> save_info_; | 103 scoped_ptr<DownloadSaveInfo> save_info_; |
| 104 | 104 |
| 105 // Data flow | 105 // Data flow |
| 106 scoped_refptr<net::IOBuffer> read_buffer_; // From URLRequest. | 106 scoped_refptr<net::IOBuffer> read_buffer_; // From URLRequest. |
| 107 scoped_ptr<ByteStreamWriter> stream_writer_; // To rest of system. | 107 scoped_ptr<ByteStreamWriter> stream_writer_; // To rest of system. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 122 | 122 |
| 123 static const int kReadBufSize = 32768; // bytes | 123 static const int kReadBufSize = 32768; // bytes |
| 124 static const int kThrottleTimeMs = 200; // milliseconds | 124 static const int kThrottleTimeMs = 200; // milliseconds |
| 125 | 125 |
| 126 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); | 126 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); |
| 127 }; | 127 }; |
| 128 | 128 |
| 129 } // namespace content | 129 } // namespace content |
| 130 | 130 |
| 131 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_ | 131 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_ |
| OLD | NEW |