| 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 "cloud_print/gcp20/prototype/print_job_handler.h" | 5 #include "cloud_print/gcp20/prototype/print_job_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 create_time_exploded.month, | 228 create_time_exploded.month, |
| 229 create_time_exploded.day_of_month, | 229 create_time_exploded.day_of_month, |
| 230 create_time_exploded.hour, | 230 create_time_exploded.hour, |
| 231 create_time_exploded.minute, | 231 create_time_exploded.minute, |
| 232 create_time_exploded.second); | 232 create_time_exploded.second); |
| 233 if (!base::CreateTemporaryDirInDir(directory, job_prefix, &directory)) { | 233 if (!base::CreateTemporaryDirInDir(directory, job_prefix, &directory)) { |
| 234 LOG(WARNING) << "Cannot create directory for " << job_prefix; | 234 LOG(WARNING) << "Cannot create directory for " << job_prefix; |
| 235 return false; | 235 return false; |
| 236 } | 236 } |
| 237 | 237 |
| 238 int written = file_util::WriteFile(directory.AppendASCII("ticket.xml"), | 238 int written = base::WriteFile(directory.AppendASCII("ticket.xml"), |
| 239 ticket.data(), | 239 ticket.data(), |
| 240 static_cast<int>(ticket.size())); | 240 static_cast<int>(ticket.size())); |
| 241 if (static_cast<size_t>(written) != ticket.size()) { | 241 if (static_cast<size_t>(written) != ticket.size()) { |
| 242 LOG(WARNING) << "Cannot save ticket."; | 242 LOG(WARNING) << "Cannot save ticket."; |
| 243 return false; | 243 return false; |
| 244 } | 244 } |
| 245 | 245 |
| 246 written = file_util::WriteFile( | 246 written = base::WriteFile( |
| 247 directory.AppendASCII("data." + file_extension), | 247 directory.AppendASCII("data." + file_extension), |
| 248 content.data(), static_cast<int>(content.size())); | 248 content.data(), static_cast<int>(content.size())); |
| 249 if (static_cast<size_t>(written) != content.size()) { | 249 if (static_cast<size_t>(written) != content.size()) { |
| 250 LOG(WARNING) << "Cannot save data."; | 250 LOG(WARNING) << "Cannot save data."; |
| 251 return false; | 251 return false; |
| 252 } | 252 } |
| 253 | 253 |
| 254 VLOG(0) << "Job saved at " << directory.value(); | 254 VLOG(0) << "Job saved at " << directory.value(); |
| 255 return true; | 255 return true; |
| 256 } | 256 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 return expiration - base::Time::Now(); | 299 return expiration - base::Time::Now(); |
| 300 } | 300 } |
| 301 | 301 |
| 302 void PrintJobHandler::ForgetDraft(const std::string& id) { | 302 void PrintJobHandler::ForgetDraft(const std::string& id) { |
| 303 drafts.erase(id); | 303 drafts.erase(id); |
| 304 } | 304 } |
| 305 | 305 |
| 306 void PrintJobHandler::ForgetLocalJob(const std::string& id) { | 306 void PrintJobHandler::ForgetLocalJob(const std::string& id) { |
| 307 jobs.erase(id); | 307 jobs.erase(id); |
| 308 } | 308 } |
| OLD | NEW |