| 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
|
|
|