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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/files/file.h" | 13 #include "base/files/file.h" |
14 #include "base/files/scoped_temp_dir.h" | 14 #include "base/files/scoped_temp_dir.h" |
15 #include "base/md5.h" | 15 #include "base/md5.h" |
16 #include "base/memory/ref_counted_memory.h" | 16 #include "base/memory/ref_counted_memory.h" |
17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
18 #include "base/task/cancelable_task_tracker.h" | 18 #include "base/task/cancelable_task_tracker.h" |
19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
20 #include "chrome/browser/extensions/api/image_writer_private/image_writer_utilit
y_client.h" | 20 #include "chrome/browser/extensions/api/image_writer_private/image_writer_utilit
y_client.h" |
21 #include "chrome/common/extensions/api/image_writer_private.h" | 21 #include "chrome/common/extensions/api/image_writer_private.h" |
22 | 22 #include "extensions/common/extension_id.h" |
23 | 23 |
24 namespace image_writer_api = extensions::api::image_writer_private; | 24 namespace image_writer_api = extensions::api::image_writer_private; |
25 | 25 |
26 namespace base { | 26 namespace base { |
27 class FilePath; | 27 class FilePath; |
28 } // namespace base | 28 } // namespace base |
29 | 29 |
30 namespace zip { | 30 namespace zip { |
31 class ZipReader; | 31 class ZipReader; |
32 } | 32 } |
(...skipping 19 matching lines...) Expand all Loading... |
52 // TODO(haven): This class is current refcounted because it is owned by the | 52 // TODO(haven): This class is current refcounted because it is owned by the |
53 // OperationManager on the UI thread but needs to do work on the FILE thread. | 53 // OperationManager on the UI thread but needs to do work on the FILE thread. |
54 // There is probably a better way to organize this so that it can be represented | 54 // There is probably a better way to organize this so that it can be represented |
55 // by a WeakPtr, but those are not thread-safe. Additionally, if destruction is | 55 // by a WeakPtr, but those are not thread-safe. Additionally, if destruction is |
56 // done on the UI thread then that causes problems if any of the fields were | 56 // done on the UI thread then that causes problems if any of the fields were |
57 // allocated/accessed on the FILE thread. http://crbug.com/344713 | 57 // allocated/accessed on the FILE thread. http://crbug.com/344713 |
58 class Operation : public base::RefCountedThreadSafe<Operation> { | 58 class Operation : public base::RefCountedThreadSafe<Operation> { |
59 public: | 59 public: |
60 typedef base::Callback<void(bool, const std::string&)> StartWriteCallback; | 60 typedef base::Callback<void(bool, const std::string&)> StartWriteCallback; |
61 typedef base::Callback<void(bool, const std::string&)> CancelWriteCallback; | 61 typedef base::Callback<void(bool, const std::string&)> CancelWriteCallback; |
62 typedef std::string ExtensionId; | |
63 | 62 |
64 Operation(base::WeakPtr<OperationManager> manager, | 63 Operation(base::WeakPtr<OperationManager> manager, |
65 const ExtensionId& extension_id, | 64 const ExtensionId& extension_id, |
66 const std::string& device_path); | 65 const std::string& device_path); |
67 | 66 |
68 // Starts the operation. | 67 // Starts the operation. |
69 void Start(); | 68 void Start(); |
70 | 69 |
71 // Cancel the operation. This must be called to clean up internal state and | 70 // Cancel the operation. This must be called to clean up internal state and |
72 // cause the the operation to actually stop. It will not be destroyed until | 71 // cause the the operation to actually stop. It will not be destroyed until |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 222 |
224 // CleanUp operations that must be run. All these functions are run on the | 223 // CleanUp operations that must be run. All these functions are run on the |
225 // FILE thread. | 224 // FILE thread. |
226 std::vector<base::Closure> cleanup_functions_; | 225 std::vector<base::Closure> cleanup_functions_; |
227 }; | 226 }; |
228 | 227 |
229 } // namespace image_writer | 228 } // namespace image_writer |
230 } // namespace extensions | 229 } // namespace extensions |
231 | 230 |
232 #endif // CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_OPERATION_H_ | 231 #endif // CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_OPERATION_H_ |
OLD | NEW |