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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 }; | 68 }; |
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 base::WriteFile(GetPdfPath(), data->front_as<char>(), data->size())) { |
79 data->front_as<char>(), | |
80 data->size())) { | |
81 return; | 79 return; |
82 } | 80 } |
83 | 81 |
84 // Reopen in read only mode. | 82 // Reopen in read only mode. |
85 pdf_file_ = base::CreatePlatformFile(GetPdfPath(), base::PLATFORM_FILE_OPEN | | 83 pdf_file_ = base::CreatePlatformFile(GetPdfPath(), base::PLATFORM_FILE_OPEN | |
86 base::PLATFORM_FILE_READ, | 84 base::PLATFORM_FILE_READ, |
87 NULL, NULL); | 85 NULL, NULL); |
88 pwg_file_ = base::CreatePlatformFile(GetPwgPath(), | 86 pwg_file_ = base::CreatePlatformFile(GetPwgPath(), |
89 base::PLATFORM_FILE_CREATE_ALWAYS | | 87 base::PLATFORM_FILE_CREATE_ALWAYS | |
90 base::PLATFORM_FILE_APPEND, NULL, NULL); | 88 base::PLATFORM_FILE_APPEND, NULL, NULL); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 } | 278 } |
281 | 279 |
282 } // namespace | 280 } // namespace |
283 | 281 |
284 // static | 282 // static |
285 scoped_ptr<PWGRasterConverter> PWGRasterConverter::CreateDefault() { | 283 scoped_ptr<PWGRasterConverter> PWGRasterConverter::CreateDefault() { |
286 return scoped_ptr<PWGRasterConverter>(new PWGRasterConverterImpl()); | 284 return scoped_ptr<PWGRasterConverter>(new PWGRasterConverterImpl()); |
287 } | 285 } |
288 | 286 |
289 } // namespace local_discovery | 287 } // namespace local_discovery |
OLD | NEW |