| 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
|
|
|