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

Unified Diff: ash/system/toast/toast_manager.cc

Issue 2833093002: WIP: simplified display management in ash (Closed)
Patch Set: x Created 3 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 | « ash/system/status_area_widget.cc ('k') | ash/test/ash_test_base.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/toast/toast_manager.cc
diff --git a/ash/system/toast/toast_manager.cc b/ash/system/toast/toast_manager.cc
index 88ac380537fe31fa44aac94d477b61d997711200..0200dbe235c5fdd5537626eece1722e9a7403d19 100644
--- a/ash/system/toast/toast_manager.cc
+++ b/ash/system/toast/toast_manager.cc
@@ -27,8 +27,11 @@ void ToastManager::Show(const ToastData& data) {
const std::string& id = data.id;
DCHECK(!id.empty());
+ LOG(WARNING) << "Show id=" << id;
+
if (current_toast_id_ == id) {
// TODO(yoshiki): Replaces the visible toast.
+ LOG(WARNING) << "1";
return;
}
@@ -37,16 +40,21 @@ void ToastManager::Show(const ToastData& data) {
[&id](const ToastData& data) { return data.id == id; });
if (existing_toast == queue_.end()) {
+ LOG(WARNING) << "2";
queue_.emplace_back(data);
} else {
+ LOG(WARNING) << "3";
*existing_toast = data;
}
- if (queue_.size() == 1 && overlay_ == nullptr)
+ if (queue_.size() == 1 && overlay_ == nullptr) {
+ LOG(WARNING) << "4";
ShowLatest();
+ }
}
void ToastManager::Cancel(const std::string& id) {
+ LOG(WARNING) << "Cancel id=" << id;
if (id == current_toast_id_) {
overlay_->Show(false);
return;
@@ -55,20 +63,26 @@ void ToastManager::Cancel(const std::string& id) {
auto cancelled_toast =
std::find_if(queue_.begin(), queue_.end(),
[&id](const ToastData& data) { return data.id == id; });
- if (cancelled_toast != queue_.end())
+ if (cancelled_toast != queue_.end()) {
+ LOG(WARNING) << "erase";
queue_.erase(cancelled_toast);
+ }
}
void ToastManager::OnClosed() {
+ LOG(WARNING) << "OnClosed";
overlay_.reset();
current_toast_id_.clear();
// Show the next toast if available.
- if (!queue_.empty())
+ if (!queue_.empty()) {
+ LOG(WARNING) << "calling ShowLatest";
ShowLatest();
+ }
}
void ToastManager::ShowLatest() {
+ LOG(WARNING) << "ShowLatest";
DCHECK(!overlay_);
const ToastData data = std::move(queue_.front());
@@ -81,6 +95,7 @@ void ToastManager::ShowLatest() {
overlay_->Show(true);
if (data.duration_ms != ToastData::kInfiniteDuration) {
+ LOG(WARNING) << "postking!";
int32_t duration_ms = std::max(data.duration_ms, kMinimumDurationMs);
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::Bind(&ToastManager::OnDurationPassed,
@@ -90,8 +105,11 @@ void ToastManager::ShowLatest() {
}
void ToastManager::OnDurationPassed(int toast_number) {
- if (overlay_ && serial_ == toast_number)
+ LOG(WARNING) << "OnDurationPassed " << toast_number;
+ if (overlay_ && serial_ == toast_number) {
+ LOG(WARNING) << "OnDurationPassed - showing";
overlay_->Show(false);
+ }
}
} // namespace ash
« no previous file with comments | « ash/system/status_area_widget.cc ('k') | ash/test/ash_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698