| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/editing/commands/EditingState.h" | 5 #ifndef BindForMojo_h |
| 6 #define BindForMojo_h |
| 7 |
| 8 #include "base/bind.h" |
| 9 #include "mojo/public/cpp/bindings/callback.h" |
| 10 |
| 11 // This file provides limited access to base::Bind() function. base::Bind() |
| 12 // could be dangerous if it's used across threads, so we don't want to allow |
| 13 // general use of base::Bind(). |
| 14 // See also "platform/ThreadSafeFunctional.h". |
| 6 | 15 |
| 7 namespace blink { | 16 namespace blink { |
| 8 | 17 |
| 9 EditingState::EditingState() | 18 // Binds an instance of a class to its member function. Does not bind anything |
| 19 // else. |
| 20 template<typename Class, typename ReturnType, typename... Args> |
| 21 mojo::Callback<ReturnType(Args...)> |
| 22 sameThreadBindForMojo(ReturnType (Class::*method)(Args...), Class* instance) |
| 10 { | 23 { |
| 24 return base::Bind(method, base::Unretained(instance)); |
| 11 } | 25 } |
| 12 | 26 |
| 13 EditingState::~EditingState() | 27 } // namespace blink |
| 14 { | |
| 15 } | |
| 16 | 28 |
| 17 void EditingState::abort() | 29 #endif // BindForMojo_h |
| 18 { | |
| 19 ASSERT(!m_isAborted); | |
| 20 m_isAborted = true; | |
| 21 } | |
| 22 | |
| 23 // --- | |
| 24 IgnorableEditingAbortState::IgnorableEditingAbortState() | |
| 25 { | |
| 26 } | |
| 27 | |
| 28 IgnorableEditingAbortState::~IgnorableEditingAbortState() | |
| 29 { | |
| 30 } | |
| 31 | |
| 32 #if ENABLE(ASSERT) | |
| 33 // --- | |
| 34 | |
| 35 NoEditingAbortChecker::NoEditingAbortChecker(const char* file, int line) | |
| 36 : m_file(file) | |
| 37 , m_line(line) { } | |
| 38 | |
| 39 NoEditingAbortChecker::~NoEditingAbortChecker() | |
| 40 { | |
| 41 ASSERT_AT(!m_editingState.isAborted(), m_file, m_line, ""); | |
| 42 } | |
| 43 | |
| 44 #endif | |
| 45 | |
| 46 } // namespace blink | |
| OLD | NEW |