| 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_REDIRECT_TO_FILE_RESOURCE_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_HOST_REDIRECT_TO_FILE_RESOURCE_HANDLER_H_ |
| 6 #define CHROME_BROWSER_RENDERER_HOST_REDIRECT_TO_FILE_RESOURCE_HANDLER_H_ | 6 #define CHROME_BROWSER_RENDERER_HOST_REDIRECT_TO_FILE_RESOURCE_HANDLER_H_ |
| 7 | 7 |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/platform_file.h" | 9 #include "base/platform_file.h" |
| 10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
| 11 #include "base/scoped_callback_factory.h" | 11 #include "base/scoped_callback_factory.h" |
| 12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 13 #include "chrome/browser/renderer_host/resource_handler.h" | 13 #include "chrome/browser/renderer_host/resource_handler.h" |
| 14 #include "net/base/completion_callback.h" | 14 #include "net/base/completion_callback.h" |
| 15 | 15 |
| 16 class RefCountedPlatformFile; | 16 class RefCountedPlatformFile; |
| 17 class ResourceDispatcherHost; | 17 class ResourceDispatcherHost; |
| 18 | 18 |
| 19 namespace net { | 19 namespace net { |
| 20 class FileStream; | 20 class FileStream; |
| 21 class GrowableIOBuffer; | 21 class GrowableIOBuffer; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace webkit_blob { | |
| 25 class DeletableFileReference; | |
| 26 } | |
| 27 | |
| 28 // Redirects network data to a file. This is intended to be layered in front | 24 // Redirects network data to a file. This is intended to be layered in front |
| 29 // of either the AsyncResourceHandler or the SyncResourceHandler. | 25 // of either the AsyncResourceHandler or the SyncResourceHandler. |
| 30 class RedirectToFileResourceHandler : public ResourceHandler { | 26 class RedirectToFileResourceHandler : public ResourceHandler { |
| 31 public: | 27 public: |
| 32 RedirectToFileResourceHandler( | 28 RedirectToFileResourceHandler( |
| 33 ResourceHandler* next_handler, | 29 ResourceHandler* next_handler, |
| 34 int process_id, | 30 int process_id, |
| 35 ResourceDispatcherHost* resource_dispatcher_host); | 31 ResourceDispatcherHost* resource_dispatcher_host); |
| 36 | 32 |
| 37 // ResourceHandler implementation: | 33 // ResourceHandler implementation: |
| (...skipping 30 matching lines...) Expand all Loading... |
| 68 // network (buf_write_pending_ is true while the system is copying data into | 64 // network (buf_write_pending_ is true while the system is copying data into |
| 69 // buf_), and then write this buffer out to disk (write_callback_pending_ is | 65 // buf_), and then write this buffer out to disk (write_callback_pending_ is |
| 70 // true while writing to disk). Reading from the network is suspended while | 66 // true while writing to disk). Reading from the network is suspended while |
| 71 // the buffer is full (BufIsFull returns true). The write_cursor_ member | 67 // the buffer is full (BufIsFull returns true). The write_cursor_ member |
| 72 // tracks the offset into buf_ that we are writing to disk. | 68 // tracks the offset into buf_ that we are writing to disk. |
| 73 | 69 |
| 74 scoped_refptr<net::GrowableIOBuffer> buf_; | 70 scoped_refptr<net::GrowableIOBuffer> buf_; |
| 75 bool buf_write_pending_; | 71 bool buf_write_pending_; |
| 76 int write_cursor_; | 72 int write_cursor_; |
| 77 | 73 |
| 74 FilePath file_path_; |
| 78 scoped_ptr<net::FileStream> file_stream_; | 75 scoped_ptr<net::FileStream> file_stream_; |
| 79 net::CompletionCallbackImpl<RedirectToFileResourceHandler> write_callback_; | 76 net::CompletionCallbackImpl<RedirectToFileResourceHandler> write_callback_; |
| 80 bool write_callback_pending_; | 77 bool write_callback_pending_; |
| 81 | 78 |
| 82 // We create a DeletableFileReference for the temp file created as | |
| 83 // a result of the download. | |
| 84 scoped_refptr<webkit_blob::DeletableFileReference> deletable_file_; | |
| 85 | |
| 86 DISALLOW_COPY_AND_ASSIGN(RedirectToFileResourceHandler); | 79 DISALLOW_COPY_AND_ASSIGN(RedirectToFileResourceHandler); |
| 87 }; | 80 }; |
| 88 | 81 |
| 89 #endif // CHROME_BROWSER_RENDERER_HOST_REDIRECT_TO_FILE_RESOURCE_HANDLER_H_ | 82 #endif // CHROME_BROWSER_RENDERER_HOST_REDIRECT_TO_FILE_RESOURCE_HANDLER_H_ |
| OLD | NEW |