OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_OPERATION_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_OPERATION_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_OPERATION_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_OPERATION_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/md5.h" | 9 #include "base/md5.h" |
10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/task/cancelable_task_tracker.h" | 12 #include "base/task/cancelable_task_tracker.h" |
13 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
14 #include "chrome/browser/extensions/api/image_writer_private/image_writer_utils. h" | 14 #include "chrome/browser/extensions/api/image_writer_private/image_writer_utils. h" |
15 #include "chrome/browser/image_writer_client.h" | |
15 #include "chrome/common/extensions/api/image_writer_private.h" | 16 #include "chrome/common/extensions/api/image_writer_private.h" |
16 #include "third_party/zlib/google/zip_reader.h" | 17 #include "third_party/zlib/google/zip_reader.h" |
17 | 18 |
18 namespace image_writer_api = extensions::api::image_writer_private; | 19 namespace image_writer_api = extensions::api::image_writer_private; |
19 | 20 |
20 namespace base { | 21 namespace base { |
21 class FilePath; | 22 class FilePath; |
22 } // namespace base | 23 } // namespace base |
23 | 24 |
24 namespace extensions { | 25 namespace extensions { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 | 110 |
110 base::FilePath image_path_; | 111 base::FilePath image_path_; |
111 const std::string storage_unit_id_; | 112 const std::string storage_unit_id_; |
112 | 113 |
113 // Whether or not to run the final verification step. | 114 // Whether or not to run the final verification step. |
114 bool verify_write_; | 115 bool verify_write_; |
115 | 116 |
116 private: | 117 private: |
117 friend class base::RefCountedThreadSafe<Operation>; | 118 friend class base::RefCountedThreadSafe<Operation>; |
118 | 119 |
119 // TODO(haven): Clean up these switches. http://crbug.com/292956 | 120 #if !defined(OS_CHROMEOS) |
120 #if defined(OS_LINUX) && !defined(CHROMEOS) | 121 // Ensures the client is started. This may be called many times but will only |
121 void WriteRun(); | 122 // instantiate one client which should exist for the lifetime of |
Jorge Lucangeli Obes
2014/02/14 20:42:13
for the lifetime of... what?
Drew Haven
2014/02/14 23:00:57
Oops, the operation. E.g. one client per write/ve
| |
122 void WriteChunk(scoped_ptr<image_writer_utils::ImageReader> reader, | 123 void StartImageWriterClient(); |
123 scoped_ptr<image_writer_utils::ImageWriter> writer, | |
124 int64 bytes_written); | |
125 bool WriteCleanUp(scoped_ptr<image_writer_utils::ImageReader> reader, | |
126 scoped_ptr<image_writer_utils::ImageWriter> writer); | |
127 void WriteComplete(); | |
128 | 124 |
129 void VerifyWriteStage2(scoped_ptr<std::string> image_hash); | 125 // Stops the client. This must be called to ensure the utility process can |
130 void VerifyWriteCompare(scoped_ptr<std::string> image_hash, | 126 // shutdown. |
131 scoped_ptr<std::string> device_hash); | 127 void StopImageWriterClient(); |
128 | |
129 // Reports progress from the client, transforming from bytes to percentage. | |
130 virtual void WriteImageProgress(int64 total_bytes, int64 curr_bytes); | |
131 | |
132 scoped_refptr<ImageWriterClient> image_writer_client_; | |
132 #endif | 133 #endif |
133 | 134 |
134 #if defined(OS_CHROMEOS) | 135 #if defined(OS_CHROMEOS) |
135 void StartWriteOnUIThread(); | 136 void StartWriteOnUIThread(); |
136 | 137 |
137 void OnBurnFinished(const std::string& target_path, | 138 void OnBurnFinished(const std::string& target_path, |
138 bool success, | 139 bool success, |
139 const std::string& error); | 140 const std::string& error); |
140 void OnBurnProgress(const std::string& target_path, | 141 void OnBurnProgress(const std::string& target_path, |
141 int64 num_bytes_burnt, | 142 int64 num_bytes_burnt, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 | 174 |
174 // CleanUp operations that must be run. All these functions are run on the | 175 // CleanUp operations that must be run. All these functions are run on the |
175 // FILE thread. | 176 // FILE thread. |
176 std::vector<base::Closure> cleanup_functions_; | 177 std::vector<base::Closure> cleanup_functions_; |
177 }; | 178 }; |
178 | 179 |
179 } // namespace image_writer | 180 } // namespace image_writer |
180 } // namespace extensions | 181 } // namespace extensions |
181 | 182 |
182 #endif // CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_OPERATION_H_ | 183 #endif // CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_OPERATION_H_ |
OLD | NEW |