| OLD | NEW |
| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 return false; // No memory. | 47 return false; // No memory. |
| 48 } | 48 } |
| 49 if (print_system_settings_.get()) { | 49 if (print_system_settings_.get()) { |
| 50 bool delete_on_enum_fail = false; | 50 bool delete_on_enum_fail = false; |
| 51 print_system_settings_->GetBoolean(kDeleteOnEnumFail, | 51 print_system_settings_->GetBoolean(kDeleteOnEnumFail, |
| 52 &delete_on_enum_fail); | 52 &delete_on_enum_fail); |
| 53 delete_on_enum_fail_ = delete_on_enum_fail; | 53 delete_on_enum_fail_ = delete_on_enum_fail; |
| 54 } | 54 } |
| 55 cloud_print::PrintSystem::PrintSystemResult result = print_system_->Init(); | 55 cloud_print::PrintSystem::PrintSystemResult result = print_system_->Init(); |
| 56 if (!result.succeeded()) { | 56 if (!result.succeeded()) { |
| 57 print_system_.release(); | 57 print_system_ = NULL; |
| 58 // We could not initialize the print system. We need to notify the server. | 58 // We could not initialize the print system. We need to notify the server. |
| 59 ReportUserMessage(kPrintSystemFailedMessageId, result.message()); | 59 ReportUserMessage(kPrintSystemFailedMessageId, result.message()); |
| 60 return false; | 60 return false; |
| 61 } | 61 } |
| 62 return true; | 62 return true; |
| 63 } | 63 } |
| 64 | 64 |
| 65 bool CloudPrintConnector::Start() { | 65 bool CloudPrintConnector::Start() { |
| 66 VLOG(1) << "CP_CONNECTOR: Starting connector" | 66 VLOG(1) << "CP_CONNECTOR: Starting connector" |
| 67 << ", proxy id: " << proxy_id_; | 67 << ", proxy id: " << proxy_id_; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 79 AddPendingAvailableTask(); | 79 AddPendingAvailableTask(); |
| 80 return true; | 80 return true; |
| 81 } | 81 } |
| 82 | 82 |
| 83 void CloudPrintConnector::Stop() { | 83 void CloudPrintConnector::Stop() { |
| 84 VLOG(1) << "CP_CONNECTOR: Stopping connector" | 84 VLOG(1) << "CP_CONNECTOR: Stopping connector" |
| 85 << ", proxy id: " << proxy_id_; | 85 << ", proxy id: " << proxy_id_; |
| 86 DCHECK(IsRunning()); | 86 DCHECK(IsRunning()); |
| 87 // Do uninitialization here. | 87 // Do uninitialization here. |
| 88 pending_tasks_.clear(); | 88 pending_tasks_.clear(); |
| 89 print_server_watcher_.release(); | 89 print_server_watcher_ = NULL; |
| 90 request_ = NULL; | 90 request_ = NULL; |
| 91 } | 91 } |
| 92 | 92 |
| 93 bool CloudPrintConnector::IsRunning() { | 93 bool CloudPrintConnector::IsRunning() { |
| 94 return print_server_watcher_.get() != NULL; | 94 return print_server_watcher_.get() != NULL; |
| 95 } | 95 } |
| 96 | 96 |
| 97 void CloudPrintConnector::GetPrinterIds(std::list<std::string>* printer_ids) { | 97 void CloudPrintConnector::GetPrinterIds(std::list<std::string>* printer_ids) { |
| 98 DCHECK(printer_ids); | 98 DCHECK(printer_ids); |
| 99 printer_ids->clear(); | 99 printer_ids->clear(); |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 kCloudPrintAPIMaxRetryCount, | 581 kCloudPrintAPIMaxRetryCount, |
| 582 mime_type, | 582 mime_type, |
| 583 post_data, | 583 post_data, |
| 584 &CloudPrintConnector::HandleRegisterPrinterResponse); | 584 &CloudPrintConnector::HandleRegisterPrinterResponse); |
| 585 } | 585 } |
| 586 | 586 |
| 587 bool CloudPrintConnector::IsSamePrinter(const std::string& name1, | 587 bool CloudPrintConnector::IsSamePrinter(const std::string& name1, |
| 588 const std::string& name2) const { | 588 const std::string& name2) const { |
| 589 return (0 == base::strcasecmp(name1.c_str(), name2.c_str())); | 589 return (0 == base::strcasecmp(name1.c_str(), name2.c_str())); |
| 590 } | 590 } |
| 591 | |
| OLD | NEW |