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

Side by Side Diff: components/proximity_auth/logging/log_buffer.cc

Issue 2423353002: Reduce usage of FOR_EACH_OBSERVER macro in components/ (Closed)
Patch Set: 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/proximity_auth/logging/log_buffer.h" 5 #include "components/proximity_auth/logging/log_buffer.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 8
9 namespace proximity_auth { 9 namespace proximity_auth {
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 void LogBuffer::RemoveObserver(Observer* observer) { 44 void LogBuffer::RemoveObserver(Observer* observer) {
45 observers_.RemoveObserver(observer); 45 observers_.RemoveObserver(observer);
46 } 46 }
47 47
48 void LogBuffer::AddLogMessage(const LogMessage& log_message) { 48 void LogBuffer::AddLogMessage(const LogMessage& log_message) {
49 // Note: We may want to sort the messages by timestamp if there are cases 49 // Note: We may want to sort the messages by timestamp if there are cases
50 // where logs are not added chronologically. 50 // where logs are not added chronologically.
51 log_messages_.push_back(log_message); 51 log_messages_.push_back(log_message);
52 if (log_messages_.size() > MaxBufferSize()) 52 if (log_messages_.size() > MaxBufferSize())
53 log_messages_.pop_front(); 53 log_messages_.pop_front();
54 FOR_EACH_OBSERVER(Observer, observers_, OnLogMessageAdded(log_message)); 54 for (auto& observer : observers_)
55 observer.OnLogMessageAdded(log_message);
55 } 56 }
56 57
57 void LogBuffer::Clear() { 58 void LogBuffer::Clear() {
58 log_messages_.clear(); 59 log_messages_.clear();
59 FOR_EACH_OBSERVER(Observer, observers_, OnLogBufferCleared()); 60 for (auto& observer : observers_)
61 observer.OnLogBufferCleared();
60 } 62 }
61 63
62 size_t LogBuffer::MaxBufferSize() const { 64 size_t LogBuffer::MaxBufferSize() const {
63 return kMaxBufferSize; 65 return kMaxBufferSize;
64 } 66 }
65 67
66 } // proximity_auth 68 } // proximity_auth
OLDNEW
« no previous file with comments | « components/proximity_auth/cryptauth/mock_cryptauth_client.cc ('k') | components/proximity_auth/messenger_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698