Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: src/platform/update_engine/download_action.h

Issue 2037002: AU: DBus support. (Closed) Base URL: ssh://git@chromiumos-git/chromeos
Patch Set: fixes for review Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 15 matching lines...) Expand all
26 // The Download Action downloads a specified url to disk. The url should 26 // The Download Action downloads a specified url to disk. The url should
27 // point to either a full or delta update. If a full update, the file will 27 // point to either a full or delta update. If a full update, the file will
28 // be piped into a SplitFileWriter, which will direct it to the kernel 28 // be piped into a SplitFileWriter, which will direct it to the kernel
29 // and rootfs partitions. If it's a delta update, the destination kernel 29 // and rootfs partitions. If it's a delta update, the destination kernel
30 // and rootfs should already contain the source-version that this delta 30 // and rootfs should already contain the source-version that this delta
31 // update goes from. In this case, the update will be piped into a 31 // update goes from. In this case, the update will be piped into a
32 // DeltaPerformer that will apply the delta to the disk. 32 // DeltaPerformer that will apply the delta to the disk.
33 33
34 namespace chromeos_update_engine { 34 namespace chromeos_update_engine {
35 35
36 class DownloadActionDelegate {
37 public:
38 // Called before any bytes are received and periodically after
39 // bytes are received.
40 // bytes_received is the number of bytes downloaded thus far.
41 // total is the number of bytes expected.
42 virtual void BytesReceived(uint64_t bytes_received, uint64_t total) = 0;
43 };
44
36 class DownloadAction; 45 class DownloadAction;
37 class NoneType; 46 class NoneType;
38 47
39 template<> 48 template<>
40 class ActionTraits<DownloadAction> { 49 class ActionTraits<DownloadAction> {
41 public: 50 public:
42 // Takes and returns an InstallPlan 51 // Takes and returns an InstallPlan
43 typedef InstallPlan InputObjectType; 52 typedef InstallPlan InputObjectType;
44 typedef InstallPlan OutputObjectType; 53 typedef InstallPlan OutputObjectType;
45 }; 54 };
(...skipping 13 matching lines...) Expand all
59 68
60 // Testing 69 // Testing
61 void SetTestFileWriter(FileWriter* writer) { 70 void SetTestFileWriter(FileWriter* writer) {
62 writer_ = writer; 71 writer_ = writer;
63 } 72 }
64 73
65 // Debugging/logging 74 // Debugging/logging
66 static std::string StaticType() { return "DownloadAction"; } 75 static std::string StaticType() { return "DownloadAction"; }
67 std::string Type() const { return StaticType(); } 76 std::string Type() const { return StaticType(); }
68 77
69 // Delegate methods (see http_fetcher.h) 78 // HttpFetcherDelegate methods (see http_fetcher.h)
70 virtual void ReceivedBytes(HttpFetcher *fetcher, 79 virtual void ReceivedBytes(HttpFetcher *fetcher,
71 const char* bytes, int length); 80 const char* bytes, int length);
72 virtual void TransferComplete(HttpFetcher *fetcher, bool successful); 81 virtual void TransferComplete(HttpFetcher *fetcher, bool successful);
73 82
83 void set_delegate(DownloadActionDelegate* delegate) {
84 delegate_ = delegate;
85 }
86
74 private: 87 private:
75 // The InstallPlan passed in 88 // The InstallPlan passed in
76 InstallPlan install_plan_; 89 InstallPlan install_plan_;
77 90
78 // The FileWriter that downloaded data should be written to. It will 91 // The FileWriter that downloaded data should be written to. It will
79 // either point to *decompressing_file_writer_ or *delta_performer_. 92 // either point to *decompressing_file_writer_ or *delta_performer_.
80 FileWriter* writer_; 93 FileWriter* writer_;
81 94
82 // These are used for full updates: 95 // These are used for full updates:
83 scoped_ptr<GzipDecompressingFileWriter> decompressing_file_writer_; 96 scoped_ptr<GzipDecompressingFileWriter> decompressing_file_writer_;
84 scoped_ptr<SplitFileWriter> split_file_writer_; 97 scoped_ptr<SplitFileWriter> split_file_writer_;
85 scoped_ptr<DirectFileWriter> kernel_file_writer_; 98 scoped_ptr<DirectFileWriter> kernel_file_writer_;
86 scoped_ptr<DirectFileWriter> rootfs_file_writer_; 99 scoped_ptr<DirectFileWriter> rootfs_file_writer_;
87 100
88 // Used to apply a delta update: 101 // Used to apply a delta update:
89 scoped_ptr<DeltaPerformer> delta_performer_; 102 scoped_ptr<DeltaPerformer> delta_performer_;
90 103
91 // Pointer to the HttpFetcher that does the http work. 104 // Pointer to the HttpFetcher that does the http work.
92 scoped_ptr<HttpFetcher> http_fetcher_; 105 scoped_ptr<HttpFetcher> http_fetcher_;
93 106
94 // Used to find the hash of the bytes downloaded 107 // Used to find the hash of the bytes downloaded
95 OmahaHashCalculator omaha_hash_calculator_; 108 OmahaHashCalculator omaha_hash_calculator_;
109
110 // For reporting status to outsiders
111 DownloadActionDelegate* delegate_;
112 uint64_t bytes_received_;
113
96 DISALLOW_COPY_AND_ASSIGN(DownloadAction); 114 DISALLOW_COPY_AND_ASSIGN(DownloadAction);
97 }; 115 };
98 116
99 // We want to be sure that we're compiled with large file support on linux, 117 // We want to be sure that we're compiled with large file support on linux,
100 // just in case we find ourselves downloading large images. 118 // just in case we find ourselves downloading large images.
101 COMPILE_ASSERT(8 == sizeof(off_t), off_t_not_64_bit); 119 COMPILE_ASSERT(8 == sizeof(off_t), off_t_not_64_bit);
102 120
103 } // namespace chromeos_update_engine 121 } // namespace chromeos_update_engine
104 122
105 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DOWNLOAD_ACTION_H__ 123 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DOWNLOAD_ACTION_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698