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

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