OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/local_discovery/pwg_raster_converter.h" | 5 #include "chrome/browser/local_discovery/pwg_raster_converter.h" |
6 | 6 |
7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
8 #include "base/cancelable_callback.h" | 8 #include "base/cancelable_callback.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 69 |
70 void FileHandlers::Init(base::RefCountedMemory* data) { | 70 void FileHandlers::Init(base::RefCountedMemory* data) { |
71 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 71 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
72 | 72 |
73 if (!temp_dir_.CreateUniqueTempDir()) { | 73 if (!temp_dir_.CreateUniqueTempDir()) { |
74 return; | 74 return; |
75 } | 75 } |
76 | 76 |
77 if (static_cast<int>(data->size()) != | 77 if (static_cast<int>(data->size()) != |
78 file_util::WriteFile(GetPdfPath(), | 78 file_util::WriteFile(GetPdfPath(), |
79 reinterpret_cast<const char*>(data->front()), | 79 data->front_as<char>(), |
80 data->size())) { | 80 data->size())) { |
81 return; | 81 return; |
82 } | 82 } |
83 | 83 |
84 // Reopen in read only mode. | 84 // Reopen in read only mode. |
85 pdf_file_ = base::CreatePlatformFile(GetPdfPath(), base::PLATFORM_FILE_OPEN | | 85 pdf_file_ = base::CreatePlatformFile(GetPdfPath(), base::PLATFORM_FILE_OPEN | |
86 base::PLATFORM_FILE_READ, | 86 base::PLATFORM_FILE_READ, |
87 NULL, NULL); | 87 NULL, NULL); |
88 pwg_file_ = base::CreatePlatformFile(GetPwgPath(), | 88 pwg_file_ = base::CreatePlatformFile(GetPwgPath(), |
89 base::PLATFORM_FILE_CREATE_ALWAYS | | 89 base::PLATFORM_FILE_CREATE_ALWAYS | |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 } | 280 } |
281 | 281 |
282 } // namespace | 282 } // namespace |
283 | 283 |
284 // static | 284 // static |
285 scoped_ptr<PWGRasterConverter> PWGRasterConverter::CreateDefault() { | 285 scoped_ptr<PWGRasterConverter> PWGRasterConverter::CreateDefault() { |
286 return scoped_ptr<PWGRasterConverter>(new PWGRasterConverterImpl()); | 286 return scoped_ptr<PWGRasterConverter>(new PWGRasterConverterImpl()); |
287 } | 287 } |
288 | 288 |
289 } // namespace local_discovery | 289 } // namespace local_discovery |
OLD | NEW |