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

Unified Diff: ui/message_center/message_center_impl.cc

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 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 | « ui/message_center/message_center_impl.h ('k') | ui/message_center/message_center_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/message_center/message_center_impl.cc
diff --git a/ui/message_center/message_center_impl.cc b/ui/message_center/message_center_impl.cc
index 07cbe104ca0da353108a32a70453364311efb145..06a04611514ce0837d61e6da1f97a324dceb367a 100644
--- a/ui/message_center/message_center_impl.cc
+++ b/ui/message_center/message_center_impl.cc
@@ -46,11 +46,11 @@ class ChangeQueue {
public:
Change(ChangeType type,
const std::string& id,
- scoped_ptr<Notification> notification);
+ std::unique_ptr<Notification> notification);
~Change();
// Used to transfer ownership of the contained notification.
- scoped_ptr<Notification> PassNotification();
+ std::unique_ptr<Notification> PassNotification();
Notification* notification() const { return notification_.get(); }
// Returns the post-update ID. It means:
@@ -70,14 +70,14 @@ class ChangeQueue {
void set_type(const ChangeType new_type) {
type_ = new_type;
}
- void ReplaceNotification(scoped_ptr<Notification> new_notification);
+ void ReplaceNotification(std::unique_ptr<Notification> new_notification);
private:
ChangeType type_;
std::string id_;
std::string notification_list_id_;
bool by_user_;
- scoped_ptr<Notification> notification_;
+ std::unique_ptr<Notification> notification_;
DISALLOW_COPY_AND_ASSIGN(Change);
};
@@ -95,11 +95,11 @@ class ChangeQueue {
const std::string& id);
// Causes a TYPE_ADD change to be added to the queue.
- void AddNotification(scoped_ptr<Notification> notification);
+ void AddNotification(std::unique_ptr<Notification> notification);
// Causes a TYPE_UPDATE change to be added to the queue.
void UpdateNotification(const std::string& old_id,
- scoped_ptr<Notification> notification);
+ std::unique_ptr<Notification> notification);
// Causes a TYPE_DELETE change to be added to the queue.
void EraseNotification(const std::string& id, bool by_user);
@@ -115,7 +115,7 @@ class ChangeQueue {
private:
void ApplyChangeInternal(MessageCenterImpl* message_center,
- scoped_ptr<Change> change);
+ std::unique_ptr<Change> change);
ScopedVector<Change> changes_;
@@ -137,7 +137,7 @@ struct ChangeFinder {
ChangeQueue::Change::Change(ChangeType type,
const std::string& id,
- scoped_ptr<Notification> notification)
+ std::unique_ptr<Notification> notification)
: type_(type),
notification_list_id_(id),
by_user_(false),
@@ -150,12 +150,12 @@ ChangeQueue::Change::Change(ChangeType type,
ChangeQueue::Change::~Change() {}
-scoped_ptr<Notification> ChangeQueue::Change::PassNotification() {
+std::unique_ptr<Notification> ChangeQueue::Change::PassNotification() {
return std::move(notification_);
}
void ChangeQueue::Change::ReplaceNotification(
- scoped_ptr<Notification> new_notification) {
+ std::unique_ptr<Notification> new_notification) {
id_ = new_notification ? new_notification->id() : notification_list_id_;
notification_.swap(new_notification);
}
@@ -171,7 +171,7 @@ void ChangeQueue::ApplyChanges(MessageCenterImpl* message_center) {
// This method is re-entrant.
while (!changes_.empty()) {
ScopedVector<Change>::iterator iter = changes_.begin();
- scoped_ptr<Change> change(*iter);
+ std::unique_ptr<Change> change(*iter);
// TODO(dewittj): Replace changes_ with a deque.
changes_.weak_erase(iter);
ApplyChangeInternal(message_center, std::move(change));
@@ -190,7 +190,7 @@ void ChangeQueue::ApplyChangesForId(MessageCenterImpl* message_center,
--iter;
if (interesting_id != (*iter)->id())
continue;
- scoped_ptr<Change> change(*iter);
+ std::unique_ptr<Change> change(*iter);
interesting_id = change->notification_list_id();
@@ -199,19 +199,20 @@ void ChangeQueue::ApplyChangesForId(MessageCenterImpl* message_center,
}
while (!changes_for_id.empty()) {
- ApplyChangeInternal(
- message_center, scoped_ptr<Change>(changes_for_id.back()));
+ ApplyChangeInternal(message_center,
+ std::unique_ptr<Change>(changes_for_id.back()));
changes_for_id.pop_back();
}
}
-void ChangeQueue::AddNotification(scoped_ptr<Notification> notification) {
+void ChangeQueue::AddNotification(std::unique_ptr<Notification> notification) {
std::string id = notification->id();
changes_.push_back(new Change(CHANGE_TYPE_ADD, id, std::move(notification)));
}
-void ChangeQueue::UpdateNotification(const std::string& old_id,
- scoped_ptr<Notification> notification) {
+void ChangeQueue::UpdateNotification(
+ const std::string& old_id,
+ std::unique_ptr<Notification> notification) {
ScopedVector<Change>::reverse_iterator iter =
std::find_if(changes_.rbegin(), changes_.rend(), ChangeFinder(old_id));
if (iter == changes_.rend()) {
@@ -262,7 +263,7 @@ void ChangeQueue::EraseNotification(const std::string& id, bool by_user) {
ScopedVector<Change>::reverse_iterator iter =
std::find_if(changes_.rbegin(), changes_.rend(), ChangeFinder(id));
if (iter == changes_.rend()) {
- scoped_ptr<Change> change(new Change(CHANGE_TYPE_DELETE, id, nullptr));
+ std::unique_ptr<Change> change(new Change(CHANGE_TYPE_DELETE, id, nullptr));
change->set_by_user(by_user);
changes_.push_back(std::move(change));
return;
@@ -306,7 +307,7 @@ Notification* ChangeQueue::GetLatestNotification(const std::string& id) const {
}
void ChangeQueue::ApplyChangeInternal(MessageCenterImpl* message_center,
- scoped_ptr<Change> change) {
+ std::unique_ptr<Change> change) {
switch (change->type()) {
case CHANGE_TYPE_ADD:
message_center->AddNotificationImmediately(change->PassNotification());
@@ -508,7 +509,8 @@ void MessageCenterImpl::ForceNotificationFlush(const std::string& id) {
//------------------------------------------------------------------------------
// Client code interface.
-void MessageCenterImpl::AddNotification(scoped_ptr<Notification> notification) {
+void MessageCenterImpl::AddNotification(
+ std::unique_ptr<Notification> notification) {
DCHECK(notification);
const std::string id = notification->id();
for (size_t i = 0; i < blockers_.size(); ++i)
@@ -524,7 +526,7 @@ void MessageCenterImpl::AddNotification(scoped_ptr<Notification> notification) {
}
void MessageCenterImpl::AddNotificationImmediately(
- scoped_ptr<Notification> notification) {
+ std::unique_ptr<Notification> notification) {
const std::string id = notification->id();
// Sometimes the notification can be added with the same id and the
@@ -546,7 +548,7 @@ void MessageCenterImpl::AddNotificationImmediately(
void MessageCenterImpl::UpdateNotification(
const std::string& old_id,
- scoped_ptr<Notification> new_notification) {
+ std::unique_ptr<Notification> new_notification) {
for (size_t i = 0; i < blockers_.size(); ++i)
blockers_[i]->CheckState();
@@ -580,7 +582,7 @@ void MessageCenterImpl::UpdateNotification(
void MessageCenterImpl::UpdateNotificationImmediately(
const std::string& old_id,
- scoped_ptr<Notification> new_notification) {
+ std::unique_ptr<Notification> new_notification) {
std::string new_id = new_notification->id();
notification_list_->UpdateNotificationMessage(old_id,
std::move(new_notification));
« no previous file with comments | « ui/message_center/message_center_impl.h ('k') | ui/message_center/message_center_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698