Chromium Code Reviews| 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 "platform/graphics/paint/DisplayItemList.h" | 5 #ifndef Bind_h |
| 6 #define Bind_h | |
| 6 | 7 |
| 7 #include "platform/graphics/paint/PaintChunk.h" | 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". | |
|
haraken
2016/02/09 12:01:21
I'd move the contents of this file to ThreadSafeFu
Yuki
2016/02/12 12:36:14
We'd like to limit the access to base/bind.h. Not
| |
| 8 | 15 |
| 9 namespace blink { | 16 namespace blink { |
| 10 | 17 |
| 11 DisplayItemList::Range<DisplayItemList::iterator> | 18 // Binds an instance of a class to its member function. Does not bind anything |
| 12 DisplayItemList::itemsInPaintChunk(const PaintChunk& paintChunk) | 19 // else. |
| 20 template<typename Class, typename ReturnType, typename... Args> | |
| 21 mojo::Callback<ReturnType(Args...)> | |
| 22 bindInstanceToMethodForMojo(ReturnType (Class::*method)(Args...), Class* instanc e) | |
|
haraken
2016/02/09 12:01:21
tzik@: In your refactoring plan, this method is go
Yuki
2016/02/12 12:36:14
tzik@, is there an easy way to check whether we're
| |
| 13 { | 23 { |
| 14 return Range<iterator>(begin() + paintChunk.beginIndex, begin() + paintChunk .endIndex); | 24 return base::Bind(method, base::Unretained(instance)); |
| 15 } | |
| 16 | |
| 17 DisplayItemList::Range<DisplayItemList::const_iterator> | |
| 18 DisplayItemList::itemsInPaintChunk(const PaintChunk& paintChunk) const | |
| 19 { | |
| 20 return Range<const_iterator>(begin() + paintChunk.beginIndex, begin() + pain tChunk.endIndex); | |
| 21 } | 25 } |
| 22 | 26 |
| 23 } // namespace blink | 27 } // namespace blink |
| 28 | |
| 29 #endif // Bind_h | |
| OLD | NEW |