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

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

Issue 10836278: Add additional logging. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/service/cloud_print/cloud_print_consts.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 } 104 }
105 } 105 }
106 106
107 // Check for jobs for specific printer 107 // Check for jobs for specific printer
108 void CloudPrintConnector::CheckForJobs(const std::string& reason, 108 void CloudPrintConnector::CheckForJobs(const std::string& reason,
109 const std::string& printer_id) { 109 const std::string& printer_id) {
110 if (!IsRunning()) 110 if (!IsRunning())
111 return; 111 return;
112 if (!printer_id.empty()) { 112 if (!printer_id.empty()) {
113 JobHandlerMap::iterator index = job_handler_map_.find(printer_id); 113 JobHandlerMap::iterator index = job_handler_map_.find(printer_id);
114 if (index != job_handler_map_.end()) 114 if (index != job_handler_map_.end()) {
115 index->second->CheckForJobs(reason); 115 index->second->CheckForJobs(reason);
116 } else {
117 std::string status_message = l10n_util::GetStringUTF8(
118 IDS_CLOUD_PRINT_ZOMBIE_PRINTER);
119 LOG(ERROR) << "CP_CONNECTOR: " << status_message <<
120 " Printer_id: " << printer_id;
121 ReportUserMessage(kZombiePrinterMessageId, status_message);
122 }
116 } else { 123 } else {
117 for (JobHandlerMap::iterator index = job_handler_map_.begin(); 124 for (JobHandlerMap::iterator index = job_handler_map_.begin();
118 index != job_handler_map_.end(); index++) { 125 index != job_handler_map_.end(); index++) {
119 index->second->CheckForJobs(reason); 126 index->second->CheckForJobs(reason);
120 } 127 }
121 } 128 }
122 } 129 }
123 130
124 void CloudPrintConnector::OnPrinterAdded() { 131 void CloudPrintConnector::OnPrinterAdded() {
125 AddPendingAvailableTask(); 132 AddPendingAvailableTask();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // and split printers into 3 categories: 190 // and split printers into 3 categories:
184 // - existing and registered printers 191 // - existing and registered printers
185 // - new printers 192 // - new printers
186 // - deleted printers 193 // - deleted printers
187 194
188 // Get list of the printers from the print system. 195 // Get list of the printers from the print system.
189 printing::PrinterList local_printers; 196 printing::PrinterList local_printers;
190 cloud_print::PrintSystem::PrintSystemResult result = 197 cloud_print::PrintSystem::PrintSystemResult result =
191 print_system_->EnumeratePrinters(&local_printers); 198 print_system_->EnumeratePrinters(&local_printers);
192 bool full_list = result.succeeded(); 199 bool full_list = result.succeeded();
193 if (!result.succeeded()) { 200 if (!full_list) {
194 std::string message = result.message(); 201 std::string message = result.message();
195 if (message.empty()) 202 if (message.empty())
196 message = l10n_util::GetStringFUTF8(IDS_CLOUD_PRINT_ENUM_FAILED, 203 message = l10n_util::GetStringFUTF8(IDS_CLOUD_PRINT_ENUM_FAILED,
197 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT)); 204 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT));
198 // There was a failure enumerating printers. Send a message to the server. 205 // There was a failure enumerating printers. Send a message to the server.
199 ReportUserMessage(kEnumPrintersFailedMessageId, message); 206 ReportUserMessage(kEnumPrintersFailedMessageId, message);
200 } 207 }
201 208
202 // Go through the list of the cloud printers and init print job handlers. 209 // Go through the list of the cloud printers and init print job handlers.
203 ListValue* printer_list = NULL; 210 ListValue* printer_list = NULL;
204 // There may be no "printers" value in the JSON 211 // There may be no "printers" value in the JSON
205 if (json_data->GetList(cloud_print::kPrinterListValue, &printer_list) 212 if (json_data->GetList(cloud_print::kPrinterListValue, &printer_list)
206 && printer_list) { 213 && printer_list) {
207 for (size_t index = 0; index < printer_list->GetSize(); index++) { 214 for (size_t index = 0; index < printer_list->GetSize(); index++) {
208 DictionaryValue* printer_data = NULL; 215 DictionaryValue* printer_data = NULL;
209 if (printer_list->GetDictionary(index, &printer_data)) { 216 if (printer_list->GetDictionary(index, &printer_data)) {
210 std::string printer_name; 217 std::string printer_name;
211 printer_data->GetString(kNameValue, &printer_name); 218 printer_data->GetString(kNameValue, &printer_name);
212 if (RemovePrinterFromList(printer_name, &local_printers)) { 219 if (RemovePrinterFromList(printer_name, &local_printers)) {
213 InitJobHandlerForPrinter(printer_data); 220 InitJobHandlerForPrinter(printer_data);
214 } else { 221 } else {
215 // Cloud printer is not found on the local system. 222 // Cloud printer is not found on the local system.
223 std::string printer_id;
224 printer_data->GetString(kIdValue, &printer_id);
216 if (full_list) { // Delete only if we get the full list of printer. 225 if (full_list) { // Delete only if we get the full list of printer.
217 std::string printer_id;
218 printer_data->GetString(kIdValue, &printer_id);
219 AddPendingDeleteTask(printer_id); 226 AddPendingDeleteTask(printer_id);
227 } else {
228 LOG(ERROR) << "CP_CONNECTOR: Printer: " << printer_name <<
229 " id: " << printer_id <<
230 " not found in print system and full printer list was" <<
231 " not received. Printer will not be able to process" <<
232 " jobs.";
220 } 233 }
221 } 234 }
222 } else { 235 } else {
223 NOTREACHED(); 236 NOTREACHED();
224 } 237 }
225 } 238 }
226 } 239 }
227 240
228 request_ = NULL; 241 request_ = NULL;
229 if (!local_printers.empty()) { 242 if (!local_printers.empty()) {
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 mime_type, 567 mime_type,
555 post_data, 568 post_data,
556 &CloudPrintConnector::HandleRegisterPrinterResponse); 569 &CloudPrintConnector::HandleRegisterPrinterResponse);
557 } 570 }
558 571
559 bool CloudPrintConnector::IsSamePrinter(const std::string& name1, 572 bool CloudPrintConnector::IsSamePrinter(const std::string& name1,
560 const std::string& name2) const { 573 const std::string& name2) const {
561 return (0 == base::strcasecmp(name1.c_str(), name2.c_str())); 574 return (0 == base::strcasecmp(name1.c_str(), name2.c_str()));
562 } 575 }
563 576
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/service/cloud_print/cloud_print_consts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698