| OLD | NEW |
| 1 // Copyright (c) 2011 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_RENDERER_HOST_SAVE_FILE_RESOURCE_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_SAVE_FILE_RESOURCE_HANDLER_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_SAVE_FILE_RESOURCE_HANDLER_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_SAVE_FILE_RESOURCE_HANDLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "content/browser/renderer_host/resource_handler.h" | 11 #include "content/browser/renderer_host/resource_handler.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 // Saves the redirected URL to final_url_, we need to use the original | 29 // Saves the redirected URL to final_url_, we need to use the original |
| 30 // URL to match original request. | 30 // URL to match original request. |
| 31 virtual bool OnRequestRedirected(int request_id, | 31 virtual bool OnRequestRedirected(int request_id, |
| 32 const GURL& url, | 32 const GURL& url, |
| 33 content::ResourceResponse* response, | 33 content::ResourceResponse* response, |
| 34 bool* defer) OVERRIDE; | 34 bool* defer) OVERRIDE; |
| 35 | 35 |
| 36 // Sends the download creation information to the download thread. | 36 // Sends the download creation information to the download thread. |
| 37 virtual bool OnResponseStarted(int request_id, | 37 virtual bool OnResponseStarted(int request_id, |
| 38 content::ResourceResponse* response) OVERRIDE; | 38 content::ResourceResponse* response, |
| 39 bool* defer) OVERRIDE; |
| 39 | 40 |
| 40 // Pass-through implementation. | 41 // Pass-through implementation. |
| 41 virtual bool OnWillStart(int request_id, | 42 virtual bool OnWillStart(int request_id, |
| 42 const GURL& url, | 43 const GURL& url, |
| 43 bool* defer) OVERRIDE; | 44 bool* defer) OVERRIDE; |
| 44 | 45 |
| 45 // Creates a new buffer, which will be handed to the download thread for file | 46 // Creates a new buffer, which will be handed to the download thread for file |
| 46 // writing and deletion. | 47 // writing and deletion. |
| 47 virtual bool OnWillRead(int request_id, | 48 virtual bool OnWillRead(int request_id, |
| 48 net::IOBuffer** buf, | 49 net::IOBuffer** buf, |
| 49 int* buf_size, | 50 int* buf_size, |
| 50 int min_size) OVERRIDE; | 51 int min_size) OVERRIDE; |
| 51 | 52 |
| 52 // Passes the buffer to the download file writer. | 53 // Passes the buffer to the download file writer. |
| 53 virtual bool OnReadCompleted(int request_id, int* bytes_read) OVERRIDE; | 54 virtual bool OnReadCompleted(int request_id, int* bytes_read, |
| 55 bool* defer) OVERRIDE; |
| 54 | 56 |
| 55 virtual bool OnResponseCompleted(int request_id, | 57 virtual bool OnResponseCompleted(int request_id, |
| 56 const net::URLRequestStatus& status, | 58 const net::URLRequestStatus& status, |
| 57 const std::string& security_info) OVERRIDE; | 59 const std::string& security_info) OVERRIDE; |
| 58 | 60 |
| 59 virtual void OnRequestClosed() OVERRIDE; | 61 virtual void OnRequestClosed() OVERRIDE; |
| 60 | 62 |
| 61 // If the content-length header is not present (or contains something other | 63 // If the content-length header is not present (or contains something other |
| 62 // than numbers), StringToInt64 returns 0, which indicates 'unknown size' and | 64 // than numbers), StringToInt64 returns 0, which indicates 'unknown size' and |
| 63 // is handled correctly by the SaveManager. | 65 // is handled correctly by the SaveManager. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 79 GURL final_url_; | 81 GURL final_url_; |
| 80 int64 content_length_; | 82 int64 content_length_; |
| 81 SaveFileManager* save_manager_; | 83 SaveFileManager* save_manager_; |
| 82 | 84 |
| 83 static const int kReadBufSize = 32768; // bytes | 85 static const int kReadBufSize = 32768; // bytes |
| 84 | 86 |
| 85 DISALLOW_COPY_AND_ASSIGN(SaveFileResourceHandler); | 87 DISALLOW_COPY_AND_ASSIGN(SaveFileResourceHandler); |
| 86 }; | 88 }; |
| 87 | 89 |
| 88 #endif // CONTENT_BROWSER_RENDERER_HOST_SAVE_FILE_RESOURCE_HANDLER_H_ | 90 #endif // CONTENT_BROWSER_RENDERER_HOST_SAVE_FILE_RESOURCE_HANDLER_H_ |
| OLD | NEW |