Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Side by Side Diff: chrome/service/cloud_print/job_status_updater.h

Issue 2519002: Redesign cloud printing subsystem layer. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/thread.h" 12 #include "base/thread.h"
13 #include "chrome/service/cloud_print/printer_info.h" 13 #include "chrome/service/cloud_print/print_system.h"
14 #include "chrome/common/net/url_fetcher.h" 14 #include "chrome/common/net/url_fetcher.h"
15 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
16 #include "net/url_request/url_request_status.h" 16 #include "net/url_request/url_request_status.h"
17 17
18 // Periodically monitors the status of a local print job and updates the 18 // Periodically monitors the status of a local print job and updates the
19 // cloud print server accordingly. When the job has been completed this 19 // cloud print server accordingly. When the job has been completed this
20 // object releases the reference to itself which should cause it to 20 // object releases the reference to itself which should cause it to
21 // self-destruct. 21 // self-destruct.
22 class JobStatusUpdater : public base::RefCountedThreadSafe<JobStatusUpdater>, 22 class JobStatusUpdater : public base::RefCountedThreadSafe<JobStatusUpdater>,
23 public URLFetcher::Delegate { 23 public URLFetcher::Delegate {
24 public: 24 public:
25 class Delegate { 25 class Delegate {
26 public: 26 public:
27 virtual bool OnJobCompleted(JobStatusUpdater* updater) = 0; 27 virtual bool OnJobCompleted(JobStatusUpdater* updater) = 0;
28 }; 28 };
29 29
30 JobStatusUpdater(const std::string& printer_name, 30 JobStatusUpdater(const std::string& printer_name,
31 const std::string& job_id, 31 const std::string& job_id,
32 cloud_print::PlatformJobId& local_job_id, 32 cloud_print::PlatformJobId& local_job_id,
33 const std::string& auth_token, 33 const std::string& auth_token,
34 const GURL& cloud_print_server_url, 34 const GURL& cloud_print_server_url,
35 cloud_print::PrintSystem* print_system,
35 Delegate* delegate); 36 Delegate* delegate);
36 // Checks the status of the local print job and sends an update. 37 // Checks the status of the local print job and sends an update.
37 void UpdateStatus(); 38 void UpdateStatus();
38 void Stop(); 39 void Stop();
39 // URLFetcher::Delegate implementation. 40 // URLFetcher::Delegate implementation.
40 virtual void OnURLFetchComplete(const URLFetcher* source, const GURL& url, 41 virtual void OnURLFetchComplete(const URLFetcher* source, const GURL& url,
41 const URLRequestStatus& status, 42 const URLRequestStatus& status,
42 int response_code, 43 int response_code,
43 const ResponseCookies& cookies, 44 const ResponseCookies& cookies,
44 const std::string& data); 45 const std::string& data);
45 private: 46 private:
46 std::string printer_name_; 47 std::string printer_name_;
47 std::string job_id_; 48 std::string job_id_;
48 cloud_print::PlatformJobId local_job_id_; 49 cloud_print::PlatformJobId local_job_id_;
49 cloud_print::PrintJobDetails last_job_details_; 50 cloud_print::PrintJobDetails last_job_details_;
50 scoped_ptr<URLFetcher> request_; 51 scoped_ptr<URLFetcher> request_;
51 std::string auth_token_; 52 std::string auth_token_;
52 GURL cloud_print_server_url_; 53 GURL cloud_print_server_url_;
54 scoped_refptr<cloud_print::PrintSystem> print_system_;
53 Delegate* delegate_; 55 Delegate* delegate_;
54 // A flag that is set to true in Stop() and will ensure the next scheduled 56 // A flag that is set to true in Stop() and will ensure the next scheduled
55 // task will do nothing. 57 // task will do nothing.
56 bool stopped_; 58 bool stopped_;
57 DISALLOW_COPY_AND_ASSIGN(JobStatusUpdater); 59 DISALLOW_COPY_AND_ASSIGN(JobStatusUpdater);
58 }; 60 };
59 61
60 // This typedef is to workaround the issue with certain versions of 62 // This typedef is to workaround the issue with certain versions of
61 // Visual Studio where it gets confused between multiple Delegate 63 // Visual Studio where it gets confused between multiple Delegate
62 // classes and gives a C2500 error. (I saw this error on the try bots - 64 // classes and gives a C2500 error. (I saw this error on the try bots -
63 // the workaround was not needed for my machine). 65 // the workaround was not needed for my machine).
64 typedef JobStatusUpdater::Delegate JobStatusUpdaterDelegate; 66 typedef JobStatusUpdater::Delegate JobStatusUpdaterDelegate;
65 67
66 #endif // CHROME_SERVICE_CLOUD_PRINT_JOB_STATUS_UPDATER_H_ 68 #endif // CHROME_SERVICE_CLOUD_PRINT_JOB_STATUS_UPDATER_H_
67 69
OLDNEW
« no previous file with comments | « chrome/service/cloud_print/cloud_print_proxy_backend.cc ('k') | chrome/service/cloud_print/job_status_updater.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698