OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_JOB_STATUS_UPDATER_H_ | 5 #ifndef CHROME_SERVICE_CLOUD_PRINT_JOB_STATUS_UPDATER_H_ |
6 #define CHROME_SERVICE_CLOUD_PRINT_JOB_STATUS_UPDATER_H_ | 6 #define CHROME_SERVICE_CLOUD_PRINT_JOB_STATUS_UPDATER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 protected: | 31 protected: |
32 virtual ~Delegate() {} | 32 virtual ~Delegate() {} |
33 }; | 33 }; |
34 | 34 |
35 JobStatusUpdater(const std::string& printer_name, | 35 JobStatusUpdater(const std::string& printer_name, |
36 const std::string& job_id, | 36 const std::string& job_id, |
37 cloud_print::PlatformJobId& local_job_id, | 37 cloud_print::PlatformJobId& local_job_id, |
38 const GURL& cloud_print_server_url, | 38 const GURL& cloud_print_server_url, |
39 cloud_print::PrintSystem* print_system, | 39 cloud_print::PrintSystem* print_system, |
40 Delegate* delegate); | 40 Delegate* delegate); |
41 virtual ~JobStatusUpdater(); | |
42 | 41 |
43 // Checks the status of the local print job and sends an update. | 42 // Checks the status of the local print job and sends an update. |
44 void UpdateStatus(); | 43 void UpdateStatus(); |
45 void Stop(); | 44 void Stop(); |
46 | 45 |
47 // CloudPrintURLFetcher::Delegate implementation. | 46 // CloudPrintURLFetcher::Delegate implementation. |
48 virtual CloudPrintURLFetcher::ResponseAction HandleJSONData( | 47 virtual CloudPrintURLFetcher::ResponseAction HandleJSONData( |
49 const content::URLFetcher* source, | 48 const content::URLFetcher* source, |
50 const GURL& url, | 49 const GURL& url, |
51 base::DictionaryValue* json_data, | 50 base::DictionaryValue* json_data, |
52 bool succeeded) OVERRIDE; | 51 bool succeeded) OVERRIDE; |
53 virtual CloudPrintURLFetcher::ResponseAction OnRequestAuthError() OVERRIDE; | 52 virtual CloudPrintURLFetcher::ResponseAction OnRequestAuthError() OVERRIDE; |
54 virtual std::string GetAuthHeader() OVERRIDE; | 53 virtual std::string GetAuthHeader() OVERRIDE; |
55 | 54 |
56 private: | 55 private: |
| 56 friend class base::RefCountedThreadSafe<JobStatusUpdater>; |
| 57 virtual ~JobStatusUpdater(); |
| 58 |
57 std::string printer_name_; | 59 std::string printer_name_; |
58 std::string job_id_; | 60 std::string job_id_; |
59 cloud_print::PlatformJobId local_job_id_; | 61 cloud_print::PlatformJobId local_job_id_; |
60 cloud_print::PrintJobDetails last_job_details_; | 62 cloud_print::PrintJobDetails last_job_details_; |
61 scoped_refptr<CloudPrintURLFetcher> request_; | 63 scoped_refptr<CloudPrintURLFetcher> request_; |
62 GURL cloud_print_server_url_; | 64 GURL cloud_print_server_url_; |
63 scoped_refptr<cloud_print::PrintSystem> print_system_; | 65 scoped_refptr<cloud_print::PrintSystem> print_system_; |
64 Delegate* delegate_; | 66 Delegate* delegate_; |
65 // A flag that is set to true in Stop() and will ensure the next scheduled | 67 // A flag that is set to true in Stop() and will ensure the next scheduled |
66 // task will do nothing. | 68 // task will do nothing. |
67 bool stopped_; | 69 bool stopped_; |
68 DISALLOW_COPY_AND_ASSIGN(JobStatusUpdater); | 70 DISALLOW_COPY_AND_ASSIGN(JobStatusUpdater); |
69 }; | 71 }; |
70 | 72 |
71 // This typedef is to workaround the issue with certain versions of | 73 // This typedef is to workaround the issue with certain versions of |
72 // Visual Studio where it gets confused between multiple Delegate | 74 // Visual Studio where it gets confused between multiple Delegate |
73 // classes and gives a C2500 error. (I saw this error on the try bots - | 75 // classes and gives a C2500 error. (I saw this error on the try bots - |
74 // the workaround was not needed for my machine). | 76 // the workaround was not needed for my machine). |
75 typedef JobStatusUpdater::Delegate JobStatusUpdaterDelegate; | 77 typedef JobStatusUpdater::Delegate JobStatusUpdaterDelegate; |
76 | 78 |
77 #endif // CHROME_SERVICE_CLOUD_PRINT_JOB_STATUS_UPDATER_H_ | 79 #endif // CHROME_SERVICE_CLOUD_PRINT_JOB_STATUS_UPDATER_H_ |
OLD | NEW |