Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: chrome/browser/printing/pdf_to_emf_converter.cc

Issue 1109043003: Apply automated fixits for Chrome clang plugin to chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/printing/pdf_to_emf_converter.h" 5 #include "chrome/browser/printing/pdf_to_emf_converter.h"
6 6
7 #include <queue> 7 #include <queue>
8 8
9 #include "base/files/file.h" 9 #include "base/files/file.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 ScopedTempFile; 54 ScopedTempFile;
55 55
56 // Wrapper for Emf to keep only file handle in memory, and load actual data only 56 // Wrapper for Emf to keep only file handle in memory, and load actual data only
57 // on playback. Emf::InitFromFile() can play metafile directly from disk, but it 57 // on playback. Emf::InitFromFile() can play metafile directly from disk, but it
58 // can't open file handles. We need file handles to reliably delete temporary 58 // can't open file handles. We need file handles to reliably delete temporary
59 // files, and to efficiently interact with utility process. 59 // files, and to efficiently interact with utility process.
60 class LazyEmf : public MetafilePlayer { 60 class LazyEmf : public MetafilePlayer {
61 public: 61 public:
62 LazyEmf(const scoped_refptr<RefCountedTempDir>& temp_dir, ScopedTempFile file) 62 LazyEmf(const scoped_refptr<RefCountedTempDir>& temp_dir, ScopedTempFile file)
63 : temp_dir_(temp_dir), file_(file.Pass()) {} 63 : temp_dir_(temp_dir), file_(file.Pass()) {}
64 virtual ~LazyEmf() { Close(); } 64 ~LazyEmf() override { Close(); }
65 65
66 bool SafePlayback(HDC hdc) const override; 66 bool SafePlayback(HDC hdc) const override;
67 bool SaveTo(base::File* file) const override; 67 bool SaveTo(base::File* file) const override;
68 68
69 private: 69 private:
70 void Close() const; 70 void Close() const;
71 bool LoadEmf(Emf* emf) const; 71 bool LoadEmf(Emf* emf) const;
72 72
73 mutable scoped_refptr<RefCountedTempDir> temp_dir_; 73 mutable scoped_refptr<RefCountedTempDir> temp_dir_;
74 mutable ScopedTempFile file_; // Mutable because of consts in base class. 74 mutable ScopedTempFile file_; // Mutable because of consts in base class.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 135 }
136 ScopedTempFile emf() { return emf_.Pass(); } 136 ScopedTempFile emf() { return emf_.Pass(); }
137 void set_emf(ScopedTempFile emf) { emf_ = emf.Pass(); } 137 void set_emf(ScopedTempFile emf) { emf_ = emf.Pass(); }
138 138
139 private: 139 private:
140 int page_number_; 140 int page_number_;
141 PdfToEmfConverter::GetPageCallback callback_; 141 PdfToEmfConverter::GetPageCallback callback_;
142 ScopedTempFile emf_; 142 ScopedTempFile emf_;
143 }; 143 };
144 144
145 virtual ~PdfToEmfUtilityProcessHostClient(); 145 ~PdfToEmfUtilityProcessHostClient() override;
146 146
147 bool Send(IPC::Message* msg); 147 bool Send(IPC::Message* msg);
148 148
149 // Message handlers. 149 // Message handlers.
150 void OnProcessStarted(); 150 void OnProcessStarted();
151 void OnPageCount(int page_count); 151 void OnPageCount(int page_count);
152 void OnPageDone(bool success, float scale_factor); 152 void OnPageDone(bool success, float scale_factor);
153 153
154 void OnFailed(); 154 void OnFailed();
155 void OnTempPdfReady(ScopedTempFile pdf); 155 void OnTempPdfReady(ScopedTempFile pdf);
(...skipping 18 matching lines...) Expand all
174 typedef std::queue<GetPageCallbackData> GetPageCallbacks; 174 typedef std::queue<GetPageCallbackData> GetPageCallbacks;
175 GetPageCallbacks get_page_callbacks_; 175 GetPageCallbacks get_page_callbacks_;
176 176
177 DISALLOW_COPY_AND_ASSIGN(PdfToEmfUtilityProcessHostClient); 177 DISALLOW_COPY_AND_ASSIGN(PdfToEmfUtilityProcessHostClient);
178 }; 178 };
179 179
180 class PdfToEmfConverterImpl : public PdfToEmfConverter { 180 class PdfToEmfConverterImpl : public PdfToEmfConverter {
181 public: 181 public:
182 PdfToEmfConverterImpl(); 182 PdfToEmfConverterImpl();
183 183
184 virtual ~PdfToEmfConverterImpl(); 184 ~PdfToEmfConverterImpl() override;
185 185
186 void Start(const scoped_refptr<base::RefCountedMemory>& data, 186 void Start(const scoped_refptr<base::RefCountedMemory>& data,
187 const PdfRenderSettings& conversion_settings, 187 const PdfRenderSettings& conversion_settings,
188 const StartCallback& start_callback) override; 188 const StartCallback& start_callback) override;
189 189
190 void GetPage(int page_number, 190 void GetPage(int page_number,
191 const GetPageCallback& get_page_callback) override; 191 const GetPageCallback& get_page_callback) override;
192 192
193 // Helps to cancel callbacks if this object is destroyed. 193 // Helps to cancel callbacks if this object is destroyed.
194 void RunCallback(const base::Closure& callback); 194 void RunCallback(const base::Closure& callback);
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 488
489 PdfToEmfConverter::~PdfToEmfConverter() { 489 PdfToEmfConverter::~PdfToEmfConverter() {
490 } 490 }
491 491
492 // static 492 // static
493 scoped_ptr<PdfToEmfConverter> PdfToEmfConverter::CreateDefault() { 493 scoped_ptr<PdfToEmfConverter> PdfToEmfConverter::CreateDefault() {
494 return scoped_ptr<PdfToEmfConverter>(new PdfToEmfConverterImpl()); 494 return scoped_ptr<PdfToEmfConverter>(new PdfToEmfConverterImpl());
495 } 495 }
496 496
497 } // namespace printing 497 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698