Chromium Code Reviews| 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_; |