| Index: chrome/browser/printing/cloud_print/privet_notifications.cc
|
| diff --git a/chrome/browser/printing/cloud_print/privet_notifications.cc b/chrome/browser/printing/cloud_print/privet_notifications.cc
|
| index 8b93ec0dae05d49f4d6727b8c1296de9d85b6580..56badfc320a6e8887402644e04dba6cef0d926b5 100644
|
| --- a/chrome/browser/printing/cloud_print/privet_notifications.cc
|
| +++ b/chrome/browser/printing/cloud_print/privet_notifications.cc
|
| @@ -91,11 +91,11 @@ void PrivetNotificationsListener::DeviceChanged(
|
| const std::string& name,
|
| const DeviceDescription& description) {
|
| ReportPrivetUmaEvent(PRIVET_DEVICE_CHANGED);
|
| - DeviceContextMap::iterator found = devices_seen_.find(name);
|
| - if (found != devices_seen_.end()) {
|
| + DeviceContextMap::iterator it = devices_seen_.find(name);
|
| + if (it != devices_seen_.end()) {
|
| if (!description.id.empty() && // Device is registered
|
| - found->second->notification_may_be_active) {
|
| - found->second->notification_may_be_active = false;
|
| + it->second->notification_may_be_active) {
|
| + it->second->notification_may_be_active = false;
|
| NotifyDeviceRemoved();
|
| }
|
| return; // Already saw this device.
|
| @@ -118,16 +118,16 @@ void PrivetNotificationsListener::DeviceChanged(
|
|
|
| void PrivetNotificationsListener::CreateInfoOperation(
|
| std::unique_ptr<PrivetHTTPClient> http_client) {
|
| - if (!http_client) {
|
| - // Do nothing if resolution fails.
|
| + // Do nothing if resolution fails.
|
| + if (!http_client)
|
| return;
|
| - }
|
|
|
| std::string name = http_client->GetName();
|
| - DeviceContextMap::iterator device_iter = devices_seen_.find(name);
|
| - if (device_iter == devices_seen_.end())
|
| + DeviceContextMap::iterator it = devices_seen_.find(name);
|
| + if (it == devices_seen_.end())
|
| return;
|
| - DeviceContext* device = device_iter->second.get();
|
| +
|
| + DeviceContext* device = it->second.get();
|
| device->privet_http.swap(http_client);
|
| device->info_operation = device->privet_http->CreateInfoOperation(
|
| base::Bind(&PrivetNotificationsListener::OnPrivetInfoDone,
|
| @@ -154,11 +154,11 @@ void PrivetNotificationsListener::OnPrivetInfoDone(
|
| }
|
|
|
| void PrivetNotificationsListener::DeviceRemoved(const std::string& name) {
|
| - DeviceContextMap::iterator device_iter = devices_seen_.find(name);
|
| - if (device_iter == devices_seen_.end())
|
| + DeviceContextMap::iterator it = devices_seen_.find(name);
|
| + if (it == devices_seen_.end())
|
| return;
|
| - DeviceContext* device = device_iter->second.get();
|
|
|
| + DeviceContext* device = it->second.get();
|
| device->info_operation.reset();
|
| device->privet_http_resolution.reset();
|
| device->notification_may_be_active = false;
|
| @@ -166,9 +166,8 @@ void PrivetNotificationsListener::DeviceRemoved(const std::string& name) {
|
| }
|
|
|
| void PrivetNotificationsListener::DeviceCacheFlushed() {
|
| - for (DeviceContextMap::iterator i = devices_seen_.begin();
|
| - i != devices_seen_.end(); ++i) {
|
| - DeviceContext* device = i->second.get();
|
| + for (const auto& it : devices_seen_) {
|
| + DeviceContext* device = it.second.get();
|
|
|
| device->info_operation.reset();
|
| device->privet_http_resolution.reset();
|
|
|