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

Unified Diff: chrome/browser/extensions/api/image_writer_private/image_writer_utils.h

Issue 170123002: Revert of Significantly cleans up the ImageWriter Operation class and subclasses. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/image_writer_private/image_writer_utils.h
diff --git a/chrome/browser/extensions/api/image_writer_private/image_writer_utils.h b/chrome/browser/extensions/api/image_writer_private/image_writer_utils.h
new file mode 100644
index 0000000000000000000000000000000000000000..45beef04080220369dc74a63b47cf5d3bf40e7bf
--- /dev/null
+++ b/chrome/browser/extensions/api/image_writer_private/image_writer_utils.h
@@ -0,0 +1,53 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// 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_IMAGE_WRITER_UTILS_H_
+#define CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_IMAGE_WRITER_UTILS_H_
+
+#include "base/files/file_path.h"
+#include "base/platform_file.h"
+
+namespace extensions {
+namespace image_writer_utils {
+
+// Utility class for writing data to a removable disk.
+class ImageWriter {
+ public:
+ ImageWriter();
+ virtual ~ImageWriter();
+
+ // Note: If there is already a device open, it will be closed.
+ virtual bool Open(const base::FilePath& path);
+ virtual bool Close();
+
+ // Writes from data_block to the device, and returns the amount written or -1
+ // on error.
+ virtual int Write(const char* data_block, int data_size);
+
+ private:
+ base::PlatformFile file_;
+ int writes_count_;
+};
+
+// Utility class for reading a large file, such as a Chrome OS image.
+class ImageReader {
+ public:
+ ImageReader();
+ virtual ~ImageReader();
+
+ // Note: If there is already a file open, it will be closed.
+ virtual bool Open(const base::FilePath& path);
+ virtual bool Close();
+ // Read from the file into data_block.
+ virtual int Read(char* data_block, int data_size);
+ virtual int64 GetSize();
+
+ private:
+ base::PlatformFile file_;
+};
+
+} // namespace image_writer_utils
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_IMAGE_WRITER_UTILS_H_

Powered by Google App Engine
This is Rietveld 408576698