| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "pdf/pdfium/pdfium_api_string_buffer_adapter.h" | 5 #include "pdf/pdfium/pdfium_api_string_buffer_adapter.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/numerics/safe_math.h" | 10 #include "base/numerics/safe_math.h" |
| 11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 | 13 |
| 14 namespace chrome_pdf { | 14 namespace chrome_pdf { |
| 15 | 15 |
| 16 template <class StringType> | 16 template <class StringType> |
| 17 PDFiumAPIStringBufferAdapter<StringType>::PDFiumAPIStringBufferAdapter( | 17 PDFiumAPIStringBufferAdapter<StringType>::PDFiumAPIStringBufferAdapter( |
| 18 StringType* str, | 18 StringType* str, |
| 19 size_t expected_size, | 19 size_t expected_size, |
| 20 bool check_expected_size) | 20 bool check_expected_size) |
| 21 : str_(str), | 21 : str_(str), |
| 22 data_(WriteInto(str, expected_size + 1)), | 22 data_(base::WriteInto(str, expected_size + 1)), |
| 23 expected_size_(expected_size), | 23 expected_size_(expected_size), |
| 24 check_expected_size_(check_expected_size), | 24 check_expected_size_(check_expected_size), |
| 25 is_closed_(false) { | 25 is_closed_(false) { |
| 26 } | 26 } |
| 27 | 27 |
| 28 template <class StringType> | 28 template <class StringType> |
| 29 PDFiumAPIStringBufferAdapter<StringType>::~PDFiumAPIStringBufferAdapter() { | 29 PDFiumAPIStringBufferAdapter<StringType>::~PDFiumAPIStringBufferAdapter() { |
| 30 DCHECK(is_closed_); | 30 DCHECK(is_closed_); |
| 31 } | 31 } |
| 32 | 32 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 56 } else { | 56 } else { |
| 57 str_->clear(); | 57 str_->clear(); |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 | 60 |
| 61 // explicit instantiations | 61 // explicit instantiations |
| 62 template class PDFiumAPIStringBufferAdapter<std::string>; | 62 template class PDFiumAPIStringBufferAdapter<std::string>; |
| 63 template class PDFiumAPIStringBufferAdapter<base::string16>; | 63 template class PDFiumAPIStringBufferAdapter<base::string16>; |
| 64 | 64 |
| 65 } // namespace chrome_pdf | 65 } // namespace chrome_pdf |
| OLD | NEW |