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

Unified Diff: chrome/browser/printing/cloud_print/privet_notifications.cc

Issue 2027883002: Fix PrivetNotificationService::PrivetNotify() silliness. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add unit test to hit -1 new printers case Created 4 years, 7 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 | « no previous file | chrome/browser/printing/cloud_print/privet_notifications_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « no previous file | chrome/browser/printing/cloud_print/privet_notifications_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698