| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 int render_process_host_id, | 43 int render_process_host_id, |
| 44 int render_frame_routing_id, | 44 int render_frame_routing_id, |
| 45 const GURL& url, | 45 const GURL& url, |
| 46 AuthorizationState authorization_state); | 46 AuthorizationState authorization_state); |
| 47 ~SaveFileResourceHandler() override; | 47 ~SaveFileResourceHandler() override; |
| 48 | 48 |
| 49 // ResourceHandler Implementation: | 49 // ResourceHandler Implementation: |
| 50 | 50 |
| 51 // Saves the redirected URL to final_url_, we need to use the original | 51 // Saves the redirected URL to final_url_, we need to use the original |
| 52 // URL to match original request. | 52 // URL to match original request. |
| 53 bool OnRequestRedirected(const net::RedirectInfo& redirect_info, | 53 void OnRequestRedirected( |
| 54 ResourceResponse* response, | 54 const net::RedirectInfo& redirect_info, |
| 55 bool* defer) override; | 55 ResourceResponse* response, |
| 56 std::unique_ptr<ResourceController> controller) override; |
| 56 | 57 |
| 57 // Sends the download creation information to the download thread. | 58 // Sends the download creation information to the download thread. |
| 58 bool OnResponseStarted(ResourceResponse* response, bool* defer) override; | 59 void OnResponseStarted( |
| 60 ResourceResponse* response, |
| 61 std::unique_ptr<ResourceController> controller) override; |
| 59 | 62 |
| 60 // Pass-through implementation. | 63 // Pass-through implementation. |
| 61 bool OnWillStart(const GURL& url, bool* defer) override; | 64 void OnWillStart(const GURL& url, |
| 65 std::unique_ptr<ResourceController> controller) override; |
| 62 | 66 |
| 63 // Creates a new buffer, which will be handed to the download thread for file | 67 // Creates a new buffer, which will be handed to the download thread for file |
| 64 // writing and deletion. | 68 // writing and deletion. |
| 65 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, | 69 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, |
| 66 int* buf_size, | 70 int* buf_size, |
| 67 int min_size) override; | 71 int min_size) override; |
| 68 | 72 |
| 69 // Passes the buffer to the download file writer. | 73 // Passes the buffer to the download file writer. |
| 70 bool OnReadCompleted(int bytes_read, bool* defer) override; | 74 void OnReadCompleted(int bytes_read, |
| 75 std::unique_ptr<ResourceController> controller) override; |
| 71 | 76 |
| 72 void OnResponseCompleted(const net::URLRequestStatus& status, | 77 void OnResponseCompleted( |
| 73 bool* defer) override; | 78 const net::URLRequestStatus& status, |
| 79 std::unique_ptr<ResourceController> controller) override; |
| 74 | 80 |
| 75 // N/A to this flavor of SaveFileResourceHandler. | 81 // N/A to this flavor of SaveFileResourceHandler. |
| 76 void OnDataDownloaded(int bytes_downloaded) override; | 82 void OnDataDownloaded(int bytes_downloaded) override; |
| 77 | 83 |
| 78 // If the content-length header is not present (or contains something other | 84 // If the content-length header is not present (or contains something other |
| 79 // than numbers), StringToInt64 returns 0, which indicates 'unknown size' and | 85 // than numbers), StringToInt64 returns 0, which indicates 'unknown size' and |
| 80 // is handled correctly by the SaveManager. | 86 // is handled correctly by the SaveManager. |
| 81 void set_content_length(const std::string& content_length); | 87 void set_content_length(const std::string& content_length); |
| 82 | 88 |
| 83 void set_content_disposition(const std::string& content_disposition) { | 89 void set_content_disposition(const std::string& content_disposition) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 99 AuthorizationState authorization_state_; | 105 AuthorizationState authorization_state_; |
| 100 | 106 |
| 101 static const int kReadBufSize = 32768; // bytes | 107 static const int kReadBufSize = 32768; // bytes |
| 102 | 108 |
| 103 DISALLOW_COPY_AND_ASSIGN(SaveFileResourceHandler); | 109 DISALLOW_COPY_AND_ASSIGN(SaveFileResourceHandler); |
| 104 }; | 110 }; |
| 105 | 111 |
| 106 } // namespace content | 112 } // namespace content |
| 107 | 113 |
| 108 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_RESOURCE_HANDLER_H_ | 114 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_RESOURCE_HANDLER_H_ |
| OLD | NEW |