// Copyright 2013 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_OPERATION_H_ #define CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_OPERATION_H_ #include <stdint.h> #include <memory> #include "base/files/file.h" #include "base/files/scoped_temp_dir.h" #include "base/functional/callback.h" #include "base/hash/md5.h" #include "base/memory/ref_counted_memory.h" #include "base/memory/weak_ptr.h" #include "base/task/sequenced_task_runner.h" #include "base/task/task_traits.h" #include "build/build_config.h" #include "build/chromeos_buildflags.h" #include "chrome/common/extensions/api/image_writer_private.h" #include "extensions/common/extension_id.h" #if BUILDFLAG(IS_CHROMEOS_ASH) #include "chromeos/ash/components/disks/disk_mount_manager.h" #endif image_writer_api; namespace base { class FilePath; } // namespace base namespace extensions { namespace image_writer { const int kProgressComplete = …; class OperationManager; #if !BUILDFLAG(IS_CHROMEOS_ASH) class ImageWriterUtilityClient; #endif // Encapsulates an operation being run on behalf of the // OperationManager. Construction of the operation does not start // anything. The operation's Start method should be called to start it, and // then the Cancel method will stop it. The operation will call back to the // OperationManager periodically or on any significant event. // // Each stage of the operation is generally divided into multiple phases with // Start() being the first phase and Complete() being the last. All phases // except Complete() run on blocking thread and Complete() runs on the UI // thread. // // TODO(haven): This class is current refcounted because it is owned by the // OperationManager on the UI thread but needs to do work on blocking threads. // There is probably a better way to organize this so that it can be represented // by a WeakPtr, but those are not thread-safe. Additionally, if destruction is // done on the UI thread then that causes problems if any of the fields were // allocated/accessed on the blocking thread. http://crbug.com/344713 class Operation : public base::RefCountedThreadSafe<Operation> { … }; } // namespace image_writer } // namespace extensions #endif // CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_OPERATION_H_