| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 CHROME_BROWSER_RENDERER_HOST_SAVE_FILE_RESOURCE_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_HOST_SAVE_FILE_RESOURCE_HANDLER_H_ |
| 6 #define CHROME_BROWSER_RENDERER_HOST_SAVE_FILE_RESOURCE_HANDLER_H_ | 6 #define CHROME_BROWSER_RENDERER_HOST_SAVE_FILE_RESOURCE_HANDLER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "chrome/browser/renderer_host/resource_handler.h" | 10 #include "chrome/browser/renderer_host/resource_handler.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 // Saves the redirected URL to final_url_, we need to use the original | 22 // Saves the redirected URL to final_url_, we need to use the original |
| 23 // URL to match original request. | 23 // URL to match original request. |
| 24 bool OnRequestRedirected(int request_id, const GURL& url); | 24 bool OnRequestRedirected(int request_id, const GURL& url); |
| 25 | 25 |
| 26 // Sends the download creation information to the download thread. | 26 // Sends the download creation information to the download thread. |
| 27 bool OnResponseStarted(int request_id, ResourceResponse* response); | 27 bool OnResponseStarted(int request_id, ResourceResponse* response); |
| 28 | 28 |
| 29 // Creates a new buffer, which will be handed to the download thread for file | 29 // Creates a new buffer, which will be handed to the download thread for file |
| 30 // writing and deletion. | 30 // writing and deletion. |
| 31 bool OnWillRead(int request_id, char** buf, int* buf_size, int min_size); | 31 bool OnWillRead(int request_id, net::IOBuffer** buf, int* buf_size, |
| 32 int min_size); |
| 32 | 33 |
| 33 // Passes the buffer to the download file writer. | 34 // Passes the buffer to the download file writer. |
| 34 bool OnReadCompleted(int request_id, int* bytes_read); | 35 bool OnReadCompleted(int request_id, int* bytes_read); |
| 35 | 36 |
| 36 bool OnResponseCompleted(int request_id, const URLRequestStatus& status); | 37 bool OnResponseCompleted(int request_id, const URLRequestStatus& status); |
| 37 | 38 |
| 38 // If the content-length header is not present (or contains something other | 39 // If the content-length header is not present (or contains something other |
| 39 // than numbers), StringToInt64 returns 0, which indicates 'unknown size' and | 40 // than numbers), StringToInt64 returns 0, which indicates 'unknown size' and |
| 40 // is handled correctly by the SaveManager. | 41 // is handled correctly by the SaveManager. |
| 41 void set_content_length(const std::string& content_length) { | 42 void set_content_length(const std::string& content_length) { |
| 42 content_length_ = StringToInt64(content_length); | 43 content_length_ = StringToInt64(content_length); |
| 43 } | 44 } |
| 44 | 45 |
| 45 void set_content_disposition(const std::string& content_disposition) { | 46 void set_content_disposition(const std::string& content_disposition) { |
| 46 content_disposition_ = content_disposition; | 47 content_disposition_ = content_disposition; |
| 47 } | 48 } |
| 48 | 49 |
| 49 private: | 50 private: |
| 50 int save_id_; | 51 int save_id_; |
| 51 int render_process_id_; | 52 int render_process_id_; |
| 52 int render_view_id_; | 53 int render_view_id_; |
| 53 char* read_buffer_; | 54 scoped_refptr<net::IOBuffer> read_buffer_; |
| 54 std::string content_disposition_; | 55 std::string content_disposition_; |
| 55 std::wstring url_; | 56 std::wstring url_; |
| 56 std::wstring final_url_; | 57 std::wstring final_url_; |
| 57 int64 content_length_; | 58 int64 content_length_; |
| 58 SaveFileManager* save_manager_; | 59 SaveFileManager* save_manager_; |
| 59 | 60 |
| 60 static const int kReadBufSize = 32768; // bytes | 61 static const int kReadBufSize = 32768; // bytes |
| 61 | 62 |
| 62 DISALLOW_COPY_AND_ASSIGN(SaveFileResourceHandler); | 63 DISALLOW_COPY_AND_ASSIGN(SaveFileResourceHandler); |
| 63 }; | 64 }; |
| 64 #endif // CHROME_BROWSER_RENDERER_HOST_SAVE_FILE_RESOURCE_HANDLER_H_ | 65 #endif // CHROME_BROWSER_RENDERER_HOST_SAVE_FILE_RESOURCE_HANDLER_H_ |
| OLD | NEW |