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

Side by Side Diff: chrome/service/cloud_print/cloud_print_connector.cc

Issue 10386063: Move URLFetcherDelegate to net/ and split URLFetcher between net/ and content/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync to head, fix win component build Created 8 years, 7 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) 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 #include "chrome/service/cloud_print/cloud_print_connector.h" 5 #include "chrome/service/cloud_print/cloud_print_connector.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/md5.h" 9 #include "base/md5.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 void CloudPrintConnector::OnPrinterDeleted(const std::string& printer_id) { 122 void CloudPrintConnector::OnPrinterDeleted(const std::string& printer_id) {
123 AddPendingDeleteTask(printer_id); 123 AddPendingDeleteTask(printer_id);
124 } 124 }
125 125
126 void CloudPrintConnector::OnAuthError() { 126 void CloudPrintConnector::OnAuthError() {
127 client_->OnAuthFailed(); 127 client_->OnAuthFailed();
128 } 128 }
129 129
130 // CloudPrintURLFetcher::Delegate implementation. 130 // CloudPrintURLFetcher::Delegate implementation.
131 CloudPrintURLFetcher::ResponseAction CloudPrintConnector::HandleRawData( 131 CloudPrintURLFetcher::ResponseAction CloudPrintConnector::HandleRawData(
132 const content::URLFetcher* source, 132 const net::URLFetcher* source,
133 const GURL& url, 133 const GURL& url,
134 const std::string& data) { 134 const std::string& data) {
135 // If this notification came as a result of user message call, stop it. 135 // If this notification came as a result of user message call, stop it.
136 // Otherwise proceed continue processing. 136 // Otherwise proceed continue processing.
137 if (user_message_request_.get() && 137 if (user_message_request_.get() &&
138 user_message_request_->IsSameRequest(source)) 138 user_message_request_->IsSameRequest(source))
139 return CloudPrintURLFetcher::STOP_PROCESSING; 139 return CloudPrintURLFetcher::STOP_PROCESSING;
140 return CloudPrintURLFetcher::CONTINUE_PROCESSING; 140 return CloudPrintURLFetcher::CONTINUE_PROCESSING;
141 } 141 }
142 142
143 CloudPrintURLFetcher::ResponseAction CloudPrintConnector::HandleJSONData( 143 CloudPrintURLFetcher::ResponseAction CloudPrintConnector::HandleJSONData(
144 const content::URLFetcher* source, 144 const net::URLFetcher* source,
145 const GURL& url, 145 const GURL& url,
146 DictionaryValue* json_data, 146 DictionaryValue* json_data,
147 bool succeeded) { 147 bool succeeded) {
148 if (!IsRunning()) // Orphant response. Connector has been stopped already. 148 if (!IsRunning()) // Orphant response. Connector has been stopped already.
149 return CloudPrintURLFetcher::STOP_PROCESSING; 149 return CloudPrintURLFetcher::STOP_PROCESSING;
150 150
151 DCHECK(next_response_handler_); 151 DCHECK(next_response_handler_);
152 return (this->*next_response_handler_)(source, url, json_data, succeeded); 152 return (this->*next_response_handler_)(source, url, json_data, succeeded);
153 } 153 }
154 154
155 CloudPrintURLFetcher::ResponseAction CloudPrintConnector::OnRequestAuthError() { 155 CloudPrintURLFetcher::ResponseAction CloudPrintConnector::OnRequestAuthError() {
156 OnAuthError(); 156 OnAuthError();
157 return CloudPrintURLFetcher::STOP_PROCESSING; 157 return CloudPrintURLFetcher::STOP_PROCESSING;
158 } 158 }
159 159
160 std::string CloudPrintConnector::GetAuthHeader() { 160 std::string CloudPrintConnector::GetAuthHeader() {
161 return CloudPrintHelpers::GetCloudPrintAuthHeaderFromStore(); 161 return CloudPrintHelpers::GetCloudPrintAuthHeaderFromStore();
162 } 162 }
163 163
164 CloudPrintConnector::~CloudPrintConnector() {} 164 CloudPrintConnector::~CloudPrintConnector() {}
165 165
166 CloudPrintURLFetcher::ResponseAction 166 CloudPrintURLFetcher::ResponseAction
167 CloudPrintConnector::HandlePrinterListResponse( 167 CloudPrintConnector::HandlePrinterListResponse(
168 const content::URLFetcher* source, 168 const net::URLFetcher* source,
169 const GURL& url, 169 const GURL& url,
170 DictionaryValue* json_data, 170 DictionaryValue* json_data,
171 bool succeeded) { 171 bool succeeded) {
172 DCHECK(succeeded); 172 DCHECK(succeeded);
173 if (!succeeded) 173 if (!succeeded)
174 return CloudPrintURLFetcher::RETRY_REQUEST; 174 return CloudPrintURLFetcher::RETRY_REQUEST;
175 175
176 // Now we need to get the list of printers from the print system 176 // Now we need to get the list of printers from the print system
177 // and split printers into 3 categories: 177 // and split printers into 3 categories:
178 // - existing and registered printers 178 // - existing and registered printers
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 // and let user choose which printers to register. 225 // and let user choose which printers to register.
226 // Here is a good place to notify client about available printers. 226 // Here is a good place to notify client about available printers.
227 RegisterPrinters(local_printers); 227 RegisterPrinters(local_printers);
228 } 228 }
229 ContinuePendingTaskProcessing(); // Continue processing background tasks. 229 ContinuePendingTaskProcessing(); // Continue processing background tasks.
230 return CloudPrintURLFetcher::STOP_PROCESSING; 230 return CloudPrintURLFetcher::STOP_PROCESSING;
231 } 231 }
232 232
233 CloudPrintURLFetcher::ResponseAction 233 CloudPrintURLFetcher::ResponseAction
234 CloudPrintConnector::HandlePrinterDeleteResponse( 234 CloudPrintConnector::HandlePrinterDeleteResponse(
235 const content::URLFetcher* source, 235 const net::URLFetcher* source,
236 const GURL& url, 236 const GURL& url,
237 DictionaryValue* json_data, 237 DictionaryValue* json_data,
238 bool succeeded) { 238 bool succeeded) {
239 VLOG(1) << "CP_CONNECTOR: Handler printer delete response, succeeded:" 239 VLOG(1) << "CP_CONNECTOR: Handler printer delete response, succeeded:"
240 << succeeded << " url: " << url; 240 << succeeded << " url: " << url;
241 ContinuePendingTaskProcessing(); // Continue processing background tasks. 241 ContinuePendingTaskProcessing(); // Continue processing background tasks.
242 return CloudPrintURLFetcher::STOP_PROCESSING; 242 return CloudPrintURLFetcher::STOP_PROCESSING;
243 } 243 }
244 244
245 CloudPrintURLFetcher::ResponseAction 245 CloudPrintURLFetcher::ResponseAction
246 CloudPrintConnector::HandleRegisterPrinterResponse( 246 CloudPrintConnector::HandleRegisterPrinterResponse(
247 const content::URLFetcher* source, 247 const net::URLFetcher* source,
248 const GURL& url, 248 const GURL& url,
249 DictionaryValue* json_data, 249 DictionaryValue* json_data,
250 bool succeeded) { 250 bool succeeded) {
251 VLOG(1) << "CP_CONNECTOR: Handler printer register response, succeeded:" 251 VLOG(1) << "CP_CONNECTOR: Handler printer register response, succeeded:"
252 << succeeded << " url: " << url; 252 << succeeded << " url: " << url;
253 if (succeeded) { 253 if (succeeded) {
254 ListValue* printer_list = NULL; 254 ListValue* printer_list = NULL;
255 // There should be a "printers" value in the JSON 255 // There should be a "printers" value in the JSON
256 if (json_data->GetList(cloud_print::kPrinterListValue, &printer_list)) { 256 if (json_data->GetList(cloud_print::kPrinterListValue, &printer_list)) {
257 DictionaryValue* printer_data = NULL; 257 DictionaryValue* printer_data = NULL;
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 mime_type, 546 mime_type,
547 post_data, 547 post_data,
548 &CloudPrintConnector::HandleRegisterPrinterResponse); 548 &CloudPrintConnector::HandleRegisterPrinterResponse);
549 } 549 }
550 550
551 bool CloudPrintConnector::IsSamePrinter(const std::string& name1, 551 bool CloudPrintConnector::IsSamePrinter(const std::string& name1,
552 const std::string& name2) const { 552 const std::string& name2) const {
553 return (0 == base::strcasecmp(name1.c_str(), name2.c_str())); 553 return (0 == base::strcasecmp(name1.c_str(), name2.c_str()));
554 } 554 }
555 555
OLDNEW
« no previous file with comments | « chrome/service/cloud_print/cloud_print_connector.h ('k') | chrome/service/cloud_print/cloud_print_url_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698