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

Unified Diff: chrome/service/cloud_print/cloud_print_connector.cc

Issue 10825172: Don't delete print system on connector stop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/service/cloud_print/cloud_print_connector.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/service/cloud_print/cloud_print_connector.cc
diff --git a/chrome/service/cloud_print/cloud_print_connector.cc b/chrome/service/cloud_print/cloud_print_connector.cc
index a853781a3fc15c5d3befc9213838255f6ef94526..4b9613c874a43aa3673cb8782ce0b6cd5b241667 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) {
« no previous file with comments | « chrome/service/cloud_print/cloud_print_connector.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698