| 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/files/file.h" | 9 #include "base/files/file.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| 11 #include "base/md5.h" | 11 #include "base/md5.h" |
| 12 #include "base/memory/ref_counted_memory.h" | 12 #include "base/memory/ref_counted_memory.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/task/cancelable_task_tracker.h" | 14 #include "base/task/cancelable_task_tracker.h" |
| 15 #include "chrome/browser/extensions/api/image_writer_private/image_writer_utilit
y_client.h" | 15 #include "chrome/browser/extensions/api/image_writer_private/image_writer_utilit
y_client.h" |
| 16 #include "chrome/common/extensions/api/image_writer_private.h" | 16 #include "chrome/common/extensions/api/image_writer_private.h" |
| 17 #include "third_party/zlib/google/zip_reader.h" | 17 |
| 18 | 18 |
| 19 namespace image_writer_api = extensions::api::image_writer_private; | 19 namespace image_writer_api = extensions::api::image_writer_private; |
| 20 | 20 |
| 21 namespace base { | 21 namespace base { |
| 22 class FilePath; | 22 class FilePath; |
| 23 } // namespace base | 23 } // namespace base |
| 24 | 24 |
| 25 namespace zip { |
| 26 class ZipReader; |
| 27 } |
| 28 |
| 25 namespace extensions { | 29 namespace extensions { |
| 26 namespace image_writer { | 30 namespace image_writer { |
| 27 | 31 |
| 28 const int kProgressComplete = 100; | 32 const int kProgressComplete = 100; |
| 29 | 33 |
| 30 class OperationManager; | 34 class OperationManager; |
| 31 | 35 |
| 32 // Encapsulates an operation being run on behalf of the | 36 // Encapsulates an operation being run on behalf of the |
| 33 // OperationManager. Construction of the operation does not start | 37 // OperationManager. Construction of the operation does not start |
| 34 // anything. The operation's Start method should be called to start it, and | 38 // anything. The operation's Start method should be called to start it, and |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 | 204 |
| 201 // |stage_| and |progress_| are owned by the FILE thread, use |SetStage| and | 205 // |stage_| and |progress_| are owned by the FILE thread, use |SetStage| and |
| 202 // |SetProgress| to update. Progress should be in the interval [0,100] | 206 // |SetProgress| to update. Progress should be in the interval [0,100] |
| 203 image_writer_api::Stage stage_; | 207 image_writer_api::Stage stage_; |
| 204 int progress_; | 208 int progress_; |
| 205 | 209 |
| 206 // MD5 contexts don't play well with smart pointers. Just going to allocate | 210 // MD5 contexts don't play well with smart pointers. Just going to allocate |
| 207 // memory here. This requires that we only do one MD5 sum at a time. | 211 // memory here. This requires that we only do one MD5 sum at a time. |
| 208 base::MD5Context md5_context_; | 212 base::MD5Context md5_context_; |
| 209 | 213 |
| 210 // Zip reader for unzip operations. | 214 // Zip reader for unzip operations. The reason for using a pointer is that we |
| 211 zip::ZipReader zip_reader_; | 215 // don't want to include zip_reader.h here which can mangle definitions in |
| 216 // jni.h when included in the same file. See crbug.com/554199. |
| 217 scoped_ptr<zip::ZipReader> zip_reader_; |
| 212 | 218 |
| 213 // CleanUp operations that must be run. All these functions are run on the | 219 // CleanUp operations that must be run. All these functions are run on the |
| 214 // FILE thread. | 220 // FILE thread. |
| 215 std::vector<base::Closure> cleanup_functions_; | 221 std::vector<base::Closure> cleanup_functions_; |
| 216 }; | 222 }; |
| 217 | 223 |
| 218 } // namespace image_writer | 224 } // namespace image_writer |
| 219 } // namespace extensions | 225 } // namespace extensions |
| 220 | 226 |
| 221 #endif // CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_OPERATION_H_ | 227 #endif // CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_OPERATION_H_ |
| OLD | NEW |