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; |