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

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

Issue 10808086: Standardize log message style for cloudprint service and display printer id (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 8 years, 5 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 18 matching lines...) Expand all
29 cloud_print_server_url_(cloud_print_server_url), 29 cloud_print_server_url_(cloud_print_server_url),
30 next_response_handler_(NULL) { 30 next_response_handler_(NULL) {
31 if (print_system_settings) { 31 if (print_system_settings) {
32 // It is possible to have no print settings specified. 32 // It is possible to have no print settings specified.
33 print_system_settings_.reset(print_system_settings->DeepCopy()); 33 print_system_settings_.reset(print_system_settings->DeepCopy());
34 } 34 }
35 } 35 }
36 36
37 bool CloudPrintConnector::Start() { 37 bool CloudPrintConnector::Start() {
38 DCHECK(!print_system_.get()); 38 DCHECK(!print_system_.get());
39 VLOG(1) << "CP_CONNECTOR: Starting connector, id: " << proxy_id_; 39 VLOG(1) << "CP_CONNECTOR: Starting connector"
40 << ", proxy id: " << proxy_id_;
40 41
41 pending_tasks_.clear(); 42 pending_tasks_.clear();
42 43
43 print_system_ = 44 print_system_ =
44 cloud_print::PrintSystem::CreateInstance(print_system_settings_.get()); 45 cloud_print::PrintSystem::CreateInstance(print_system_settings_.get());
45 if (!print_system_.get()) { 46 if (!print_system_.get()) {
46 NOTREACHED(); 47 NOTREACHED();
47 return false; // No print system available, fail initalization. 48 return false; // No print system available, fail initalization.
48 } 49 }
49 cloud_print::PrintSystem::PrintSystemResult result = print_system_->Init(); 50 cloud_print::PrintSystem::PrintSystemResult result = print_system_->Init();
50 if (!result.succeeded()) { 51 if (!result.succeeded()) {
51 // We could not initialize the print system. We need to notify the server. 52 // We could not initialize the print system. We need to notify the server.
52 ReportUserMessage(kPrintSystemFailedMessageId, result.message()); 53 ReportUserMessage(kPrintSystemFailedMessageId, result.message());
53 print_system_.release(); 54 print_system_.release();
54 return false; 55 return false;
55 } 56 }
56 57
57 // Start watching for updates from the print system. 58 // Start watching for updates from the print system.
58 print_server_watcher_ = print_system_->CreatePrintServerWatcher(); 59 print_server_watcher_ = print_system_->CreatePrintServerWatcher();
59 print_server_watcher_->StartWatching(this); 60 print_server_watcher_->StartWatching(this);
60 61
61 // Get list of registered printers. 62 // Get list of registered printers.
62 AddPendingAvailableTask(); 63 AddPendingAvailableTask();
63 return true; 64 return true;
64 } 65 }
65 66
66 void CloudPrintConnector::Stop() { 67 void CloudPrintConnector::Stop() {
67 VLOG(1) << "CP_CONNECTOR: Stopping connector, id: " << proxy_id_; 68 VLOG(1) << "CP_CONNECTOR: Stopping connector"
69 << ", proxy id: " << proxy_id_;
68 DCHECK(print_system_.get()); 70 DCHECK(print_system_.get());
69 if (print_system_.get()) { 71 if (print_system_.get()) {
70 // Do uninitialization here. 72 // Do uninitialization here.
71 pending_tasks_.clear(); 73 pending_tasks_.clear();
72 print_server_watcher_.release(); 74 print_server_watcher_.release();
73 print_system_.release(); 75 print_system_.release();
74 } 76 }
75 request_ = NULL; 77 request_ = NULL;
76 } 78 }
77 79
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 ContinuePendingTaskProcessing(); // Continue processing background tasks. 231 ContinuePendingTaskProcessing(); // Continue processing background tasks.
230 return CloudPrintURLFetcher::STOP_PROCESSING; 232 return CloudPrintURLFetcher::STOP_PROCESSING;
231 } 233 }
232 234
233 CloudPrintURLFetcher::ResponseAction 235 CloudPrintURLFetcher::ResponseAction
234 CloudPrintConnector::HandlePrinterDeleteResponse( 236 CloudPrintConnector::HandlePrinterDeleteResponse(
235 const net::URLFetcher* source, 237 const net::URLFetcher* source,
236 const GURL& url, 238 const GURL& url,
237 DictionaryValue* json_data, 239 DictionaryValue* json_data,
238 bool succeeded) { 240 bool succeeded) {
239 VLOG(1) << "CP_CONNECTOR: Handler printer delete response, succeeded:" 241 VLOG(1) << "CP_CONNECTOR: Handler printer delete response"
240 << succeeded << " url: " << url; 242 << ", succeeded: " << succeeded
243 << ", url: " << url;
241 ContinuePendingTaskProcessing(); // Continue processing background tasks. 244 ContinuePendingTaskProcessing(); // Continue processing background tasks.
242 return CloudPrintURLFetcher::STOP_PROCESSING; 245 return CloudPrintURLFetcher::STOP_PROCESSING;
243 } 246 }
244 247
245 CloudPrintURLFetcher::ResponseAction 248 CloudPrintURLFetcher::ResponseAction
246 CloudPrintConnector::HandleRegisterPrinterResponse( 249 CloudPrintConnector::HandleRegisterPrinterResponse(
247 const net::URLFetcher* source, 250 const net::URLFetcher* source,
248 const GURL& url, 251 const GURL& url,
249 DictionaryValue* json_data, 252 DictionaryValue* json_data,
250 bool succeeded) { 253 bool succeeded) {
251 VLOG(1) << "CP_CONNECTOR: Handler printer register response, succeeded:" 254 VLOG(1) << "CP_CONNECTOR: Handler printer register response"
252 << succeeded << " url: " << url; 255 << ", succeeded: " << succeeded
256 << ", url: " << url;
253 if (succeeded) { 257 if (succeeded) {
254 ListValue* printer_list = NULL; 258 ListValue* printer_list = NULL;
255 // There should be a "printers" value in the JSON 259 // There should be a "printers" value in the JSON
256 if (json_data->GetList(cloud_print::kPrinterListValue, &printer_list)) { 260 if (json_data->GetList(cloud_print::kPrinterListValue, &printer_list)) {
257 DictionaryValue* printer_data = NULL; 261 DictionaryValue* printer_data = NULL;
258 if (printer_list->GetDictionary(0, &printer_data)) 262 if (printer_list->GetDictionary(0, &printer_data))
259 InitJobHandlerForPrinter(printer_data); 263 InitJobHandlerForPrinter(printer_data);
260 } 264 }
261 } 265 }
262 ContinuePendingTaskProcessing(); // Continue processing background tasks. 266 ContinuePendingTaskProcessing(); // Continue processing background tasks.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 } 319 }
316 return false; 320 return false;
317 } 321 }
318 322
319 void CloudPrintConnector::InitJobHandlerForPrinter( 323 void CloudPrintConnector::InitJobHandlerForPrinter(
320 DictionaryValue* printer_data) { 324 DictionaryValue* printer_data) {
321 DCHECK(printer_data); 325 DCHECK(printer_data);
322 PrinterJobHandler::PrinterInfoFromCloud printer_info_cloud; 326 PrinterJobHandler::PrinterInfoFromCloud printer_info_cloud;
323 printer_data->GetString(kIdValue, &printer_info_cloud.printer_id); 327 printer_data->GetString(kIdValue, &printer_info_cloud.printer_id);
324 DCHECK(!printer_info_cloud.printer_id.empty()); 328 DCHECK(!printer_info_cloud.printer_id.empty());
325 VLOG(1) << "CP_CONNECTOR: Init job handler for printer id: " 329 VLOG(1) << "CP_CONNECTOR: Init job handler"
326 << printer_info_cloud.printer_id; 330 << ", printer id: " << printer_info_cloud.printer_id;
327 JobHandlerMap::iterator index = job_handler_map_.find( 331 JobHandlerMap::iterator index = job_handler_map_.find(
328 printer_info_cloud.printer_id); 332 printer_info_cloud.printer_id);
329 if (index != job_handler_map_.end()) 333 if (index != job_handler_map_.end())
330 return; // Nothing to do if we already have a job handler for this printer. 334 return; // Nothing to do if we already have a job handler for this printer.
331 335
332 printing::PrinterBasicInfo printer_info; 336 printing::PrinterBasicInfo printer_info;
333 printer_data->GetString(kNameValue, &printer_info.printer_name); 337 printer_data->GetString(kNameValue, &printer_info.printer_name);
334 DCHECK(!printer_info.printer_name.empty()); 338 DCHECK(!printer_info.printer_name.empty());
335 printer_data->GetString(kPrinterDescValue, 339 printer_data->GetString(kPrinterDescValue,
336 &printer_info.printer_description); 340 &printer_info.printer_description);
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 StartPostRequest(post_url, 548 StartPostRequest(post_url,
545 kCloudPrintAPIMaxRetryCount, 549 kCloudPrintAPIMaxRetryCount,
546 mime_type, 550 mime_type,
547 post_data, 551 post_data,
548 &CloudPrintConnector::HandleRegisterPrinterResponse); 552 &CloudPrintConnector::HandleRegisterPrinterResponse);
549 } 553 }
550 554
551 bool CloudPrintConnector::IsSamePrinter(const std::string& name1, 555 bool CloudPrintConnector::IsSamePrinter(const std::string& name1,
552 const std::string& name2) const { 556 const std::string& name2) const {
553 return (0 == base::strcasecmp(name1.c_str(), name2.c_str())); 557 return (0 == base::strcasecmp(name1.c_str(), name2.c_str()));
554 } 558 }
Albert Bodenhamer 2012/07/23 20:49:02 Did you change something at EOF? If so, please un
Alex Yu 2012/07/23 21:16:51 I think my vim automatically deletes blank EOF. F
555
OLDNEW
« no previous file with comments | « no previous file | chrome/service/cloud_print/print_system_cups.cc » ('j') | chrome/service/cloud_print/printer_job_handler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698