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

Unified Diff: pdf/file_writer.h

Issue 317803005: Add function to document_loader to get PDF as pp::FileRef (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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: pdf/file_writer.h
diff --git a/pdf/file_writer.h b/pdf/file_writer.h
new file mode 100644
index 0000000000000000000000000000000000000000..a67285cae626e84f358a5404c6c94737fca12e1c
--- /dev/null
+++ b/pdf/file_writer.h
@@ -0,0 +1,50 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
Lei Zhang 2014/06/05 07:23:54 nit: no (c) in new code.
raymes 2014/06/06 01:57:14 Done.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PDF_FILE_WRITER_H_
+#define PDF_FILE_WRITER_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+#include "ppapi/cpp/file_io.h"
+#include "ppapi/cpp/file_ref.h"
+#include "ppapi/cpp/file_system.h"
+#include "ppapi/cpp/instance_handle.h"
+#include "ppapi/utility/completion_callback_factory.h"
+
+namespace chrome_pdf {
+
+class FileWriter {
+ public:
+ FileWriter(const pp::InstanceHandle& instance,
+ const std::string& filename,
+ const char* bytes,
+ size_t length);
+
+ void GetFile(pp::CompletionCallbackWithOutput<pp::FileRef> callback);
+
+ private:
+ void OnFileSystemOpen(int32_t result);
+ void OnWriteComplete(int32_t result);
+ void OnFlushComplete(int32_t result);
+
+ pp::InstanceHandle instance_;
+ std::string filename_;
+ const char* bytes_;
+ size_t length_;
+ scoped_ptr<pp::CompletionCallbackWithOutput<pp::FileRef> > callback_;
+
+ bool succeeded_;
+ size_t offset_;
+ pp::FileRef file_ref_;
+ pp::FileSystem fs_;
+ pp::FileIO io_;
+ pp::CompletionCallbackFactory<FileWriter> callback_factory_;
+};
+
+} // namespace chrome_pdf
+
+#endif // PDF_FILE_WRITER_H_

Powered by Google App Engine
This is Rietveld 408576698