| 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_SAVE_FILE_RESOURCE_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_RESOURCE_HANDLER_H_ |
| 6 #define CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_RESOURCE_HANDLER_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_RESOURCE_HANDLER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "content/browser/loader/resource_handler.h" | 11 #include "content/browser/loader/resource_handler.h" |
| 12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
| 13 | 13 |
| 14 namespace net { | 14 namespace net { |
| 15 class URLRequest; | 15 class URLRequest; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 class SaveFileManager; | 19 class SaveFileManager; |
| 20 | 20 |
| 21 // Forwards data to the save thread. | 21 // Forwards data to the save thread. |
| 22 class SaveFileResourceHandler : public ResourceHandler { | 22 class SaveFileResourceHandler : public ResourceHandler { |
| 23 public: | 23 public: |
| 24 SaveFileResourceHandler(net::URLRequest* request, | 24 SaveFileResourceHandler(net::URLRequest* request, |
| 25 int save_item_id, |
| 25 int save_package_id, | 26 int save_package_id, |
| 26 int render_process_host_id, | 27 int render_process_host_id, |
| 27 int render_frame_routing_id, | 28 int render_frame_routing_id, |
| 28 const GURL& url, | 29 const GURL& url, |
| 29 SaveFileManager* manager); | 30 SaveFileManager* manager); |
| 30 ~SaveFileResourceHandler() override; | 31 ~SaveFileResourceHandler() override; |
| 31 | 32 |
| 32 // ResourceHandler Implementation: | 33 // ResourceHandler Implementation: |
| 33 | 34 |
| 34 // Saves the redirected URL to final_url_, we need to use the original | 35 // Saves the redirected URL to final_url_, we need to use the original |
| (...skipping 30 matching lines...) Expand all Loading... |
| 65 // If the content-length header is not present (or contains something other | 66 // If the content-length header is not present (or contains something other |
| 66 // than numbers), StringToInt64 returns 0, which indicates 'unknown size' and | 67 // than numbers), StringToInt64 returns 0, which indicates 'unknown size' and |
| 67 // is handled correctly by the SaveManager. | 68 // is handled correctly by the SaveManager. |
| 68 void set_content_length(const std::string& content_length); | 69 void set_content_length(const std::string& content_length); |
| 69 | 70 |
| 70 void set_content_disposition(const std::string& content_disposition) { | 71 void set_content_disposition(const std::string& content_disposition) { |
| 71 content_disposition_ = content_disposition; | 72 content_disposition_ = content_disposition; |
| 72 } | 73 } |
| 73 | 74 |
| 74 private: | 75 private: |
| 75 int save_id_; | 76 int save_item_id_; |
| 76 int save_package_id_; | 77 int save_package_id_; |
| 77 int render_process_id_; | 78 int render_process_id_; |
| 78 int render_frame_routing_id_; | 79 int render_frame_routing_id_; |
| 79 scoped_refptr<net::IOBuffer> read_buffer_; | 80 scoped_refptr<net::IOBuffer> read_buffer_; |
| 80 std::string content_disposition_; | 81 std::string content_disposition_; |
| 81 GURL url_; | 82 GURL url_; |
| 82 GURL final_url_; | 83 GURL final_url_; |
| 83 int64 content_length_; | 84 int64 content_length_; |
| 84 SaveFileManager* save_manager_; | 85 SaveFileManager* save_manager_; |
| 85 | 86 |
| 86 static const int kReadBufSize = 32768; // bytes | 87 static const int kReadBufSize = 32768; // bytes |
| 87 | 88 |
| 88 DISALLOW_COPY_AND_ASSIGN(SaveFileResourceHandler); | 89 DISALLOW_COPY_AND_ASSIGN(SaveFileResourceHandler); |
| 89 }; | 90 }; |
| 90 | 91 |
| 91 } // namespace content | 92 } // namespace content |
| 92 | 93 |
| 93 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_RESOURCE_HANDLER_H_ | 94 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_RESOURCE_HANDLER_H_ |
| OLD | NEW |