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

Side by Side Diff: chrome/service/service_utility_process_host.cc

Issue 1752233002: Convert Pass()→std::move() on Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 9 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
« no previous file with comments | « chrome/service/cloud_print/cdd_conversion_win.cc ('k') | chrome/utility/printing_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/service/service_utility_process_host.h" 5 #include "chrome/service/service_utility_process_host.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <queue> 9 #include <queue>
10 #include <utility>
10 11
11 #include "base/bind.h" 12 #include "base/bind.h"
12 #include "base/command_line.h" 13 #include "base/command_line.h"
13 #include "base/files/file.h" 14 #include "base/files/file.h"
14 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
15 #include "base/files/file_util.h" 16 #include "base/files/file_util.h"
16 #include "base/files/scoped_temp_dir.h" 17 #include "base/files/scoped_temp_dir.h"
17 #include "base/logging.h" 18 #include "base/logging.h"
18 #include "base/macros.h" 19 #include "base/macros.h"
19 #include "base/metrics/histogram.h" 20 #include "base/metrics/histogram.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 public: 88 public:
88 explicit PdfToEmfState(ServiceUtilityProcessHost* host) 89 explicit PdfToEmfState(ServiceUtilityProcessHost* host)
89 : host_(host), page_count_(0), current_page_(0), pages_in_progress_(0) {} 90 : host_(host), page_count_(0), current_page_(0), pages_in_progress_(0) {}
90 ~PdfToEmfState() { Stop(); } 91 ~PdfToEmfState() { Stop(); }
91 92
92 bool Start(base::File pdf_file, 93 bool Start(base::File pdf_file,
93 const printing::PdfRenderSettings& conversion_settings) { 94 const printing::PdfRenderSettings& conversion_settings) {
94 if (!temp_dir_.CreateUniqueTempDir()) 95 if (!temp_dir_.CreateUniqueTempDir())
95 return false; 96 return false;
96 return host_->Send(new ChromeUtilityMsg_RenderPDFPagesToMetafiles( 97 return host_->Send(new ChromeUtilityMsg_RenderPDFPagesToMetafiles(
97 IPC::TakeFileHandleForProcess(pdf_file.Pass(), host_->handle()), 98 IPC::TakeFileHandleForProcess(std::move(pdf_file), host_->handle()),
98 conversion_settings)); 99 conversion_settings));
99 } 100 }
100 101
101 void GetMorePages() { 102 void GetMorePages() {
102 const int kMaxNumberOfTempFilesPerDocument = 3; 103 const int kMaxNumberOfTempFilesPerDocument = 3;
103 while (pages_in_progress_ < kMaxNumberOfTempFilesPerDocument && 104 while (pages_in_progress_ < kMaxNumberOfTempFilesPerDocument &&
104 current_page_ < page_count_) { 105 current_page_ < page_count_) {
105 ++pages_in_progress_; 106 ++pages_in_progress_;
106 emf_files_.push(CreateTempFile()); 107 emf_files_.push(CreateTempFile());
107 host_->Send(new ChromeUtilityMsg_RenderPDFPagesToMetafiles_GetPage( 108 host_->Send(new ChromeUtilityMsg_RenderPDFPagesToMetafiles_GetPage(
(...skipping 11 matching lines...) Expand all
119 if (pages_in_progress_ || current_page_ < page_count_) 120 if (pages_in_progress_ || current_page_ < page_count_)
120 return false; 121 return false;
121 Stop(); 122 Stop();
122 return true; 123 return true;
123 } 124 }
124 125
125 base::File TakeNextFile() { 126 base::File TakeNextFile() {
126 DCHECK(!emf_files_.empty()); 127 DCHECK(!emf_files_.empty());
127 base::File file; 128 base::File file;
128 if (!emf_files_.empty()) 129 if (!emf_files_.empty())
129 file = emf_files_.front().Pass(); 130 file = std::move(emf_files_.front());
130 emf_files_.pop(); 131 emf_files_.pop();
131 return file.Pass(); 132 return file;
132 } 133 }
133 134
134 void set_page_count(int page_count) { page_count_ = page_count; } 135 void set_page_count(int page_count) { page_count_ = page_count; }
135 bool has_page_count() { return page_count_ > 0; } 136 bool has_page_count() { return page_count_ > 0; }
136 137
137 private: 138 private:
138 void Stop() { 139 void Stop() {
139 host_->Send(new ChromeUtilityMsg_RenderPDFPagesToMetafiles_Stop()); 140 host_->Send(new ChromeUtilityMsg_RenderPDFPagesToMetafiles_Stop());
140 } 141 }
141 142
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 ReportUmaEvent(SERVICE_UTILITY_METAFILE_REQUEST); 181 ReportUmaEvent(SERVICE_UTILITY_METAFILE_REQUEST);
181 start_time_ = base::Time::Now(); 182 start_time_ = base::Time::Now();
182 base::File pdf_file(pdf_path, base::File::FLAG_OPEN | base::File::FLAG_READ); 183 base::File pdf_file(pdf_path, base::File::FLAG_OPEN | base::File::FLAG_READ);
183 if (!pdf_file.IsValid() || !StartProcess(false)) 184 if (!pdf_file.IsValid() || !StartProcess(false))
184 return false; 185 return false;
185 186
186 DCHECK(!waiting_for_reply_); 187 DCHECK(!waiting_for_reply_);
187 waiting_for_reply_ = true; 188 waiting_for_reply_ = true;
188 189
189 pdf_to_emf_state_.reset(new PdfToEmfState(this)); 190 pdf_to_emf_state_.reset(new PdfToEmfState(this));
190 return pdf_to_emf_state_->Start(pdf_file.Pass(), render_settings); 191 return pdf_to_emf_state_->Start(std::move(pdf_file), render_settings);
191 } 192 }
192 193
193 bool ServiceUtilityProcessHost::StartGetPrinterCapsAndDefaults( 194 bool ServiceUtilityProcessHost::StartGetPrinterCapsAndDefaults(
194 const std::string& printer_name) { 195 const std::string& printer_name) {
195 ReportUmaEvent(SERVICE_UTILITY_CAPS_REQUEST); 196 ReportUmaEvent(SERVICE_UTILITY_CAPS_REQUEST);
196 start_time_ = base::Time::Now(); 197 start_time_ = base::Time::Now();
197 if (!StartProcess(true)) 198 if (!StartProcess(true))
198 return false; 199 return false;
199 DCHECK(!waiting_for_reply_); 200 DCHECK(!waiting_for_reply_);
200 waiting_for_reply_ = true; 201 waiting_for_reply_ = true;
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 return false; 430 return false;
430 } 431 }
431 printing::Emf emf; 432 printing::Emf emf;
432 if (!emf.InitFromData(data.data(), data.size())) { 433 if (!emf.InitFromData(data.data(), data.size())) {
433 OnRenderPDFPagesToMetafileDone(false); 434 OnRenderPDFPagesToMetafileDone(false);
434 return false; 435 return false;
435 } 436 }
436 OnRenderPDFPagesToMetafilePageDone(scale_factor, emf); 437 OnRenderPDFPagesToMetafilePageDone(scale_factor, emf);
437 return true; 438 return true;
438 } 439 }
OLDNEW
« no previous file with comments | « chrome/service/cloud_print/cdd_conversion_win.cc ('k') | chrome/utility/printing_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698