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

Unified Diff: pdf/document_loader.cc

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
« no previous file with comments | « pdf/document_loader.h ('k') | pdf/file_writer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/document_loader.cc
diff --git a/pdf/document_loader.cc b/pdf/document_loader.cc
index ba5a3afd0baaf9c6b258845e812d2003941996cf..9dbe03b5663e59a311d2ca3789a60a57b99db5d7 100644
--- a/pdf/document_loader.cc
+++ b/pdf/document_loader.cc
@@ -8,6 +8,7 @@
#include "base/strings/string_util.h"
#include "net/http/http_util.h"
#include "ppapi/c/pp_errors.h"
+#include "ppapi/cpp/dev/buffer_dev.h"
#include "ppapi/cpp/url_loader.h"
#include "ppapi/cpp/url_request_info.h"
#include "ppapi/cpp/url_response_info.h"
@@ -127,6 +128,24 @@ bool DocumentLoader::IsDocumentComplete() const {
return IsDataAvailable(0, document_size_);
}
+void DocumentLoader::GetCompleteDocument(
+ pp::CompletionCallbackWithOutput<pp::FileRef> callback) {
+ if (!IsDocumentComplete() || chunk_stream_.data().empty()) {
+ callback.Run(PP_ERROR_FAILED);
+ return;
+ }
+
+ if (!file_writer_) {
+ file_writer_.reset(new FileWriter(
+ client_->GetPluginInstance(),
+ "pdf",
+ reinterpret_cast<const char*>(&chunk_stream_.data()[0]),
+ chunk_stream_.data().size()));
+ }
+
+ file_writer_->GetFile(callback);
+}
+
uint32 DocumentLoader::GetAvailableData() const {
if (document_size_ == 0) { // If document size is unknown.
return current_pos_;
« no previous file with comments | « pdf/document_loader.h ('k') | pdf/file_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698