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

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

Issue 6356007: Added a diagnostic user message when enumerating printers fails. Also tweaked... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_proxy_backend.h" 5 #include "chrome/service/cloud_print/cloud_print_proxy_backend.h"
6 6
7 #include <map> 7 #include <map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 bool succeeded); 73 bool succeeded);
74 74
75 virtual void OnRequestAuthError(); 75 virtual void OnRequestAuthError();
76 76
77 // cloud_print::PrintServerWatcherDelegate implementation 77 // cloud_print::PrintServerWatcherDelegate implementation
78 virtual void OnPrinterAdded(); 78 virtual void OnPrinterAdded();
79 // PrinterJobHandler::Delegate implementation 79 // PrinterJobHandler::Delegate implementation
80 virtual void OnPrinterJobHandlerShutdown(PrinterJobHandler* job_handler, 80 virtual void OnPrinterJobHandlerShutdown(PrinterJobHandler* job_handler,
81 const std::string& printer_id); 81 const std::string& printer_id);
82 virtual void OnAuthError(); 82 virtual void OnAuthError();
83 virtual bool OnPrinterNotFound(const std::string& printer_name);
83 84
84 // notifier::TalkMediator::Delegate implementation. 85 // notifier::TalkMediator::Delegate implementation.
85 virtual void OnNotificationStateChange( 86 virtual void OnNotificationStateChange(
86 bool notifications_enabled); 87 bool notifications_enabled);
87 virtual void OnIncomingNotification( 88 virtual void OnIncomingNotification(
88 const IncomingNotificationData& notification_data); 89 const IncomingNotificationData& notification_data);
89 virtual void OnOutgoingNotification(); 90 virtual void OnOutgoingNotification();
90 91
91 private: 92 private:
92 // Prototype for a response handler. 93 // Prototype for a response handler.
(...skipping 15 matching lines...) Expand all
108 const GURL& url, 109 const GURL& url,
109 DictionaryValue* json_data, 110 DictionaryValue* json_data,
110 bool succeeded); 111 bool succeeded);
111 112
112 CloudPrintURLFetcher::ResponseAction HandleRegisterFailedStatusResponse( 113 CloudPrintURLFetcher::ResponseAction HandleRegisterFailedStatusResponse(
113 const URLFetcher* source, 114 const URLFetcher* source,
114 const GURL& url, 115 const GURL& url,
115 DictionaryValue* json_data, 116 DictionaryValue* json_data,
116 bool succeeded); 117 bool succeeded);
117 118
118 CloudPrintURLFetcher::ResponseAction HandlePrintSystemUnavailableResponse( 119 CloudPrintURLFetcher::ResponseAction HandlePrintSystemUnavailableResponse(
120 const URLFetcher* source,
121 const GURL& url,
122 DictionaryValue* json_data,
123 bool succeeded);
124
125 CloudPrintURLFetcher::ResponseAction HandleEnumPrintersFailedResponse(
119 const URLFetcher* source, 126 const URLFetcher* source,
120 const GURL& url, 127 const GURL& url,
121 DictionaryValue* json_data, 128 DictionaryValue* json_data,
122 bool succeeded); 129 bool succeeded);
123 // End response handlers 130 // End response handlers
124 131
125 // NotifyXXX is how the Core communicates with the frontend across 132 // NotifyXXX is how the Core communicates with the frontend across
126 // threads. 133 // threads.
127 void NotifyPrinterListAvailable( 134 void NotifyPrinterListAvailable(
128 const printing::PrinterList& printer_list); 135 const printing::PrinterList& printer_list);
(...skipping 14 matching lines...) Expand all
143 // Retrieves the list of registered printers for this user/proxy combination 150 // Retrieves the list of registered printers for this user/proxy combination
144 // from the cloud print server. 151 // from the cloud print server.
145 void GetRegisteredPrinters(); 152 void GetRegisteredPrinters();
146 // Removes the given printer from the list. Returns false if the printer 153 // Removes the given printer from the list. Returns false if the printer
147 // did not exist in the list. 154 // did not exist in the list.
148 bool RemovePrinterFromList(const std::string& printer_name); 155 bool RemovePrinterFromList(const std::string& printer_name);
149 // Initializes a job handler object for the specified printer. The job 156 // Initializes a job handler object for the specified printer. The job
150 // handler is responsible for checking for pending print jobs for this 157 // handler is responsible for checking for pending print jobs for this
151 // printer and print them. 158 // printer and print them.
152 void InitJobHandlerForPrinter(DictionaryValue* printer_data); 159 void InitJobHandlerForPrinter(DictionaryValue* printer_data);
153 // Sends a diagnostic message to the cloud print server that the print 160 // Reports a diagnostic message to the server.
154 // system failed to initialize. 161 void ReportUserMessage(const std::string& message_id,
155 void ReportPrintSystemUnavailable(const std::string& failure_message); 162 const std::string& failure_message,
163 ResponseHandler handler);
156 164
157 // Callback method for GetPrinterCapsAndDefaults. 165 // Callback method for GetPrinterCapsAndDefaults.
158 void OnReceivePrinterCaps( 166 void OnReceivePrinterCaps(
159 bool succeeded, 167 bool succeeded,
160 const std::string& printer_name, 168 const std::string& printer_name,
161 const printing::PrinterCapsAndDefaults& caps_and_defaults); 169 const printing::PrinterCapsAndDefaults& caps_and_defaults);
162 170
163 void HandlePrinterNotification(const std::string& printer_id); 171 void HandlePrinterNotification(const std::string& printer_id);
164 void PollForJobs(); 172 void PollForJobs();
165 // Schedules a task to poll for jobs. Does nothing if a task is already 173 // Schedules a task to poll for jobs. Does nothing if a task is already
166 // scheduled. 174 // scheduled.
167 void ScheduleJobPoll(); 175 void ScheduleJobPoll();
168 176
169 // Our parent CloudPrintProxyBackend 177 // Our parent CloudPrintProxyBackend
170 CloudPrintProxyBackend* backend_; 178 CloudPrintProxyBackend* backend_;
171 179
172 GURL cloud_print_server_url_; 180 GURL cloud_print_server_url_;
173 scoped_ptr<DictionaryValue> print_system_settings_; 181 scoped_ptr<DictionaryValue> print_system_settings_;
174 // Pointer to current print system. 182 // Pointer to current print system.
175 scoped_refptr<cloud_print::PrintSystem> print_system_; 183 scoped_refptr<cloud_print::PrintSystem> print_system_;
176 // The list of printers to be registered with the cloud print server. 184 // The list of printers to be registered with the cloud print server.
177 // To begin with,this list is initialized with the list of local and network 185 // To begin with,this list is initialized with the list of local and network
178 // printers available. Then we query the server for the list of printers 186 // printers available. Then we query the server for the list of printers
179 // already registered. We trim this list to remove the printers already 187 // already registered. We trim this list to remove the printers already
180 // registered. We then pass a copy of this list to the frontend to give the 188 // registered. We then pass a copy of this list to the frontend to give the
181 // user a chance to further trim the list. When the frontend gives us the 189 // user a chance to further trim the list. When the frontend gives us the
182 // final list we make a copy into this so that we can start registering. 190 // final list we make a copy into this so that we can start registering.
183 printing::PrinterList printer_list_; 191 printing::PrinterList printer_list_;
192 // Indicates whether the printers in printer_list_ is the complete set of
193 // printers to be registered for this proxy.
194 bool complete_list_available_;
184 // The CloudPrintURLFetcher instance for the current request. 195 // The CloudPrintURLFetcher instance for the current request.
185 scoped_refptr<CloudPrintURLFetcher> request_; 196 scoped_refptr<CloudPrintURLFetcher> request_;
186 // The index of the nex printer to be uploaded. 197 // The index of the nex printer to be uploaded.
187 size_t next_upload_index_; 198 size_t next_upload_index_;
188 // The unique id for this proxy 199 // The unique id for this proxy
189 std::string proxy_id_; 200 std::string proxy_id_;
190 // The GAIA auth token 201 // The GAIA auth token
191 std::string auth_token_; 202 std::string auth_token_;
192 // Cached info about the last printer that we tried to upload. We cache this 203 // Cached info about the last printer that we tried to upload. We cache this
193 // so we won't have to requery the printer if the upload fails and we need 204 // so we won't have to requery the printer if the upload fails and we need
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 core_.get(), 284 core_.get(),
274 &CloudPrintProxyBackend::Core::DoRegisterSelectedPrinters, 285 &CloudPrintProxyBackend::Core::DoRegisterSelectedPrinters,
275 printer_list)); 286 printer_list));
276 } 287 }
277 288
278 CloudPrintProxyBackend::Core::Core(CloudPrintProxyBackend* backend, 289 CloudPrintProxyBackend::Core::Core(CloudPrintProxyBackend* backend,
279 const GURL& cloud_print_server_url, 290 const GURL& cloud_print_server_url,
280 const DictionaryValue* print_system_settings) 291 const DictionaryValue* print_system_settings)
281 : backend_(backend), 292 : backend_(backend),
282 cloud_print_server_url_(cloud_print_server_url), 293 cloud_print_server_url_(cloud_print_server_url),
294 complete_list_available_(false),
283 next_upload_index_(0), 295 next_upload_index_(0),
284 next_response_handler_(NULL), 296 next_response_handler_(NULL),
285 new_printers_available_(false), 297 new_printers_available_(false),
286 notifications_enabled_(false), 298 notifications_enabled_(false),
287 job_poll_scheduled_(false) { 299 job_poll_scheduled_(false) {
288 if (print_system_settings) { 300 if (print_system_settings) {
289 // It is possible to have no print settings specified. 301 // It is possible to have no print settings specified.
290 print_system_settings_.reset(print_system_settings->DeepCopy()); 302 print_system_settings_.reset(print_system_settings->DeepCopy());
291 } 303 }
292 } 304 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 talk_mediator_->Login(); 387 talk_mediator_->Login();
376 388
377 print_server_watcher_ = print_system_->CreatePrintServerWatcher(); 389 print_server_watcher_ = print_system_->CreatePrintServerWatcher();
378 print_server_watcher_->StartWatching(this); 390 print_server_watcher_->StartWatching(this);
379 391
380 proxy_id_ = proxy_id; 392 proxy_id_ = proxy_id;
381 393
382 StartRegistration(); 394 StartRegistration();
383 } else { 395 } else {
384 // We could not initialize the print system. We need to notify the server. 396 // We could not initialize the print system. We need to notify the server.
385 ReportPrintSystemUnavailable(result.message()); 397 ReportUserMessage(
398 kPrintSystemFailedMessageId,
399 result.message(),
400 &CloudPrintProxyBackend::Core::HandlePrintSystemUnavailableResponse);
386 } 401 }
387 } 402 }
388 403
389 void CloudPrintProxyBackend::Core::StartRegistration() { 404 void CloudPrintProxyBackend::Core::StartRegistration() {
390 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop()); 405 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop());
391 printer_list_.clear(); 406 printer_list_.clear();
392 print_system_->EnumeratePrinters(&printer_list_); 407 cloud_print::PrintSystem::PrintSystemResult result =
393 // Now we need to ask the server about printers that were registered on the 408 print_system_->EnumeratePrinters(&printer_list_);
394 // server so that we can trim this list. 409 complete_list_available_ = result.succeeded();
395 GetRegisteredPrinters(); 410 if (!result.succeeded() && !result.message().empty()) {
gene1 2011/01/24 19:46:47 I think we should not use message here to decide w
sanjeevr 2011/01/24 19:59:05 We can have a fallback message. I don't see why we
411 // There was a failure enumerating printers. Send a message to the server.
412 ReportUserMessage(
413 kEnumPrintersFailedMessageId,
414 result.message(),
415 &CloudPrintProxyBackend::Core::HandleEnumPrintersFailedResponse);
416 } else {
417 // Now we need to ask the server about printers that were registered on the
418 // server so that we can trim this list.
419 GetRegisteredPrinters();
420 }
396 } 421 }
397 422
398 void CloudPrintProxyBackend::Core::EndRegistration() { 423 void CloudPrintProxyBackend::Core::EndRegistration() {
399 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop()); 424 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop());
400 request_ = NULL; 425 request_ = NULL;
401 if (new_printers_available_) { 426 if (new_printers_available_) {
402 new_printers_available_ = false; 427 new_printers_available_ = false;
403 StartRegistration(); 428 StartRegistration();
404 } 429 }
405 } 430 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 } else { 496 } else {
472 EndRegistration(); 497 EndRegistration();
473 } 498 }
474 } 499 }
475 500
476 void CloudPrintProxyBackend::Core::OnReceivePrinterCaps( 501 void CloudPrintProxyBackend::Core::OnReceivePrinterCaps(
477 bool succeeded, 502 bool succeeded,
478 const std::string& printer_name, 503 const std::string& printer_name,
479 const printing::PrinterCapsAndDefaults& caps_and_defaults) { 504 const printing::PrinterCapsAndDefaults& caps_and_defaults) {
480 DCHECK(next_upload_index_ < printer_list_.size()); 505 DCHECK(next_upload_index_ < printer_list_.size());
481 std::string mime_boundary;
482 CloudPrintHelpers::CreateMimeBoundaryForUpload(&mime_boundary);
483 std::string post_data;
484 GURL post_url;
485 if (succeeded) { 506 if (succeeded) {
486 const printing::PrinterBasicInfo& info = 507 const printing::PrinterBasicInfo& info =
487 printer_list_.at(next_upload_index_); 508 printer_list_.at(next_upload_index_);
488 509
489 last_uploaded_printer_name_ = info.printer_name; 510 last_uploaded_printer_name_ = info.printer_name;
490 last_uploaded_printer_info_ = caps_and_defaults; 511 last_uploaded_printer_info_ = caps_and_defaults;
491 512
513 std::string mime_boundary;
514 CloudPrintHelpers::CreateMimeBoundaryForUpload(&mime_boundary);
515 std::string post_data;
516
492 CloudPrintHelpers::AddMultipartValueForUpload(kProxyIdValue, proxy_id_, 517 CloudPrintHelpers::AddMultipartValueForUpload(kProxyIdValue, proxy_id_,
493 mime_boundary, 518 mime_boundary,
494 std::string(), &post_data); 519 std::string(), &post_data);
495 CloudPrintHelpers::AddMultipartValueForUpload(kPrinterNameValue, 520 CloudPrintHelpers::AddMultipartValueForUpload(kPrinterNameValue,
496 info.printer_name, 521 info.printer_name,
497 mime_boundary, 522 mime_boundary,
498 std::string(), &post_data); 523 std::string(), &post_data);
499 CloudPrintHelpers::AddMultipartValueForUpload(kPrinterDescValue, 524 CloudPrintHelpers::AddMultipartValueForUpload(kPrinterDescValue,
500 info.printer_description, 525 info.printer_description,
501 mime_boundary, 526 mime_boundary,
(...skipping 13 matching lines...) Expand all
515 CloudPrintHelpers::AddMultipartValueForUpload( 540 CloudPrintHelpers::AddMultipartValueForUpload(
516 kPrinterDefaultsValue, last_uploaded_printer_info_.printer_defaults, 541 kPrinterDefaultsValue, last_uploaded_printer_info_.printer_defaults,
517 mime_boundary, last_uploaded_printer_info_.defaults_mime_type, 542 mime_boundary, last_uploaded_printer_info_.defaults_mime_type,
518 &post_data); 543 &post_data);
519 // Send a hash of the printer capabilities to the server. We will use this 544 // Send a hash of the printer capabilities to the server. We will use this
520 // later to check if the capabilities have changed 545 // later to check if the capabilities have changed
521 CloudPrintHelpers::AddMultipartValueForUpload( 546 CloudPrintHelpers::AddMultipartValueForUpload(
522 kPrinterCapsHashValue, 547 kPrinterCapsHashValue,
523 MD5String(last_uploaded_printer_info_.printer_capabilities), 548 MD5String(last_uploaded_printer_info_.printer_capabilities),
524 mime_boundary, std::string(), &post_data); 549 mime_boundary, std::string(), &post_data);
525 post_url = CloudPrintHelpers::GetUrlForPrinterRegistration( 550 GURL post_url = CloudPrintHelpers::GetUrlForPrinterRegistration(
526 cloud_print_server_url_); 551 cloud_print_server_url_);
527 552
528 next_response_handler_ = 553 next_response_handler_ =
529 &CloudPrintProxyBackend::Core::HandleRegisterPrinterResponse; 554 &CloudPrintProxyBackend::Core::HandleRegisterPrinterResponse;
555 // Terminate the request body
556 post_data.append("--" + mime_boundary + "--\r\n");
557 std::string mime_type("multipart/form-data; boundary=");
558 mime_type += mime_boundary;
559 request_ = new CloudPrintURLFetcher;
560 request_->StartPostRequest(post_url, this, auth_token_,
561 kCloudPrintAPIMaxRetryCount, mime_type,
562 post_data);
530 } else { 563 } else {
531 LOG(ERROR) << "CP_PROXY: Failed to get printer info for: " << 564 LOG(ERROR) << "CP_PROXY: Failed to get printer info for: " <<
532 printer_name; 565 printer_name;
533 // This printer failed to register, notify the server of this failure. 566 // This printer failed to register, notify the server of this failure.
534 post_url = CloudPrintHelpers::GetUrlForUserMessage(
535 cloud_print_server_url_,
536 kGetPrinterCapsFailedMessageId);
537 string16 printer_name_utf16 = UTF8ToUTF16(printer_name); 567 string16 printer_name_utf16 = UTF8ToUTF16(printer_name);
538 std::string status_message = l10n_util::GetStringFUTF8( 568 std::string status_message = l10n_util::GetStringFUTF8(
539 IDS_CLOUD_PRINT_REGISTER_PRINTER_FAILED, 569 IDS_CLOUD_PRINT_REGISTER_PRINTER_FAILED,
540 printer_name_utf16); 570 printer_name_utf16);
541 CloudPrintHelpers::AddMultipartValueForUpload(kMessageTextValue, 571 ReportUserMessage(
542 status_message, 572 kGetPrinterCapsFailedMessageId,
543 mime_boundary, 573 status_message,
544 std::string(), 574 &CloudPrintProxyBackend::Core::HandleRegisterFailedStatusResponse);
545 &post_data);
546 next_response_handler_ =
547 &CloudPrintProxyBackend::Core::HandleRegisterFailedStatusResponse;
548 } 575 }
549 // Terminate the request body
550 post_data.append("--" + mime_boundary + "--\r\n");
551 std::string mime_type("multipart/form-data; boundary=");
552 mime_type += mime_boundary;
553 request_ = new CloudPrintURLFetcher;
554 request_->StartPostRequest(post_url, this, auth_token_,
555 kCloudPrintAPIMaxRetryCount, mime_type,
556 post_data);
557 } 576 }
558 577
559 void CloudPrintProxyBackend::Core::HandlePrinterNotification( 578 void CloudPrintProxyBackend::Core::HandlePrinterNotification(
560 const std::string& printer_id) { 579 const std::string& printer_id) {
561 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop()); 580 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop());
562 VLOG(1) << "CP_PROXY: Handle printer notification, id: " << printer_id; 581 VLOG(1) << "CP_PROXY: Handle printer notification, id: " << printer_id;
563 JobHandlerMap::iterator index = job_handler_map_.find(printer_id); 582 JobHandlerMap::iterator index = job_handler_map_.find(printer_id);
564 if (index != job_handler_map_.end()) 583 if (index != job_handler_map_.end())
565 index->second->CheckForJobs(kJobFetchReasonNotified); 584 index->second->CheckForJobs(kJobFetchReasonNotified);
566 } 585 }
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 } 737 }
719 scoped_refptr<PrinterJobHandler> job_handler; 738 scoped_refptr<PrinterJobHandler> job_handler;
720 job_handler = new PrinterJobHandler(printer_info, printer_info_cloud, 739 job_handler = new PrinterJobHandler(printer_info, printer_info_cloud,
721 auth_token_, cloud_print_server_url_, 740 auth_token_, cloud_print_server_url_,
722 print_system_.get(), this); 741 print_system_.get(), this);
723 job_handler_map_[printer_info_cloud.printer_id] = job_handler; 742 job_handler_map_[printer_info_cloud.printer_id] = job_handler;
724 job_handler->Initialize(); 743 job_handler->Initialize();
725 } 744 }
726 } 745 }
727 746
728 void CloudPrintProxyBackend::Core::ReportPrintSystemUnavailable( 747 void CloudPrintProxyBackend::Core::ReportUserMessage(
729 const std::string& failure_message) { 748 const std::string& message_id,
749 const std::string& failure_message,
750 ResponseHandler handler) {
730 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop()); 751 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop());
731 std::string mime_boundary; 752 std::string mime_boundary;
732 CloudPrintHelpers::CreateMimeBoundaryForUpload(&mime_boundary); 753 CloudPrintHelpers::CreateMimeBoundaryForUpload(&mime_boundary);
733 GURL post_url = CloudPrintHelpers::GetUrlForUserMessage( 754 GURL post_url = CloudPrintHelpers::GetUrlForUserMessage(
734 cloud_print_server_url_, 755 cloud_print_server_url_,
735 kPrintSystemFailedMessageId); 756 message_id);
736 std::string post_data; 757 std::string post_data;
737 CloudPrintHelpers::AddMultipartValueForUpload(kMessageTextValue, 758 CloudPrintHelpers::AddMultipartValueForUpload(kMessageTextValue,
738 failure_message, 759 failure_message,
739 mime_boundary, 760 mime_boundary,
740 std::string(), 761 std::string(),
741 &post_data); 762 &post_data);
742 next_response_handler_ = 763 next_response_handler_ = handler;
743 &CloudPrintProxyBackend::Core::HandlePrintSystemUnavailableResponse;
744 // Terminate the request body 764 // Terminate the request body
745 post_data.append("--" + mime_boundary + "--\r\n"); 765 post_data.append("--" + mime_boundary + "--\r\n");
746 std::string mime_type("multipart/form-data; boundary="); 766 std::string mime_type("multipart/form-data; boundary=");
747 mime_type += mime_boundary; 767 mime_type += mime_boundary;
748 request_ = new CloudPrintURLFetcher; 768 request_ = new CloudPrintURLFetcher;
749 request_->StartPostRequest(post_url, this, auth_token_, 769 request_->StartPostRequest(post_url, this, auth_token_,
750 kCloudPrintAPIMaxRetryCount, mime_type, 770 kCloudPrintAPIMaxRetryCount, mime_type,
751 post_data); 771 post_data);
752 } 772 }
753 773
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 bool succeeded) { 820 bool succeeded) {
801 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop()); 821 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop());
802 // Let the frontend know that we do not have a print system. 822 // Let the frontend know that we do not have a print system.
803 backend_->frontend_loop_->PostTask( 823 backend_->frontend_loop_->PostTask(
804 FROM_HERE, 824 FROM_HERE,
805 NewRunnableMethod(this, 825 NewRunnableMethod(this,
806 &Core::NotifyPrintSystemUnavailable)); 826 &Core::NotifyPrintSystemUnavailable));
807 return CloudPrintURLFetcher::STOP_PROCESSING; 827 return CloudPrintURLFetcher::STOP_PROCESSING;
808 } 828 }
809 829
830 CloudPrintURLFetcher::ResponseAction
831 CloudPrintProxyBackend::Core::HandleEnumPrintersFailedResponse(
832 const URLFetcher* source,
833 const GURL& url,
834 DictionaryValue* json_data,
835 bool succeeded) {
836 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop());
837 // Now proceed with printer registration.
838 GetRegisteredPrinters();
839 return CloudPrintURLFetcher::STOP_PROCESSING;
840 }
841
842
810 bool CloudPrintProxyBackend::Core::RemovePrinterFromList( 843 bool CloudPrintProxyBackend::Core::RemovePrinterFromList(
811 const std::string& printer_name) { 844 const std::string& printer_name) {
812 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop()); 845 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop());
813 for (printing::PrinterList::iterator index = printer_list_.begin(); 846 for (printing::PrinterList::iterator index = printer_list_.begin();
814 index != printer_list_.end(); index++) { 847 index != printer_list_.end(); index++) {
815 if (0 == base::strcasecmp(index->printer_name.c_str(), 848 if (0 == base::strcasecmp(index->printer_name.c_str(),
816 printer_name.c_str())) { 849 printer_name.c_str())) {
817 index = printer_list_.erase(index); 850 index = printer_list_.erase(index);
818 return true; 851 return true;
819 } 852 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 VLOG(1) << "CP_PROXY: Printer job handle shutdown, id " << printer_id; 909 VLOG(1) << "CP_PROXY: Printer job handle shutdown, id " << printer_id;
877 job_handler_map_.erase(printer_id); 910 job_handler_map_.erase(printer_id);
878 } 911 }
879 912
880 void CloudPrintProxyBackend::Core::OnAuthError() { 913 void CloudPrintProxyBackend::Core::OnAuthError() {
881 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop()); 914 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop());
882 VLOG(1) << "CP_PROXY: Auth Error"; 915 VLOG(1) << "CP_PROXY: Auth Error";
883 backend_->frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, 916 backend_->frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
884 &Core::NotifyAuthenticationFailed)); 917 &Core::NotifyAuthenticationFailed));
885 } 918 }
919
920 bool CloudPrintProxyBackend::Core::OnPrinterNotFound(
gene1 2011/01/24 19:46:47 I am confused with this function. Usually OnSometh
sanjeevr 2011/01/24 19:59:05 I can pass an out param instead of returning a boo
921 const std::string& printer_name) {
922 // If we have a complete list of local printers, then this needs to be deleted
923 // from the server.
924 return complete_list_available_;
925 }
OLDNEW
« no previous file with comments | « chrome/service/cloud_print/cloud_print_consts.cc ('k') | chrome/service/cloud_print/print_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698