| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #ifndef CHROME_SERVICE_CLOUD_PRINT_PRINTER_JOB_QUEUE_HANDLER_H_ | 5 #ifndef CHROME_SERVICE_CLOUD_PRINT_PRINTER_JOB_QUEUE_HANDLER_H_ |
| 6 #define CHROME_SERVICE_CLOUD_PRINT_PRINTER_JOB_QUEUE_HANDLER_H_ | 6 #define CHROME_SERVICE_CLOUD_PRINT_PRINTER_JOB_QUEUE_HANDLER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> |
| 9 #include <string> | 10 #include <string> |
| 10 #include <utility> | 11 #include <utility> |
| 11 #include <vector> | 12 #include <vector> |
| 12 | 13 |
| 13 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/scoped_ptr.h" | |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "chrome/common/cloud_print/cloud_print_constants.h" | 19 #include "chrome/common/cloud_print/cloud_print_constants.h" |
| 20 | 20 |
| 21 namespace base { | 21 namespace base { |
| 22 class DictionaryValue; | 22 class DictionaryValue; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace cloud_print { | 25 namespace cloud_print { |
| 26 | 26 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 // print will have a time_remaining_ of 0. | 69 // print will have a time_remaining_ of 0. |
| 70 void GetJobsFromQueue(const base::DictionaryValue* json_data, | 70 void GetJobsFromQueue(const base::DictionaryValue* json_data, |
| 71 std::vector<JobDetails>* jobs); | 71 std::vector<JobDetails>* jobs); |
| 72 | 72 |
| 73 // Marks a job fetch as failed. Returns "true" if the job will be retried. | 73 // Marks a job fetch as failed. Returns "true" if the job will be retried. |
| 74 bool JobFetchFailed(const std::string& job_id); | 74 bool JobFetchFailed(const std::string& job_id); |
| 75 | 75 |
| 76 void JobDone(const std::string& job_id); | 76 void JobDone(const std::string& job_id); |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 scoped_ptr<TimeProvider> time_provider_; | 79 std::unique_ptr<TimeProvider> time_provider_; |
| 80 | 80 |
| 81 struct FailedJobMetadata { | 81 struct FailedJobMetadata { |
| 82 int retries_; | 82 int retries_; |
| 83 base::Time last_retry_; | 83 base::Time last_retry_; |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 typedef std::map<std::string, FailedJobMetadata> FailedJobMap; | 86 typedef std::map<std::string, FailedJobMetadata> FailedJobMap; |
| 87 typedef std::pair<std::string, FailedJobMetadata> FailedJobPair; | 87 typedef std::pair<std::string, FailedJobMetadata> FailedJobPair; |
| 88 | 88 |
| 89 FailedJobMap failed_job_map_; | 89 FailedJobMap failed_job_map_; |
| 90 | 90 |
| 91 void ConstructJobDetailsFromJson(const base::DictionaryValue* json_data, | 91 void ConstructJobDetailsFromJson(const base::DictionaryValue* json_data, |
| 92 JobDetails* details_obj); | 92 JobDetails* details_obj); |
| 93 base::TimeDelta ComputeBackoffTime(const std::string& job_id); | 93 base::TimeDelta ComputeBackoffTime(const std::string& job_id); |
| 94 | 94 |
| 95 DISALLOW_COPY_AND_ASSIGN(PrinterJobQueueHandler); | 95 DISALLOW_COPY_AND_ASSIGN(PrinterJobQueueHandler); |
| 96 }; | 96 }; |
| 97 | 97 |
| 98 } // namespace cloud_print | 98 } // namespace cloud_print |
| 99 | 99 |
| 100 #endif // CHROME_SERVICE_CLOUD_PRINT_PRINTER_JOB_QUEUE_HANDLER_H_ | 100 #endif // CHROME_SERVICE_CLOUD_PRINT_PRINTER_JOB_QUEUE_HANDLER_H_ |
| 101 | 101 |
| 102 | 102 |
| OLD | NEW |