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

Unified Diff: chrome/browser/local_discovery/privet_local_printer_lister.cc

Issue 333243007: Don't crash on device resolution failure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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
Index: chrome/browser/local_discovery/privet_local_printer_lister.cc
diff --git a/chrome/browser/local_discovery/privet_local_printer_lister.cc b/chrome/browser/local_discovery/privet_local_printer_lister.cc
index 2dc8fa9b6bd2c1c53bd4cd5318eb72ad8b95af59..f9ffb43709fc40408fe4b8eb150af42fdc0c227c 100644
--- a/chrome/browser/local_discovery/privet_local_printer_lister.cc
+++ b/chrome/browser/local_discovery/privet_local_printer_lister.cc
@@ -13,11 +13,7 @@
namespace local_discovery {
struct PrivetLocalPrinterLister::DeviceContext {
- public:
- DeviceContext() {
- }
-
- ~DeviceContext() {
+ DeviceContext() : has_local_printing(false) {
}
scoped_ptr<PrivetHTTPResolution> privet_resolution;
@@ -71,7 +67,7 @@ void PrivetLocalPrinterLister::DeviceChanged(
name,
description.address,
base::Bind(&PrivetLocalPrinterLister::OnPrivetResolved,
- base::Unretained(this)));
+ base::Unretained(this), name));
device_contexts_[name] = context;
context->privet_resolution->Start();
@@ -84,7 +80,13 @@ void PrivetLocalPrinterLister::DeviceCacheFlushed() {
}
void PrivetLocalPrinterLister::OnPrivetResolved(
+ const std::string& name,
scoped_ptr<PrivetHTTPClient> http_client) {
+ if (!http_client) {
+ // Remove device if we can't resolve it.
+ device_contexts_.erase(name);
+ return;
+ }
DeviceContextMap::iterator i = device_contexts_.find(http_client->GetName());
DCHECK(i != device_contexts_.end());
@@ -99,7 +101,7 @@ void PrivetLocalPrinterLister::OnPrivetResolved(
void PrivetLocalPrinterLister::OnPrivetInfoDone(
DeviceContext* context,
- std::string name,
+ const std::string& name,
const base::DictionaryValue* json_value) {
bool has_local_printing = false;
const base::ListValue* api_list = NULL;
« no previous file with comments | « chrome/browser/local_discovery/privet_local_printer_lister.h ('k') | chrome/browser/local_discovery/privet_notifications.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698