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

Unified Diff: sky/engine/core/dom/custom2/new_custom_element_callback_scope.cc

Issue 943013002: Implement Custom Elements (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: attributeChanged***d***Callback Created 5 years, 10 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: sky/engine/core/dom/custom2/new_custom_element_callback_scope.cc
diff --git a/sky/engine/core/dom/custom2/new_custom_element_callback_scope.cc b/sky/engine/core/dom/custom2/new_custom_element_callback_scope.cc
new file mode 100644
index 0000000000000000000000000000000000000000..58fb3e97494c6a0c83ed8f42a4debbbdf6cdc287
--- /dev/null
+++ b/sky/engine/core/dom/custom2/new_custom_element_callback_scope.cc
@@ -0,0 +1,39 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sky/engine/config.h"
+#include "sky/engine/core/dom/custom2/new_custom_element_callback_scope.h"
+
+#include "base/callback.h"
+
+namespace blink {
+namespace {
+static NewCustomElementCallbackScope* g_current = nullptr;
+}
+
+NewCustomElementCallbackScope::NewCustomElementCallbackScope()
+ : previous_scope_(g_current) {
+ g_current = this;
+}
+
+NewCustomElementCallbackScope::~NewCustomElementCallbackScope() {
+ while(!callbacks_.isEmpty()) {
+ Vector<base::Closure> local;
+ callbacks_.swap(local);
+ for (const auto& callback : local)
+ callback.Run();
+ }
+
+ g_current = previous_scope_;
+}
+
+NewCustomElementCallbackScope* NewCustomElementCallbackScope::Current() {
+ return g_current;
+}
+
+void NewCustomElementCallbackScope::Enqueue(const base::Closure& callback) {
+ callbacks_.append(callback);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698