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

Side by Side Diff: chrome/browser/extensions/api/image_writer_private/operation.h

Issue 61643015: Adds imageWriterPrivate support for Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes comment. Created 6 years, 10 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 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
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 the
122 void WriteChunk(scoped_ptr<image_writer_utils::ImageReader> reader, 123 // Operation.
123 scoped_ptr<image_writer_utils::ImageWriter> writer, 124 void StartImageWriterClient();
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 125
129 void VerifyWriteStage2(scoped_ptr<std::string> image_hash); 126 // Stops the client. This must be called to ensure the utility process can
130 void VerifyWriteCompare(scoped_ptr<std::string> image_hash, 127 // shutdown.
131 scoped_ptr<std::string> device_hash); 128 void StopImageWriterClient();
129
130 // Reports progress from the client, transforming from bytes to percentage.
131 virtual void WriteImageProgress(int64 total_bytes, int64 curr_bytes);
132
133 scoped_refptr<ImageWriterClient> image_writer_client_;
132 #endif 134 #endif
133 135
134 #if defined(OS_CHROMEOS) 136 #if defined(OS_CHROMEOS)
135 void StartWriteOnUIThread(); 137 void StartWriteOnUIThread();
136 138
137 void OnBurnFinished(const std::string& target_path, 139 void OnBurnFinished(const std::string& target_path,
138 bool success, 140 bool success,
139 const std::string& error); 141 const std::string& error);
140 void OnBurnProgress(const std::string& target_path, 142 void OnBurnProgress(const std::string& target_path,
141 int64 num_bytes_burnt, 143 int64 num_bytes_burnt,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 175
174 // CleanUp operations that must be run. All these functions are run on the 176 // CleanUp operations that must be run. All these functions are run on the
175 // FILE thread. 177 // FILE thread.
176 std::vector<base::Closure> cleanup_functions_; 178 std::vector<base::Closure> cleanup_functions_;
177 }; 179 };
178 180
179 } // namespace image_writer 181 } // namespace image_writer
180 } // namespace extensions 182 } // namespace extensions
181 183
182 #endif // CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_OPERATION_H_ 184 #endif // CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_OPERATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698