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/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 std::string* job_id_out, | 78 std::string* job_id_out, |
79 // TODO(maksymb): Use base::TimeDelta for timeout values | 79 // TODO(maksymb): Use base::TimeDelta for timeout values |
80 int* expires_in_out, | 80 int* expires_in_out, |
81 // TODO(maksymb): Use base::TimeDelta for timeout values | 81 // TODO(maksymb): Use base::TimeDelta for timeout values |
82 int* error_timeout_out, | 82 int* error_timeout_out, |
83 std::string* error_description) { | 83 std::string* error_description) { |
84 if (!ValidateTicket(ticket)) | 84 if (!ValidateTicket(ticket)) |
85 return LocalPrintJob::CREATE_INVALID_TICKET; | 85 return LocalPrintJob::CREATE_INVALID_TICKET; |
86 | 86 |
87 // Let's simulate at least some errors just for testing. | 87 // Let's simulate at least some errors just for testing. |
88 if (CommandLine::ForCurrentProcess()->HasSwitch( | 88 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
89 switches::kSimulatePrintingErrors)) { | 89 switches::kSimulatePrintingErrors)) { |
90 if (base::RandDouble() <= kPaperJamProbability) { | 90 if (base::RandDouble() <= kPaperJamProbability) { |
91 *error_description = "Paper jam, try again"; | 91 *error_description = "Paper jam, try again"; |
92 return LocalPrintJob::CREATE_PRINTER_ERROR; | 92 return LocalPrintJob::CREATE_PRINTER_ERROR; |
93 } | 93 } |
94 | 94 |
95 if (drafts.size() > kMaxDrafts) { // Another simulation of error: business | 95 if (drafts.size() > kMaxDrafts) { // Another simulation of error: business |
96 *error_timeout_out = kTooManyDraftsTimeout; | 96 *error_timeout_out = kTooManyDraftsTimeout; |
97 return LocalPrintJob::CREATE_PRINTER_BUSY; | 97 return LocalPrintJob::CREATE_PRINTER_BUSY; |
98 } | 98 } |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 return expiration - base::Time::Now(); | 301 return expiration - base::Time::Now(); |
302 } | 302 } |
303 | 303 |
304 void PrintJobHandler::ForgetDraft(const std::string& id) { | 304 void PrintJobHandler::ForgetDraft(const std::string& id) { |
305 drafts.erase(id); | 305 drafts.erase(id); |
306 } | 306 } |
307 | 307 |
308 void PrintJobHandler::ForgetLocalJob(const std::string& id) { | 308 void PrintJobHandler::ForgetLocalJob(const std::string& id) { |
309 jobs.erase(id); | 309 jobs.erase(id); |
310 } | 310 } |
OLD | NEW |