Index: chrome/browser/image_writer/image_writer.h |
diff --git a/chrome/browser/image_writer/image_writer.h b/chrome/browser/image_writer/image_writer.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e9ee5580eb006b9a42d4ff9ad8b2400688ae8917 |
--- /dev/null |
+++ b/chrome/browser/image_writer/image_writer.h |
@@ -0,0 +1,63 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
jam
2013/11/21 19:36:41
here and in other files, the new copyright header
Drew Haven
2013/11/26 02:10:43
Done.
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_IMAGE_WRITER_IMAGE_WRITER_H_ |
+#define CHROME_BROWSER_IMAGE_WRITER_IMAGE_WRITER_H_ |
+ |
+#include <string> |
+#include <vector> |
+ |
+#include "base/files/file_path.h" |
+#include "base/threading/sequenced_worker_pool.h" |
+#include "content/public/browser/utility_process_host_client.h" |
+ |
+// Decodes an image in a sandboxed process. |
jam
2013/11/21 19:36:41
update
Drew Haven
2013/11/26 02:10:43
Done.
|
+class ImageWriter : public content::UtilityProcessHostClient { |
+ public: |
+ class Delegate { |
+ public: |
+ // Called when image is decoded. |
+ // |writer| is used to identify the image in case of decoding several |
+ // images simultaneously. |
+ virtual void OnWriteImageSucceeded() = 0; |
+ |
+ // Called when decoding image failed. Delegate can do some cleanup in |
+ // this handler. |
+ virtual void OnWriteImageFailed(const std::string& message) = 0; |
+ |
+ virtual void OnWriteImageProgress(int progress) = 0; |
+ |
+ protected: |
+ virtual ~Delegate() {} |
+ }; |
+ |
+ ImageWriter(Delegate* delegate, |
+ const base::FilePath& source, |
+ const base::FilePath& target); |
+ |
+ void Start(scoped_refptr<base::SequencedTaskRunner> task_runner); |
+ |
+ // Overidden from UtilityProcessHostClient: |
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
jam
2013/11/21 19:36:41
nit: put in private section
Drew Haven
2013/11/26 02:10:43
Done.
|
+ |
+ private: |
+ // It's a reference counted object, so destructor is private. |
+ virtual ~ImageWriter(); |
+ |
+ // IPC message handlers. |
+ void OnWriteImageSucceeded(); |
+ void OnWriteImageFailed(const std::string& message); |
+ void OnWriteImageProgress(int progress); |
+ |
+ void StartWriteInUtilityProcess(); |
+ |
+ Delegate* delegate_; |
+ base::FilePath source_; |
+ base::FilePath target_; |
+ scoped_refptr<base::SequencedTaskRunner> task_runner_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ImageWriter); |
+}; |
+ |
+#endif // CHROME_BROWSER_IMAGE_WRITER_IMAGE_WRITER_H_ |