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

Side by Side Diff: chromeos/dbus/update_engine_client.cc

Issue 2413963002: Replace FOR_EACH_OBSERVER in chromeos/ with range-based for (Closed)
Patch Set: Run the script again with '/mg' Created 4 years, 2 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
« no previous file with comments | « chromeos/dbus/system_clock_client.cc ('k') | chromeos/disks/disk_mount_manager.cc » ('j') | 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 "chromeos/dbus/update_engine_client.h" 5 #include "chromeos/dbus/update_engine_client.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 reader.PopDouble(&status.download_progress) && 321 reader.PopDouble(&status.download_progress) &&
322 reader.PopString(&current_operation) && 322 reader.PopString(&current_operation) &&
323 reader.PopString(&status.new_version) && 323 reader.PopString(&status.new_version) &&
324 reader.PopInt64(&status.new_size))) { 324 reader.PopInt64(&status.new_size))) {
325 LOG(ERROR) << "GetStatus had incorrect response: " 325 LOG(ERROR) << "GetStatus had incorrect response: "
326 << response->ToString(); 326 << response->ToString();
327 return; 327 return;
328 } 328 }
329 status.status = UpdateStatusFromString(current_operation); 329 status.status = UpdateStatusFromString(current_operation);
330 last_status_ = status; 330 last_status_ = status;
331 FOR_EACH_OBSERVER(Observer, observers_, UpdateStatusChanged(status)); 331 for (auto& observer : observers_)
332 observer.UpdateStatusChanged(status);
332 } 333 }
333 334
334 // Called when GetStatus call failed. 335 // Called when GetStatus call failed.
335 void OnGetStatusError(dbus::ErrorResponse* error) { 336 void OnGetStatusError(dbus::ErrorResponse* error) {
336 LOG(ERROR) << "GetStatus request failed with error: " 337 LOG(ERROR) << "GetStatus request failed with error: "
337 << (error ? error->ToString() : ""); 338 << (error ? error->ToString() : "");
338 } 339 }
339 340
340 // Called when a response for SetReleaseChannel() is received. 341 // Called when a response for SetReleaseChannel() is received.
341 void OnSetChannel(dbus::Response* response) { 342 void OnSetChannel(dbus::Response* response) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 return; 413 return;
413 } 414 }
414 Status status; 415 Status status;
415 status.last_checked_time = last_checked_time; 416 status.last_checked_time = last_checked_time;
416 status.download_progress = progress; 417 status.download_progress = progress;
417 status.status = UpdateStatusFromString(current_operation); 418 status.status = UpdateStatusFromString(current_operation);
418 status.new_version = new_version; 419 status.new_version = new_version;
419 status.new_size = new_size; 420 status.new_size = new_size;
420 421
421 last_status_ = status; 422 last_status_ = status;
422 FOR_EACH_OBSERVER(Observer, observers_, UpdateStatusChanged(status)); 423 for (auto& observer : observers_)
424 observer.UpdateStatusChanged(status);
423 } 425 }
424 426
425 // Called when the status update signal is initially connected. 427 // Called when the status update signal is initially connected.
426 void StatusUpdateConnected(const std::string& interface_name, 428 void StatusUpdateConnected(const std::string& interface_name,
427 const std::string& signal_name, 429 const std::string& signal_name,
428 bool success) { 430 bool success) {
429 LOG_IF(WARNING, !success) 431 LOG_IF(WARNING, !success)
430 << "Failed to connect to status updated signal."; 432 << "Failed to connect to status updated signal.";
431 } 433 }
432 434
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 } 561 }
560 break; 562 break;
561 case UPDATE_STATUS_VERIFYING: 563 case UPDATE_STATUS_VERIFYING:
562 next_status = UPDATE_STATUS_FINALIZING; 564 next_status = UPDATE_STATUS_FINALIZING;
563 break; 565 break;
564 case UPDATE_STATUS_FINALIZING: 566 case UPDATE_STATUS_FINALIZING:
565 next_status = UPDATE_STATUS_IDLE; 567 next_status = UPDATE_STATUS_IDLE;
566 break; 568 break;
567 } 569 }
568 last_status_.status = next_status; 570 last_status_.status = next_status;
569 FOR_EACH_OBSERVER(Observer, observers_, UpdateStatusChanged(last_status_)); 571 for (auto& observer : observers_)
572 observer.UpdateStatusChanged(last_status_);
570 if (last_status_.status != UPDATE_STATUS_IDLE) { 573 if (last_status_.status != UPDATE_STATUS_IDLE) {
571 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 574 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
572 FROM_HERE, base::Bind(&UpdateEngineClientFakeImpl::StateTransition, 575 FROM_HERE, base::Bind(&UpdateEngineClientFakeImpl::StateTransition,
573 weak_factory_.GetWeakPtr()), 576 weak_factory_.GetWeakPtr()),
574 base::TimeDelta::FromMilliseconds(delay_ms)); 577 base::TimeDelta::FromMilliseconds(delay_ms));
575 } 578 }
576 } 579 }
577 580
578 base::ObserverList<Observer> observers_; 581 base::ObserverList<Observer> observers_;
579 Status last_status_; 582 Status last_status_;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 const char** cix = std::find( 618 const char** cix = std::find(
616 kReleaseChannelsList, 619 kReleaseChannelsList,
617 kReleaseChannelsList + arraysize(kReleaseChannelsList), current_channel); 620 kReleaseChannelsList + arraysize(kReleaseChannelsList), current_channel);
618 const char** tix = std::find( 621 const char** tix = std::find(
619 kReleaseChannelsList, 622 kReleaseChannelsList,
620 kReleaseChannelsList + arraysize(kReleaseChannelsList), target_channel); 623 kReleaseChannelsList + arraysize(kReleaseChannelsList), target_channel);
621 return tix > cix; 624 return tix > cix;
622 } 625 }
623 626
624 } // namespace chromeos 627 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/system_clock_client.cc ('k') | chromeos/disks/disk_mount_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698