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

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

Issue 8387011: Chrome proxy refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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) 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_PRINTER_JOB_HANDLER_H_ 5 #ifndef CHROME_SERVICE_CLOUD_PRINT_PRINTER_JOB_HANDLER_H_
6 #define CHROME_SERVICE_CLOUD_PRINT_PRINTER_JOB_HANDLER_H_ 6 #define CHROME_SERVICE_CLOUD_PRINT_PRINTER_JOB_HANDLER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <list> 9 #include <list>
10 #include <string> 10 #include <string>
(...skipping 15 matching lines...) Expand all
26 // imlements a state machine that transitions from Start to various states. The 26 // imlements a state machine that transitions from Start to various states. The
27 // various states are shown in the below diagram. 27 // various states are shown in the below diagram.
28 // the status on the server. 28 // the status on the server.
29 29
30 // Start --> No pending tasks --> Done 30 // Start --> No pending tasks --> Done
31 // | 31 // |
32 // | 32 // |
33 // | Have Pending tasks 33 // | Have Pending tasks
34 // | 34 // |
35 // | 35 // |
36 // <----Delete Pending -- | ---Update Pending-----> 36 // | ---Update Pending----->
37 // | | | 37 // | |
38 // | | | 38 // | |
39 // | | | 39 // | |
40 // Delete Printer from server | Update Printer info on server 40 // | Update Printer info on server
41 // Shutdown | Go to Stop 41 // | Go to Stop
42 // | 42 // |
43 // | Job Available 43 // | Job Available
44 // | 44 // |
45 // | 45 // |
46 // Fetch Next Job Metadata 46 // Fetch Next Job Metadata
47 // Fetch Print Ticket 47 // Fetch Print Ticket
48 // Fetch Print Data 48 // Fetch Print Data
49 // Spool Print Job 49 // Spool Print Job
50 // Create Job StatusUpdater for job 50 // Create Job StatusUpdater for job
51 // Mark job as "in progress" on server 51 // Mark job as "in progress" on server
(...skipping 29 matching lines...) Expand all
81 std::string job_title_; 81 std::string job_title_;
82 std::string print_ticket_; 82 std::string print_ticket_;
83 FilePath print_data_file_path_; 83 FilePath print_data_file_path_;
84 std::string print_data_mime_type_; 84 std::string print_data_mime_type_;
85 std::vector<std::string> tags_; 85 std::vector<std::string> tags_;
86 }; 86 };
87 87
88 public: 88 public:
89 class Delegate { 89 class Delegate {
90 public: 90 public:
91 virtual void OnPrinterJobHandlerShutdown( 91 // Notify delegate about authentication error.
92 PrinterJobHandler* job_handler, const std::string& printer_id) = 0;
93 virtual void OnAuthError() = 0; 92 virtual void OnAuthError() = 0;
94 // Called when the PrinterJobHandler cannot find the printer locally. The 93 // Notify delegate that printer has been deleted.
95 // delegate returns |delete_from_server| to true if the printer should be 94 virtual void OnPrinterDeleted(const std::string& printer_name) = 0;
96 // deleted from the server,false otherwise.
97 virtual void OnPrinterNotFound(const std::string& printer_name,
98 bool* delete_from_server) = 0;
99 95
100 protected: 96 protected:
101 virtual ~Delegate() {} 97 virtual ~Delegate() {}
102 }; 98 };
103 99
104 struct PrinterInfoFromCloud { 100 struct PrinterInfoFromCloud {
105 std::string printer_id; 101 std::string printer_id;
106 std::string caps_hash; 102 std::string caps_hash;
107 std::string tags_hash; 103 std::string tags_hash;
108 }; 104 };
109 105
110 // Begin public interface 106 // Begin public interface
111 PrinterJobHandler(const printing::PrinterBasicInfo& printer_info, 107 PrinterJobHandler(const printing::PrinterBasicInfo& printer_info,
112 const PrinterInfoFromCloud& printer_info_from_server, 108 const PrinterInfoFromCloud& printer_info_from_server,
113 const GURL& cloud_print_server_url, 109 const GURL& cloud_print_server_url,
114 cloud_print::PrintSystem* print_system, 110 cloud_print::PrintSystem* print_system,
115 Delegate* delegate); 111 Delegate* delegate);
116 virtual ~PrinterJobHandler(); 112 virtual ~PrinterJobHandler();
117 bool Initialize(); 113 bool Initialize();
114 std::string GetPrinterName() const;
118 // Requests a job check. |reason| is the reason for fetching the job. Used 115 // Requests a job check. |reason| is the reason for fetching the job. Used
119 // for logging and diagnostc purposes. 116 // for logging and diagnostc purposes.
120 void CheckForJobs(const std::string& reason); 117 void CheckForJobs(const std::string& reason);
121 // Shutdown everything (the process is exiting). 118 // Shutdown everything (the process is exiting).
122 void Shutdown(); 119 void Shutdown();
123 base::TimeTicks last_job_fetch_time() const { return last_job_fetch_time_; } 120 base::TimeTicks last_job_fetch_time() const { return last_job_fetch_time_; }
124 // End public interface 121 // End public interface
125 122
126 // Begin Delegate implementations 123 // Begin Delegate implementations
127 124
128 // CloudPrintURLFetcher::Delegate implementation. 125 // CloudPrintURLFetcher::Delegate implementation.
129 virtual CloudPrintURLFetcher::ResponseAction HandleRawResponse( 126 virtual CloudPrintURLFetcher::ResponseAction HandleRawResponse(
130 const content::URLFetcher* source, 127 const content::URLFetcher* source,
131 const GURL& url, 128 const GURL& url,
132 const net::URLRequestStatus& status, 129 const net::URLRequestStatus& status,
133 int response_code, 130 int response_code,
134 const net::ResponseCookies& cookies, 131 const net::ResponseCookies& cookies,
135 const std::string& data); 132 const std::string& data);
136 virtual CloudPrintURLFetcher::ResponseAction HandleRawData( 133 virtual CloudPrintURLFetcher::ResponseAction HandleRawData(
137 const content::URLFetcher* source, 134 const content::URLFetcher* source,
138 const GURL& url, 135 const GURL& url,
139 const std::string& data); 136 const std::string& data);
140 virtual CloudPrintURLFetcher::ResponseAction HandleJSONData( 137 virtual CloudPrintURLFetcher::ResponseAction HandleJSONData(
141 const content::URLFetcher* source, 138 const content::URLFetcher* source,
142 const GURL& url, 139 const GURL& url,
143 base::DictionaryValue* json_data, 140 base::DictionaryValue* json_data,
144 bool succeeded); 141 bool succeeded);
145 virtual void OnRequestGiveUp(); 142 virtual void OnRequestGiveUp();
146 virtual void OnRequestAuthError(); 143 virtual CloudPrintURLFetcher::ResponseAction OnRequestAuthError();
144 virtual std::string GetAuthHeader();
147 145
148 // JobStatusUpdater::Delegate implementation 146 // JobStatusUpdater::Delegate implementation
149 virtual bool OnJobCompleted(JobStatusUpdater* updater); 147 virtual bool OnJobCompleted(JobStatusUpdater* updater);
150 virtual void OnAuthError(); 148 virtual void OnAuthError();
151 149
152 // cloud_print::PrinterWatcherDelegate implementation 150 // cloud_print::PrinterWatcherDelegate implementation
153 virtual void OnPrinterDeleted(); 151 virtual void OnPrinterDeleted();
154 virtual void OnPrinterChanged(); 152 virtual void OnPrinterChanged();
155 virtual void OnJobChanged(); 153 virtual void OnJobChanged();
156 154
(...skipping 16 matching lines...) Expand all
173 (PrinterJobHandler::*DataHandler)(const content::URLFetcher* source, 171 (PrinterJobHandler::*DataHandler)(const content::URLFetcher* source,
174 const GURL& url, 172 const GURL& url,
175 const std::string& data); 173 const std::string& data);
176 // Begin request handlers for each state in the state machine 174 // Begin request handlers for each state in the state machine
177 CloudPrintURLFetcher::ResponseAction HandlePrinterUpdateResponse( 175 CloudPrintURLFetcher::ResponseAction HandlePrinterUpdateResponse(
178 const content::URLFetcher* source, 176 const content::URLFetcher* source,
179 const GURL& url, 177 const GURL& url,
180 base::DictionaryValue* json_data, 178 base::DictionaryValue* json_data,
181 bool succeeded); 179 bool succeeded);
182 180
183 CloudPrintURLFetcher::ResponseAction HandlePrinterDeleteResponse(
184 const content::URLFetcher* source,
185 const GURL& url,
186 base::DictionaryValue* json_data,
187 bool succeeded);
188
189 CloudPrintURLFetcher::ResponseAction HandleJobMetadataResponse( 181 CloudPrintURLFetcher::ResponseAction HandleJobMetadataResponse(
190 const content::URLFetcher* source, 182 const content::URLFetcher* source,
191 const GURL& url, 183 const GURL& url,
192 base::DictionaryValue* json_data, 184 base::DictionaryValue* json_data,
193 bool succeeded); 185 bool succeeded);
194 186
195 CloudPrintURLFetcher::ResponseAction HandlePrintTicketResponse( 187 CloudPrintURLFetcher::ResponseAction HandlePrintTicketResponse(
196 const content::URLFetcher* source, 188 const content::URLFetcher* source,
197 const GURL& url, 189 const GURL& url,
198 const std::string& data); 190 const std::string& data);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 // There may be pending tasks in the message queue when Shutdown is called. 273 // There may be pending tasks in the message queue when Shutdown is called.
282 // We set this flag so as to do nothing in those tasks. 274 // We set this flag so as to do nothing in those tasks.
283 bool shutting_down_; 275 bool shutting_down_;
284 276
285 // A string indicating the reason we are fetching jobs from the server 277 // A string indicating the reason we are fetching jobs from the server
286 // (used to specify the reason in the fetch URL). 278 // (used to specify the reason in the fetch URL).
287 std::string job_fetch_reason_; 279 std::string job_fetch_reason_;
288 // Flags that specify various pending server updates 280 // Flags that specify various pending server updates
289 bool job_check_pending_; 281 bool job_check_pending_;
290 bool printer_update_pending_; 282 bool printer_update_pending_;
291 bool printer_delete_pending_;
292 283
293 // Some task in the state machine is in progress. 284 // Some task in the state machine is in progress.
294 bool task_in_progress_; 285 bool task_in_progress_;
295 scoped_refptr<cloud_print::PrintSystem::PrinterWatcher> printer_watcher_; 286 scoped_refptr<cloud_print::PrintSystem::PrinterWatcher> printer_watcher_;
296 typedef std::list< scoped_refptr<JobStatusUpdater> > JobStatusUpdaterList; 287 typedef std::list< scoped_refptr<JobStatusUpdater> > JobStatusUpdaterList;
297 JobStatusUpdaterList job_status_updater_list_; 288 JobStatusUpdaterList job_status_updater_list_;
298 289
299 base::TimeTicks last_job_fetch_time_; 290 base::TimeTicks last_job_fetch_time_;
300 291
301 DISALLOW_COPY_AND_ASSIGN(PrinterJobHandler); 292 DISALLOW_COPY_AND_ASSIGN(PrinterJobHandler);
302 }; 293 };
303 294
304 // This typedef is to workaround the issue with certain versions of 295 // This typedef is to workaround the issue with certain versions of
305 // Visual Studio where it gets confused between multiple Delegate 296 // Visual Studio where it gets confused between multiple Delegate
306 // classes and gives a C2500 error. (I saw this error on the try bots - 297 // classes and gives a C2500 error. (I saw this error on the try bots -
307 // the workaround was not needed for my machine). 298 // the workaround was not needed for my machine).
308 typedef PrinterJobHandler::Delegate PrinterJobHandlerDelegate; 299 typedef PrinterJobHandler::Delegate PrinterJobHandlerDelegate;
309 300
310 #endif // CHROME_SERVICE_CLOUD_PRINT_PRINTER_JOB_HANDLER_H_ 301 #endif // CHROME_SERVICE_CLOUD_PRINT_PRINTER_JOB_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/service/cloud_print/job_status_updater.cc ('k') | chrome/service/cloud_print/printer_job_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698