| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium OS 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 CHROMEOS_PLATFORM_UPDATE_ENGINE_DOWNLOAD_ACTION_H__ | 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_DOWNLOAD_ACTION_H__ |
| 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_DOWNLOAD_ACTION_H__ | 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_DOWNLOAD_ACTION_H__ |
| 7 | 7 |
| 8 #include <sys/types.h> | 8 #include <sys/types.h> |
| 9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
| 10 #include <fcntl.h> | 10 #include <fcntl.h> |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 // Called periodically after bytes are received. This method will be | 43 // Called periodically after bytes are received. This method will be |
| 44 // invoked only if the download is active. |bytes_received| is the | 44 // invoked only if the download is active. |bytes_received| is the |
| 45 // number of bytes downloaded thus far. |total| is the number of | 45 // number of bytes downloaded thus far. |total| is the number of |
| 46 // bytes expected. | 46 // bytes expected. |
| 47 virtual void BytesReceived(uint64_t bytes_received, uint64_t total) = 0; | 47 virtual void BytesReceived(uint64_t bytes_received, uint64_t total) = 0; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 class DownloadAction; | 50 class DownloadAction; |
| 51 class NoneType; | 51 class NoneType; |
| 52 class PrefsInterface; |
| 52 | 53 |
| 53 template<> | 54 template<> |
| 54 class ActionTraits<DownloadAction> { | 55 class ActionTraits<DownloadAction> { |
| 55 public: | 56 public: |
| 56 // Takes and returns an InstallPlan | 57 // Takes and returns an InstallPlan |
| 57 typedef InstallPlan InputObjectType; | 58 typedef InstallPlan InputObjectType; |
| 58 typedef InstallPlan OutputObjectType; | 59 typedef InstallPlan OutputObjectType; |
| 59 }; | 60 }; |
| 60 | 61 |
| 61 class DownloadAction : public Action<DownloadAction>, | 62 class DownloadAction : public Action<DownloadAction>, |
| 62 public HttpFetcherDelegate { | 63 public HttpFetcherDelegate { |
| 63 public: | 64 public: |
| 64 // Takes ownership of the passed in HttpFetcher. Useful for testing. | 65 // Takes ownership of the passed in HttpFetcher. Useful for testing. |
| 65 // A good calling pattern is: | 66 // A good calling pattern is: |
| 66 // DownloadAction(new WhateverHttpFetcher); | 67 // DownloadAction(new WhateverHttpFetcher); |
| 67 DownloadAction(HttpFetcher* http_fetcher); | 68 DownloadAction(PrefsInterface* prefs, HttpFetcher* http_fetcher); |
| 68 virtual ~DownloadAction(); | 69 virtual ~DownloadAction(); |
| 69 typedef ActionTraits<DownloadAction>::InputObjectType InputObjectType; | 70 typedef ActionTraits<DownloadAction>::InputObjectType InputObjectType; |
| 70 typedef ActionTraits<DownloadAction>::OutputObjectType OutputObjectType; | 71 typedef ActionTraits<DownloadAction>::OutputObjectType OutputObjectType; |
| 71 void PerformAction(); | 72 void PerformAction(); |
| 72 void TerminateProcessing(); | 73 void TerminateProcessing(); |
| 73 | 74 |
| 74 // Testing | 75 // Testing |
| 75 void SetTestFileWriter(FileWriter* writer) { | 76 void SetTestFileWriter(FileWriter* writer) { |
| 76 writer_ = writer; | 77 writer_ = writer; |
| 77 } | 78 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 89 | 90 |
| 90 DownloadActionDelegate* delegate() const { return delegate_; } | 91 DownloadActionDelegate* delegate() const { return delegate_; } |
| 91 void set_delegate(DownloadActionDelegate* delegate) { | 92 void set_delegate(DownloadActionDelegate* delegate) { |
| 92 delegate_ = delegate; | 93 delegate_ = delegate; |
| 93 } | 94 } |
| 94 | 95 |
| 95 private: | 96 private: |
| 96 // The InstallPlan passed in | 97 // The InstallPlan passed in |
| 97 InstallPlan install_plan_; | 98 InstallPlan install_plan_; |
| 98 | 99 |
| 100 // Update Engine preference store. |
| 101 PrefsInterface* prefs_; |
| 102 |
| 99 // The FileWriter that downloaded data should be written to. It will | 103 // The FileWriter that downloaded data should be written to. It will |
| 100 // either point to *decompressing_file_writer_ or *delta_performer_. | 104 // either point to *decompressing_file_writer_ or *delta_performer_. |
| 101 FileWriter* writer_; | 105 FileWriter* writer_; |
| 102 | 106 |
| 103 // These are used for full updates: | 107 // These are used for full updates: |
| 104 scoped_ptr<GzipDecompressingFileWriter> decompressing_file_writer_; | 108 scoped_ptr<GzipDecompressingFileWriter> decompressing_file_writer_; |
| 105 scoped_ptr<SplitFileWriter> split_file_writer_; | 109 scoped_ptr<SplitFileWriter> split_file_writer_; |
| 106 scoped_ptr<DirectFileWriter> kernel_file_writer_; | 110 scoped_ptr<DirectFileWriter> kernel_file_writer_; |
| 107 scoped_ptr<DirectFileWriter> rootfs_file_writer_; | 111 scoped_ptr<DirectFileWriter> rootfs_file_writer_; |
| 108 scoped_ptr<BufferedFileWriter> kernel_buffered_file_writer_; | 112 scoped_ptr<BufferedFileWriter> kernel_buffered_file_writer_; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 124 DISALLOW_COPY_AND_ASSIGN(DownloadAction); | 128 DISALLOW_COPY_AND_ASSIGN(DownloadAction); |
| 125 }; | 129 }; |
| 126 | 130 |
| 127 // We want to be sure that we're compiled with large file support on linux, | 131 // We want to be sure that we're compiled with large file support on linux, |
| 128 // just in case we find ourselves downloading large images. | 132 // just in case we find ourselves downloading large images. |
| 129 COMPILE_ASSERT(8 == sizeof(off_t), off_t_not_64_bit); | 133 COMPILE_ASSERT(8 == sizeof(off_t), off_t_not_64_bit); |
| 130 | 134 |
| 131 } // namespace chromeos_update_engine | 135 } // namespace chromeos_update_engine |
| 132 | 136 |
| 133 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DOWNLOAD_ACTION_H__ | 137 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DOWNLOAD_ACTION_H__ |
| OLD | NEW |