OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
13 #include "base/thread.h" | 13 #include "base/thread.h" |
14 #include "chrome/service/cloud_print/print_system.h" | 14 #include "chrome/service/cloud_print/print_system.h" |
15 #include "chrome/common/net/url_fetcher.h" | 15 #include "chrome/common/net/url_fetcher.h" |
16 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
17 #include "net/url_request/url_request_status.h" | 17 #include "net/url_request/url_request_status.h" |
18 | 18 |
19 // Periodically monitors the status of a local print job and updates the | 19 // Periodically monitors the status of a local print job and updates the |
20 // cloud print server accordingly. When the job has been completed this | 20 // cloud print server accordingly. When the job has been completed this |
21 // object releases the reference to itself which should cause it to | 21 // object releases the reference to itself which should cause it to |
22 // self-destruct. | 22 // self-destruct. |
23 class JobStatusUpdater : public base::RefCountedThreadSafe<JobStatusUpdater>, | 23 class JobStatusUpdater : public base::RefCountedThreadSafe<JobStatusUpdater>, |
24 public URLFetcher::Delegate { | 24 public URLFetcher::Delegate { |
25 public: | 25 public: |
26 class Delegate { | 26 class Delegate { |
27 public: | 27 public: |
28 virtual bool OnJobCompleted(JobStatusUpdater* updater) = 0; | 28 virtual bool OnJobCompleted(JobStatusUpdater* updater) = 0; |
| 29 |
| 30 protected: |
| 31 virtual ~Delegate() {} |
29 }; | 32 }; |
30 | 33 |
31 JobStatusUpdater(const std::string& printer_name, | 34 JobStatusUpdater(const std::string& printer_name, |
32 const std::string& job_id, | 35 const std::string& job_id, |
33 cloud_print::PlatformJobId& local_job_id, | 36 cloud_print::PlatformJobId& local_job_id, |
34 const std::string& auth_token, | 37 const std::string& auth_token, |
35 const GURL& cloud_print_server_url, | 38 const GURL& cloud_print_server_url, |
36 cloud_print::PrintSystem* print_system, | 39 cloud_print::PrintSystem* print_system, |
37 Delegate* delegate); | 40 Delegate* delegate); |
38 // Checks the status of the local print job and sends an update. | 41 // Checks the status of the local print job and sends an update. |
(...skipping 22 matching lines...) Expand all Loading... |
61 }; | 64 }; |
62 | 65 |
63 // This typedef is to workaround the issue with certain versions of | 66 // This typedef is to workaround the issue with certain versions of |
64 // Visual Studio where it gets confused between multiple Delegate | 67 // Visual Studio where it gets confused between multiple Delegate |
65 // classes and gives a C2500 error. (I saw this error on the try bots - | 68 // classes and gives a C2500 error. (I saw this error on the try bots - |
66 // the workaround was not needed for my machine). | 69 // the workaround was not needed for my machine). |
67 typedef JobStatusUpdater::Delegate JobStatusUpdaterDelegate; | 70 typedef JobStatusUpdater::Delegate JobStatusUpdaterDelegate; |
68 | 71 |
69 #endif // CHROME_SERVICE_CLOUD_PRINT_JOB_STATUS_UPDATER_H_ | 72 #endif // CHROME_SERVICE_CLOUD_PRINT_JOB_STATUS_UPDATER_H_ |
70 | 73 |
OLD | NEW |