OLD | NEW |
---|---|
(Empty) | |
1 $$ This is a pump file for generating file templates. Pump is a python | |
2 $$ script that is part of the Google Test suite of utilities. Description | |
3 $$ can be found here: | |
4 $$ | |
5 $$ http://code.google.com/p/googletest/wiki/PumpManual | |
6 $$ | |
7 $$ See comment for MAX_ARITY in base/bind.h.pump. | |
8 $var MAX_ARITY = 7 | |
9 | |
10 // Copyright 2014 The Chromium Authors. All rights reserved. | |
11 // Use of this source code is governed by a BSD-style license that can be | |
12 // found in the LICENSE file. | |
13 | |
14 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_CALLBACK_TRACKER_INTERNAL_ H_ | |
15 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_CALLBACK_TRACKER_INTERNAL_ H_ | |
16 | |
17 #include "base/callback_internal.h" | |
18 #include "base/memory/scoped_ptr.h" | |
19 #include "base/memory/weak_ptr.h" | |
20 #include "chrome/browser/sync_file_system/drive_backend/callback_tracker.h" | |
21 | |
22 namespace sync_file_system { | |
23 namespace drive_backend { | |
24 | |
25 class CallbackTracker; | |
26 | |
27 namespace internal { | |
28 | |
29 class AbortHelper { | |
30 public: | |
31 explicit AbortHelper(CallbackTracker* tracker); | |
32 ~AbortHelper(); | |
33 base::WeakPtr<AbortHelper> AsWeakPtr(); | |
34 | |
35 static scoped_ptr<AbortHelper> TakeOwnership( | |
36 const base::WeakPtr<AbortHelper>& abort_helper); | |
37 | |
38 private: | |
39 CallbackTracker* tracker_; // Not owned. | |
40 base::WeakPtrFactory<AbortHelper> weak_ptr_factory_; | |
41 | |
42 DISALLOW_COPY_AND_ASSIGN(AbortHelper); | |
43 }; | |
44 | |
45 template <typename> | |
46 struct InvokeAndInvalidateHelper; | |
47 | |
48 template <typename> | |
peria
2014/06/04 08:24:41
ditto.
tzik
2014/06/04 08:48:34
Done.
| |
49 struct InvokeAndInvalidateHelper; | |
50 | |
51 $range ARITY 0..MAX_ARITY | |
52 $for ARITY [[ | |
53 $range ARG 1..ARITY | |
54 | |
55 template <$for ARG , [[typename A$(ARG)]]> | |
56 struct InvokeAndInvalidateHelper<void($for ARG , [[A$(ARG)]])> { | |
57 static void Run(const base::WeakPtr<AbortHelper>& abort_helper, | |
58 const base::Callback<void($for ARG , [[A$(ARG)]])>& callback | |
59 $if ARITY != 0 [[, ]] | |
60 $for ARG , [[A$(ARG) a$(ARG)]] | |
61 ) { | |
62 scoped_ptr<AbortHelper> deleter = AbortHelper::TakeOwnership(abort_helper); | |
63 if (deleter) { | |
64 callback.Run( | |
65 $for ARG , [[base::internal::CallbackForward(a$(ARG))]]); | |
66 } | |
67 } | |
68 }; | |
69 | |
70 ]] $$ for ARITY | |
71 | |
72 } // namespace internal | |
73 } // namespace drive_backend | |
74 } // namespace sync_file_system | |
75 | |
76 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_CALLBACK_TRACKER_INTERN AL_H_ | |
OLD | NEW |