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

Unified Diff: pdf/pdfium/pdfium_api_string_buffer_adapter.cc

Issue 1303103003: PDF: Use PDF metadata for the title instead of the last path element. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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/pdfium/pdfium_api_string_buffer_adapter.h ('k') | pdf/pdfium/pdfium_engine.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/pdfium/pdfium_api_string_buffer_adapter.cc
diff --git a/pdf/pdfium/pdfium_api_string_buffer_adapter.cc b/pdf/pdfium/pdfium_api_string_buffer_adapter.cc
index c5be3021d5b367ca3c5f122b1d97be58b24a9db9..9ac7425f55e4239942e87b60705e591b60f2b4fa 100644
--- a/pdf/pdfium/pdfium_api_string_buffer_adapter.cc
+++ b/pdf/pdfium/pdfium_api_string_buffer_adapter.cc
@@ -7,7 +7,6 @@
#include <string>
#include "base/logging.h"
-#include "base/numerics/safe_math.h"
#include "base/strings/string16.h"
#include "base/strings/string_util.h"
@@ -37,12 +36,6 @@ void* PDFiumAPIStringBufferAdapter<StringType>::GetData() {
}
template <class StringType>
-void PDFiumAPIStringBufferAdapter<StringType>::Close(int actual_size) {
- base::CheckedNumeric<size_t> unsigned_size = actual_size;
- Close(unsigned_size.ValueOrDie());
-}
-
-template <class StringType>
void PDFiumAPIStringBufferAdapter<StringType>::Close(size_t actual_size) {
DCHECK(!is_closed_);
is_closed_ = true;
@@ -58,8 +51,36 @@ void PDFiumAPIStringBufferAdapter<StringType>::Close(size_t actual_size) {
}
}
+template <class StringType>
+PDFiumAPIStringBufferSizeInBytesAdapter<StringType>::
+ PDFiumAPIStringBufferSizeInBytesAdapter(StringType* str,
+ size_t expected_size,
+ bool check_expected_size)
+ : adapter_(str,
+ expected_size / sizeof(typename StringType::value_type),
+ check_expected_size) {
+ DCHECK(expected_size % sizeof(typename StringType::value_type) == 0);
+}
+
+template <class StringType>
+PDFiumAPIStringBufferSizeInBytesAdapter<
+ StringType>::~PDFiumAPIStringBufferSizeInBytesAdapter() = default;
+
+template <class StringType>
+void* PDFiumAPIStringBufferSizeInBytesAdapter<StringType>::GetData() {
+ return adapter_.GetData();
+}
+
+template <class StringType>
+void PDFiumAPIStringBufferSizeInBytesAdapter<StringType>::Close(
+ size_t actual_size) {
+ DCHECK(actual_size % sizeof(typename StringType::value_type) == 0);
+ adapter_.Close(actual_size / sizeof(typename StringType::value_type));
+}
+
// explicit instantiations
template class PDFiumAPIStringBufferAdapter<std::string>;
template class PDFiumAPIStringBufferAdapter<base::string16>;
+template class PDFiumAPIStringBufferSizeInBytesAdapter<base::string16>;
} // namespace chrome_pdf
« no previous file with comments | « pdf/pdfium/pdfium_api_string_buffer_adapter.h ('k') | pdf/pdfium/pdfium_engine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698