OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_CLOUD_PRINT_CONNECTOR_H_ | 5 #ifndef CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_CONNECTOR_H_ |
6 #define CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_CONNECTOR_H_ | 6 #define CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_CONNECTOR_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 #include <map> | 10 #include <map> |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 void CheckForJobs(const std::string& reason, const std::string& printer_id); | 55 void CheckForJobs(const std::string& reason, const std::string& printer_id); |
56 | 56 |
57 // cloud_print::PrintServerWatcherDelegate implementation | 57 // cloud_print::PrintServerWatcherDelegate implementation |
58 virtual void OnPrinterAdded() OVERRIDE; | 58 virtual void OnPrinterAdded() OVERRIDE; |
59 // PrinterJobHandler::Delegate implementation | 59 // PrinterJobHandler::Delegate implementation |
60 virtual void OnPrinterDeleted(const std::string& printer_name) OVERRIDE; | 60 virtual void OnPrinterDeleted(const std::string& printer_name) OVERRIDE; |
61 virtual void OnAuthError() OVERRIDE; | 61 virtual void OnAuthError() OVERRIDE; |
62 | 62 |
63 // CloudPrintURLFetcher::Delegate implementation. | 63 // CloudPrintURLFetcher::Delegate implementation. |
64 virtual CloudPrintURLFetcher::ResponseAction HandleRawData( | 64 virtual CloudPrintURLFetcher::ResponseAction HandleRawData( |
65 const content::URLFetcher* source, | 65 const net::URLFetcher* source, |
66 const GURL& url, | 66 const GURL& url, |
67 const std::string& data) OVERRIDE; | 67 const std::string& data) OVERRIDE; |
68 virtual CloudPrintURLFetcher::ResponseAction HandleJSONData( | 68 virtual CloudPrintURLFetcher::ResponseAction HandleJSONData( |
69 const content::URLFetcher* source, | 69 const net::URLFetcher* source, |
70 const GURL& url, | 70 const GURL& url, |
71 base::DictionaryValue* json_data, | 71 base::DictionaryValue* json_data, |
72 bool succeeded) OVERRIDE; | 72 bool succeeded) OVERRIDE; |
73 virtual CloudPrintURLFetcher::ResponseAction OnRequestAuthError() OVERRIDE; | 73 virtual CloudPrintURLFetcher::ResponseAction OnRequestAuthError() OVERRIDE; |
74 virtual std::string GetAuthHeader() OVERRIDE; | 74 virtual std::string GetAuthHeader() OVERRIDE; |
75 | 75 |
76 private: | 76 private: |
77 friend class base::RefCountedThreadSafe<CloudPrintConnector>; | 77 friend class base::RefCountedThreadSafe<CloudPrintConnector>; |
78 | 78 |
79 // Prototype for a response handler. | 79 // Prototype for a response handler. |
80 typedef CloudPrintURLFetcher::ResponseAction | 80 typedef CloudPrintURLFetcher::ResponseAction |
81 (CloudPrintConnector::*ResponseHandler)( | 81 (CloudPrintConnector::*ResponseHandler)( |
82 const content::URLFetcher* source, | 82 const net::URLFetcher* source, |
83 const GURL& url, | 83 const GURL& url, |
84 DictionaryValue* json_data, | 84 DictionaryValue* json_data, |
85 bool succeeded); | 85 bool succeeded); |
86 | 86 |
87 enum PendingTaskType { | 87 enum PendingTaskType { |
88 PENDING_PRINTERS_NONE, | 88 PENDING_PRINTERS_NONE, |
89 PENDING_PRINTERS_AVAILABLE, | 89 PENDING_PRINTERS_AVAILABLE, |
90 PENDING_PRINTER_REGISTER, | 90 PENDING_PRINTER_REGISTER, |
91 PENDING_PRINTER_DELETE | 91 PENDING_PRINTER_DELETE |
92 }; | 92 }; |
93 | 93 |
94 // TODO(jhawkins): This name conflicts with base::PendingTask. | 94 // TODO(jhawkins): This name conflicts with base::PendingTask. |
95 struct PendingTask { | 95 struct PendingTask { |
96 PendingTaskType type; | 96 PendingTaskType type; |
97 // Optional members, depending on type. | 97 // Optional members, depending on type. |
98 std::string printer_id; // For pending delete. | 98 std::string printer_id; // For pending delete. |
99 printing::PrinterBasicInfo printer_info; // For pending registration. | 99 printing::PrinterBasicInfo printer_info; // For pending registration. |
100 | 100 |
101 PendingTask() : type(PENDING_PRINTERS_NONE) {} | 101 PendingTask() : type(PENDING_PRINTERS_NONE) {} |
102 ~PendingTask() {} | 102 ~PendingTask() {} |
103 }; | 103 }; |
104 | 104 |
105 virtual ~CloudPrintConnector(); | 105 virtual ~CloudPrintConnector(); |
106 | 106 |
107 // Begin response handlers | 107 // Begin response handlers |
108 CloudPrintURLFetcher::ResponseAction HandlePrinterListResponse( | 108 CloudPrintURLFetcher::ResponseAction HandlePrinterListResponse( |
109 const content::URLFetcher* source, | 109 const net::URLFetcher* source, |
110 const GURL& url, | 110 const GURL& url, |
111 DictionaryValue* json_data, | 111 DictionaryValue* json_data, |
112 bool succeeded); | 112 bool succeeded); |
113 | 113 |
114 CloudPrintURLFetcher::ResponseAction HandlePrinterDeleteResponse( | 114 CloudPrintURLFetcher::ResponseAction HandlePrinterDeleteResponse( |
115 const content::URLFetcher* source, | 115 const net::URLFetcher* source, |
116 const GURL& url, | 116 const GURL& url, |
117 DictionaryValue* json_data, | 117 DictionaryValue* json_data, |
118 bool succeeded); | 118 bool succeeded); |
119 | 119 |
120 CloudPrintURLFetcher::ResponseAction HandleRegisterPrinterResponse( | 120 CloudPrintURLFetcher::ResponseAction HandleRegisterPrinterResponse( |
121 const content::URLFetcher* source, | 121 const net::URLFetcher* source, |
122 const GURL& url, | 122 const GURL& url, |
123 DictionaryValue* json_data, | 123 DictionaryValue* json_data, |
124 bool succeeded); | 124 bool succeeded); |
125 // End response handlers | 125 // End response handlers |
126 | 126 |
127 // Helper functions for network requests. | 127 // Helper functions for network requests. |
128 void StartGetRequest(const GURL& url, | 128 void StartGetRequest(const GURL& url, |
129 int max_retries, | 129 int max_retries, |
130 ResponseHandler handler); | 130 ResponseHandler handler); |
131 void StartPostRequest(const GURL& url, | 131 void StartPostRequest(const GURL& url, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 // The CloudPrintURLFetcher instance for the current request. | 184 // The CloudPrintURLFetcher instance for the current request. |
185 scoped_refptr<CloudPrintURLFetcher> request_; | 185 scoped_refptr<CloudPrintURLFetcher> request_; |
186 // The CloudPrintURLFetcher instance for the user message request. | 186 // The CloudPrintURLFetcher instance for the user message request. |
187 scoped_refptr<CloudPrintURLFetcher> user_message_request_; | 187 scoped_refptr<CloudPrintURLFetcher> user_message_request_; |
188 | 188 |
189 DISALLOW_COPY_AND_ASSIGN(CloudPrintConnector); | 189 DISALLOW_COPY_AND_ASSIGN(CloudPrintConnector); |
190 }; | 190 }; |
191 | 191 |
192 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_CONNECTOR_H_ | 192 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_CONNECTOR_H_ |
193 | 193 |
OLD | NEW |