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

Side by Side Diff: chrome/service/cloud_print/printer_job_handler.cc

Issue 10021067: Merge 132283 - Fix a crash if GetPrinterCapsAndDefaults returns after the calling printer is delete… (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1084/src/
Patch Set: Created 8 years, 8 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
« no previous file with comments | « chrome/service/cloud_print/printer_job_handler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/printer_job_handler.h" 5 #include "chrome/service/cloud_print/printer_job_handler.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/file_util.h" 9 #include "base/file_util.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 local_job_id_(-1), 47 local_job_id_(-1),
48 next_json_data_handler_(NULL), 48 next_json_data_handler_(NULL),
49 next_data_handler_(NULL), 49 next_data_handler_(NULL),
50 server_error_count_(0), 50 server_error_count_(0),
51 print_thread_("Chrome_CloudPrintJobPrintThread"), 51 print_thread_("Chrome_CloudPrintJobPrintThread"),
52 job_handler_message_loop_proxy_( 52 job_handler_message_loop_proxy_(
53 base::MessageLoopProxy::current()), 53 base::MessageLoopProxy::current()),
54 shutting_down_(false), 54 shutting_down_(false),
55 job_check_pending_(false), 55 job_check_pending_(false),
56 printer_update_pending_(true), 56 printer_update_pending_(true),
57 task_in_progress_(false) { 57 task_in_progress_(false),
58 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
58 } 59 }
59 60
60 bool PrinterJobHandler::Initialize() { 61 bool PrinterJobHandler::Initialize() {
61 if (!print_system_->IsValidPrinter(printer_info_.printer_name)) 62 if (!print_system_->IsValidPrinter(printer_info_.printer_name))
62 return false; 63 return false;
63 64
64 printer_watcher_ = print_system_->CreatePrinterWatcher( 65 printer_watcher_ = print_system_->CreatePrinterWatcher(
65 printer_info_.printer_name); 66 printer_info_.printer_name);
66 printer_watcher_->StartWatching(this); 67 printer_watcher_->StartWatching(this);
67 CheckForJobs(kJobFetchReasonStartup); 68 CheckForJobs(kJobFetchReasonStartup);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 // (could be printer name, description, status or capabilities). 163 // (could be printer name, description, status or capabilities).
163 // First asynchronously fetch the capabilities. 164 // First asynchronously fetch the capabilities.
164 printing::PrinterBasicInfo printer_info; 165 printing::PrinterBasicInfo printer_info;
165 printer_watcher_->GetCurrentPrinterInfo(&printer_info); 166 printer_watcher_->GetCurrentPrinterInfo(&printer_info);
166 167
167 // Asynchronously fetch the printer caps and defaults. The story will 168 // Asynchronously fetch the printer caps and defaults. The story will
168 // continue in OnReceivePrinterCaps. 169 // continue in OnReceivePrinterCaps.
169 print_system_->GetPrinterCapsAndDefaults( 170 print_system_->GetPrinterCapsAndDefaults(
170 printer_info.printer_name.c_str(), 171 printer_info.printer_name.c_str(),
171 base::Bind(&PrinterJobHandler::OnReceivePrinterCaps, 172 base::Bind(&PrinterJobHandler::OnReceivePrinterCaps,
172 base::Unretained(this))); 173 weak_ptr_factory_.GetWeakPtr()));
173 174
174 // While we are waiting for the data, pretend we have work to do and return 175 // While we are waiting for the data, pretend we have work to do and return
175 // true. 176 // true.
176 return true; 177 return true;
177 } 178 }
178 179
179 void PrinterJobHandler::OnReceivePrinterCaps( 180 void PrinterJobHandler::OnReceivePrinterCaps(
180 bool succeeded, 181 bool succeeded,
181 const std::string& printer_name, 182 const std::string& printer_name,
182 const printing::PrinterCapsAndDefaults& caps_and_defaults) { 183 const printing::PrinterCapsAndDefaults& caps_and_defaults) {
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 job_handler_message_loop_proxy_->PostTask( 638 job_handler_message_loop_proxy_->PostTask(
638 FROM_HERE, base::Bind(&PrinterJobHandler::JobSpooled, this, job_id)); 639 FROM_HERE, base::Bind(&PrinterJobHandler::JobSpooled, this, job_id));
639 } 640 }
640 641
641 void PrinterJobHandler::OnJobSpoolFailed() { 642 void PrinterJobHandler::OnJobSpoolFailed() {
642 DCHECK(MessageLoop::current() == print_thread_.message_loop()); 643 DCHECK(MessageLoop::current() == print_thread_.message_loop());
643 job_spooler_ = NULL; 644 job_spooler_ = NULL;
644 job_handler_message_loop_proxy_->PostTask( 645 job_handler_message_loop_proxy_->PostTask(
645 FROM_HERE, base::Bind(&PrinterJobHandler::JobFailed, this, PRINT_FAILED)); 646 FROM_HERE, base::Bind(&PrinterJobHandler::JobFailed, this, PRINT_FAILED));
646 } 647 }
OLDNEW
« no previous file with comments | « chrome/service/cloud_print/printer_job_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698