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.
5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_CALLBACK_TRACKER_INTERNAL_H_
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_CALLBACK_TRACKER_INTERNAL_H_
8 #include "base/callback.h"
9 #include "base/callback_internal.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
13 namespace sync_file_system
{
14 namespace drive_backend
{
16 class CallbackTracker
;
22 explicit AbortHelper(CallbackTracker
* tracker
);
24 base::WeakPtr
<AbortHelper
> AsWeakPtr();
26 static scoped_ptr
<AbortHelper
> TakeOwnership(
27 const base::WeakPtr
<AbortHelper
>& abort_helper
);
30 CallbackTracker
* tracker_
; // Not owned.
31 base::WeakPtrFactory
<AbortHelper
> weak_ptr_factory_
;
33 DISALLOW_COPY_AND_ASSIGN(AbortHelper
);
37 struct InvokeAndInvalidateHelper
;
39 template <typename
... Args
>
40 struct InvokeAndInvalidateHelper
<void(Args
...)> {
41 static void Run(const base::WeakPtr
<AbortHelper
>& abort_helper
,
42 const base::Callback
<void(Args
...)>& callback
,
44 scoped_ptr
<AbortHelper
> deleter
= AbortHelper::TakeOwnership(abort_helper
);
46 callback
.Run(base::internal::CallbackForward(args
)...);
51 } // namespace internal
52 } // namespace drive_backend
53 } // namespace sync_file_system
55 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_CALLBACK_TRACKER_INTERNAL_H_