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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 | 14 |
15 namespace chrome_pdf { | 15 namespace chrome_pdf { |
16 | 16 |
17 template <class StringType> | 17 template <class StringType> |
18 PDFiumAPIStringBufferAdapter<StringType>::PDFiumAPIStringBufferAdapter( | 18 PDFiumAPIStringBufferAdapter<StringType>::PDFiumAPIStringBufferAdapter( |
19 StringType* str, | 19 StringType* str, |
20 size_t expected_size, | 20 size_t expected_size, |
21 bool check_expected_size) | 21 bool check_expected_size) |
22 : str_(str), | 22 : str_(str), |
23 data_(base::WriteInto(str, expected_size + 1)), | 23 data_(base::WriteInto(str, expected_size + 1)), |
24 expected_size_(expected_size), | 24 expected_size_(expected_size), |
25 check_expected_size_(check_expected_size), | 25 check_expected_size_(check_expected_size), |
26 is_closed_(false) { | 26 is_closed_(false) {} |
27 } | |
28 | 27 |
29 template <class StringType> | 28 template <class StringType> |
30 PDFiumAPIStringBufferAdapter<StringType>::~PDFiumAPIStringBufferAdapter() { | 29 PDFiumAPIStringBufferAdapter<StringType>::~PDFiumAPIStringBufferAdapter() { |
31 DCHECK(is_closed_); | 30 DCHECK(is_closed_); |
32 } | 31 } |
33 | 32 |
34 template <class StringType> | 33 template <class StringType> |
35 void* PDFiumAPIStringBufferAdapter<StringType>::GetData() { | 34 void* PDFiumAPIStringBufferAdapter<StringType>::GetData() { |
36 DCHECK(!is_closed_); | 35 DCHECK(!is_closed_); |
37 return data_; | 36 return data_; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 DCHECK(actual_size % sizeof(typename StringType::value_type) == 0); | 78 DCHECK(actual_size % sizeof(typename StringType::value_type) == 0); |
80 adapter_.Close(actual_size / sizeof(typename StringType::value_type)); | 79 adapter_.Close(actual_size / sizeof(typename StringType::value_type)); |
81 } | 80 } |
82 | 81 |
83 // explicit instantiations | 82 // explicit instantiations |
84 template class PDFiumAPIStringBufferAdapter<std::string>; | 83 template class PDFiumAPIStringBufferAdapter<std::string>; |
85 template class PDFiumAPIStringBufferAdapter<base::string16>; | 84 template class PDFiumAPIStringBufferAdapter<base::string16>; |
86 template class PDFiumAPIStringBufferSizeInBytesAdapter<base::string16>; | 85 template class PDFiumAPIStringBufferSizeInBytesAdapter<base::string16>; |
87 | 86 |
88 } // namespace chrome_pdf | 87 } // namespace chrome_pdf |
OLD | NEW |