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

Unified Diff: chrome/browser/resources/md_bookmarks/toast_manager.js

Issue 2926763005: [MD Bookmarks] Refactor window timer mocking. (Closed)
Patch Set: address comments Created 3 years, 6 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
Index: chrome/browser/resources/md_bookmarks/toast_manager.js
diff --git a/chrome/browser/resources/md_bookmarks/toast_manager.js b/chrome/browser/resources/md_bookmarks/toast_manager.js
index c0e72fca69f5cdb3bd5bd1e69b07f2ce1f519e9b..642ce3828deb3e72d8052b014cbcaee892b180ab 100644
--- a/chrome/browser/resources/md_bookmarks/toast_manager.js
+++ b/chrome/browser/resources/md_bookmarks/toast_manager.js
@@ -26,14 +26,11 @@ cr.define('bookmarks', function() {
showUndo_: Boolean,
},
- /** @private {function(number)} */
- clearTimeout_: window.clearTimeout.bind(window),
-
- /** @private {function((Function|null|string), number)} */
- setTimeout_: window.setTimeout.bind(window),
+ /** @private {bookmarks.TimerProxy} */
+ timerProxy_: new bookmarks.TimerProxy(),
/** @private {number|null} */
- hideTimeout_: null,
+ hideTimeoutId_: null,
/** @override */
attached: function() {
@@ -89,14 +86,12 @@ cr.define('bookmarks', function() {
if (!this.duration)
return;
- if (this.hideTimeout_ != null) {
- this.clearTimeout_(this.hideTimeout_);
- this.hideTimeout_ = null;
- }
+ if (this.hideTimeoutId_ != null)
+ this.timerProxy_.clearTimeout(this.hideTimeoutId_);
- this.hideTimeout_ = this.setTimeout_(function() {
+ this.hideTimeoutId_ = this.timerProxy_.setTimeout(function() {
this.open_ = false;
- this.hideTimeout_ = null;
+ this.hideTimeoutId_ = null;
}.bind(this), this.duration);
},
« no previous file with comments | « chrome/browser/resources/md_bookmarks/timer_proxy.js ('k') | chrome/browser/ui/webui/md_bookmarks/md_bookmarks_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698