OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef REMOTING_HOST_MOCK_CALLBACK_H_ | |
6 #define REMOTING_HOST_MOCK_CALLBACK_H_ | |
7 | |
8 // TODO(lukasza): If possible, move this header file to base/mock_callback.h | |
9 | |
10 #include "base/bind.h" | |
11 #include "base/callback.h" | |
Lambros
2014/11/18 00:19:29
Could you use base/callback_forward.h instead?
Łukasz Anforowicz
2014/11/18 01:03:22
Done. It builds fine. OTOH, I have a feeling it
Lambros
2014/11/18 02:33:52
Yes you're right, you do need the full definition
Łukasz Anforowicz
2014/11/18 17:30:45
Ok, I'll go back to including base/callback.h
| |
12 #include "base/memory/weak_ptr.h" | |
13 | |
14 #include "testing/gmock/include/gmock/gmock.h" | |
15 | |
16 namespace remoting { | |
17 | |
18 template <typename Sig> | |
19 class MockCallback; | |
20 | |
21 template <typename R> | |
22 class MockCallback<R()> { | |
23 public: | |
24 MOCK_CONST_METHOD0_T(Run, R()); | |
Lambros
2014/11/18 00:19:29
Hmm. This could be tricky to generalize to the n-p
Łukasz Anforowicz
2014/11/18 01:03:22
I am doing this in part#3. I am not very happy wi
Lambros
2014/11/18 02:33:52
You're renaming this in a later CL? Why not do it
Łukasz Anforowicz
2014/11/18 17:30:45
No, not renaming. In part#3 I am adding an extra
| |
25 | |
26 MockCallback() : weak_factory_(this) { | |
27 } | |
28 | |
29 base::Callback<R()> GetCallback() { | |
30 return base::Bind(&MockCallback<R()>::Run, weak_factory_.GetWeakPtr()); | |
31 } | |
32 | |
33 private: | |
34 base::WeakPtrFactory<MockCallback<R()>> weak_factory_; | |
Lambros
2014/11/18 00:19:29
I'm not convinced we should use WeakPtr in this co
Łukasz Anforowicz
2014/11/18 01:03:22
Yes - this needs more discussion. I think one way
Lambros
2014/11/18 02:33:52
No, this is too strong a condition. A test could l
Łukasz Anforowicz
2014/11/18 17:30:45
I've been thinking about this a bit more and I am
| |
35 | |
36 DISALLOW_COPY_AND_ASSIGN(MockCallback); | |
37 }; | |
38 | |
39 typedef MockCallback<void(void)> MockClosure; | |
40 | |
41 } // namespace remoting | |
42 | |
43 #endif // REMOTING_HOST_MOCK_CALLBACK_H_ | |
OLD | NEW |