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

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') | pdf/file_writer.h » ('J')
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..744c663fc0c1dd4806d18386c0dcca93151ed3b3 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) {
Lei Zhang 2014/06/05 07:23:54 nit: indentation
raymes 2014/06/06 01:57:13 Done.
+ if (!IsDocumentComplete() || chunk_stream_.data().size() == 0) {
Lei Zhang 2014/06/05 07:23:54 nit: size() == 0 -> empty()
raymes 2014/06/06 01:57:13 Done.
+ callback.Run(PP_ERROR_FAILED);
+ return;
+ }
+
+ if (!file_writer_) {
+ file_writer_.reset(new FileWriter(
+ client_->GetPluginInstance(),
+ "pdf",
Lei Zhang 2014/06/05 07:23:54 Probably ok for now, but shouldn't the caller norm
raymes 2014/06/06 01:57:13 This will just be a temporary filename. The downlo
+ reinterpret_cast<const char*>(&chunk_stream_.data()[0]),
Lei Zhang 2014/06/05 07:23:54 Maybe just have FileWriter hold a const std::strin
+ 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') | pdf/file_writer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698