Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/callback_tracker_internal.h

Issue 1873683002: Convert //chrome/browser/sync_file_system from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_CALLBACK_TRACKER_INTERNAL_ H_ 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_ 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_CALLBACK_TRACKER_INTERNAL_ H_
7 7
8 #include <memory>
8 #include <utility> 9 #include <utility>
9 10
10 #include "base/callback.h" 11 #include "base/callback.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 14
15 namespace sync_file_system { 15 namespace sync_file_system {
16 namespace drive_backend { 16 namespace drive_backend {
17 17
18 class CallbackTracker; 18 class CallbackTracker;
19 19
20 namespace internal { 20 namespace internal {
21 21
22 class AbortHelper { 22 class AbortHelper {
23 public: 23 public:
24 explicit AbortHelper(CallbackTracker* tracker); 24 explicit AbortHelper(CallbackTracker* tracker);
25 ~AbortHelper(); 25 ~AbortHelper();
26 base::WeakPtr<AbortHelper> AsWeakPtr(); 26 base::WeakPtr<AbortHelper> AsWeakPtr();
27 27
28 static scoped_ptr<AbortHelper> TakeOwnership( 28 static std::unique_ptr<AbortHelper> TakeOwnership(
29 const base::WeakPtr<AbortHelper>& abort_helper); 29 const base::WeakPtr<AbortHelper>& abort_helper);
30 30
31 private: 31 private:
32 CallbackTracker* tracker_; // Not owned. 32 CallbackTracker* tracker_; // Not owned.
33 base::WeakPtrFactory<AbortHelper> weak_ptr_factory_; 33 base::WeakPtrFactory<AbortHelper> weak_ptr_factory_;
34 34
35 DISALLOW_COPY_AND_ASSIGN(AbortHelper); 35 DISALLOW_COPY_AND_ASSIGN(AbortHelper);
36 }; 36 };
37 37
38 template <typename> 38 template <typename>
39 struct InvokeAndInvalidateHelper; 39 struct InvokeAndInvalidateHelper;
40 40
41 template <typename... Args> 41 template <typename... Args>
42 struct InvokeAndInvalidateHelper<void(Args...)> { 42 struct InvokeAndInvalidateHelper<void(Args...)> {
43 static void Run(const base::WeakPtr<AbortHelper>& abort_helper, 43 static void Run(const base::WeakPtr<AbortHelper>& abort_helper,
44 const base::Callback<void(Args...)>& callback, 44 const base::Callback<void(Args...)>& callback,
45 Args... args) { 45 Args... args) {
46 scoped_ptr<AbortHelper> deleter = AbortHelper::TakeOwnership(abort_helper); 46 std::unique_ptr<AbortHelper> deleter =
47 AbortHelper::TakeOwnership(abort_helper);
47 if (deleter) { 48 if (deleter) {
48 callback.Run(std::forward<Args>(args)...); 49 callback.Run(std::forward<Args>(args)...);
49 } 50 }
50 } 51 }
51 }; 52 };
52 53
53 } // namespace internal 54 } // namespace internal
54 } // namespace drive_backend 55 } // namespace drive_backend
55 } // namespace sync_file_system 56 } // namespace sync_file_system
56 57
57 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_CALLBACK_TRACKER_INTERN AL_H_ 58 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_CALLBACK_TRACKER_INTERN AL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698