summaryrefslogtreecommitdiffstats
path: root/chrome/service/cloud_print
diff options
context:
space:
mode:
authorvitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-07 00:50:51 +0000
committervitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-07 00:50:51 +0000
commit8b2e85c389cc9eededb3968bdb49a07474a5a898 (patch)
treed0ef09c19725514dbb464be52835576ca17f2aab /chrome/service/cloud_print
parent38071963adec88c39714b6646092d7ee760a2061 (diff)
downloadchromium_src-8b2e85c389cc9eededb3968bdb49a07474a5a898.zip
chromium_src-8b2e85c389cc9eededb3968bdb49a07474a5a898.tar.gz
chromium_src-8b2e85c389cc9eededb3968bdb49a07474a5a898.tar.bz2
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
Diffstat (limited to 'chrome/service/cloud_print')
-rw-r--r--chrome/service/cloud_print/cloud_print_connector.cc42
-rw-r--r--chrome/service/cloud_print/cloud_print_connector.h3
2 files changed, 25 insertions, 20 deletions
diff --git a/chrome/service/cloud_print/cloud_print_connector.cc b/chrome/service/cloud_print/cloud_print_connector.cc
index a853781..4b9613c 100644
--- a/chrome/service/cloud_print/cloud_print_connector.cc
+++ b/chrome/service/cloud_print/cloud_print_connector.cc
@@ -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) {
diff --git a/chrome/service/cloud_print/cloud_print_connector.h b/chrome/service/cloud_print/cloud_print_connector.h
index 80021f6..4cb247a 100644
--- a/chrome/service/cloud_print/cloud_print_connector.h
+++ b/chrome/service/cloud_print/cloud_print_connector.h
@@ -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_;