Don't delete print system on connector stop.

It may contains cached printers list.

BUG=139001
TEST=none

Review URL: https://chromiumcodereview.appspot.com/10825172

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150199 0039d316-1c4b-4281-b951-d872f2087c98
parent 38071963
......@@ -34,26 +34,33 @@ CloudPrintConnector::CloudPrintConnector(
}
}
bool CloudPrintConnector::Start() {
DCHECK(!print_system_.get());
VLOG(1) << "CP_CONNECTOR: Starting connector"
<< ", proxy id: " << proxy_id_;
pending_tasks_.clear();
print_system_ =
cloud_print::PrintSystem::CreateInstance(print_system_settings_.get());
bool CloudPrintConnector::InitPrintSystem() {
if (print_system_.get())
return true;
print_system_ = cloud_print::PrintSystem::CreateInstance(
print_system_settings_.get());
if (!print_system_.get()) {
NOTREACHED();
return false; // No print system available, fail initalization.
return false; // No memory.
}
cloud_print::PrintSystem::PrintSystemResult result = print_system_->Init();
if (!result.succeeded()) {
print_system_.release();
// We could not initialize the print system. We need to notify the server.
ReportUserMessage(kPrintSystemFailedMessageId, result.message());
print_system_.release();
return false;
}
return true;
}
bool CloudPrintConnector::Start() {
VLOG(1) << "CP_CONNECTOR: Starting connector"
<< ", proxy id: " << proxy_id_;
pending_tasks_.clear();
if (!InitPrintSystem())
return false;
// Start watching for updates from the print system.
print_server_watcher_ = print_system_->CreatePrintServerWatcher();
......@@ -67,18 +74,15 @@ bool CloudPrintConnector::Start() {
void CloudPrintConnector::Stop() {
VLOG(1) << "CP_CONNECTOR: Stopping connector"
<< ", proxy id: " << proxy_id_;
DCHECK(print_system_.get());
if (print_system_.get()) {
// Do uninitialization here.
pending_tasks_.clear();
print_server_watcher_.release();
print_system_.release();
}
DCHECK(IsRunning());
// Do uninitialization here.
pending_tasks_.clear();
print_server_watcher_.release();
request_ = NULL;
}
bool CloudPrintConnector::IsRunning() {
return print_system_.get() != NULL;
return print_server_watcher_.get() != NULL;
}
void CloudPrintConnector::GetPrinterIds(std::list<std::string>* printer_ids) {
......
......@@ -158,6 +158,7 @@ class CloudPrintConnector
const printing::PrinterCapsAndDefaults& caps_and_defaults);
bool IsSamePrinter(const std::string& name1, const std::string& name2) const;
bool InitPrintSystem();
// CloudPrintConnector client.
Client* client_;
......@@ -178,7 +179,7 @@ class CloudPrintConnector
JobHandlerMap job_handler_map_;
// Next response handler.
ResponseHandler next_response_handler_;
// The list of peding tasks to be done in the background.
// The list of pending tasks to be done in the background.
std::list<PendingTask> pending_tasks_;
// The CloudPrintURLFetcher instance for the current request.
scoped_refptr<CloudPrintURLFetcher> request_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment