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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/sync_task_token.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_SYNC_TASK_TOKEN_H_ 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_TASK_TOKEN_H_
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_TASK_TOKEN_H_ 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_TASK_TOKEN_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory>
11
10 #include "base/callback.h" 12 #include "base/callback.h"
11 #include "base/location.h" 13 #include "base/location.h"
12 #include "base/macros.h" 14 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
15 #include "chrome/browser/sync_file_system/sync_callbacks.h" 16 #include "chrome/browser/sync_file_system/sync_callbacks.h"
16 #include "chrome/browser/sync_file_system/task_logger.h" 17 #include "chrome/browser/sync_file_system/task_logger.h"
17 18
18 namespace sync_file_system { 19 namespace sync_file_system {
19 namespace drive_backend { 20 namespace drive_backend {
20 21
21 class SyncTaskManager; 22 class SyncTaskManager;
22 struct TaskBlocker; 23 struct TaskBlocker;
23 24
24 // Represents a running sequence of SyncTasks. Owned by a callback chain that 25 // Represents a running sequence of SyncTasks. Owned by a callback chain that
25 // should run exclusively, and held by SyncTaskManager when no task is running. 26 // should run exclusively, and held by SyncTaskManager when no task is running.
26 class SyncTaskToken { 27 class SyncTaskToken {
27 public: 28 public:
28 static const int64_t kTestingTaskTokenID; 29 static const int64_t kTestingTaskTokenID;
29 static const int64_t kForegroundTaskTokenID; 30 static const int64_t kForegroundTaskTokenID;
30 static const int64_t kMinimumBackgroundTaskTokenID; 31 static const int64_t kMinimumBackgroundTaskTokenID;
31 32
32 static scoped_ptr<SyncTaskToken> CreateForTesting( 33 static std::unique_ptr<SyncTaskToken> CreateForTesting(
33 const SyncStatusCallback& callback); 34 const SyncStatusCallback& callback);
34 static scoped_ptr<SyncTaskToken> CreateForForegroundTask( 35 static std::unique_ptr<SyncTaskToken> CreateForForegroundTask(
35 const base::WeakPtr<SyncTaskManager>& manager, 36 const base::WeakPtr<SyncTaskManager>& manager,
36 base::SequencedTaskRunner* task_runner); 37 base::SequencedTaskRunner* task_runner);
37 static scoped_ptr<SyncTaskToken> CreateForBackgroundTask( 38 static std::unique_ptr<SyncTaskToken> CreateForBackgroundTask(
38 const base::WeakPtr<SyncTaskManager>& manager, 39 const base::WeakPtr<SyncTaskManager>& manager,
39 base::SequencedTaskRunner* task_runner, 40 base::SequencedTaskRunner* task_runner,
40 int64_t token_id, 41 int64_t token_id,
41 scoped_ptr<TaskBlocker> task_blocker); 42 std::unique_ptr<TaskBlocker> task_blocker);
42 43
43 void UpdateTask(const tracked_objects::Location& location, 44 void UpdateTask(const tracked_objects::Location& location,
44 const SyncStatusCallback& callback); 45 const SyncStatusCallback& callback);
45 46
46 const tracked_objects::Location& location() const { return location_; } 47 const tracked_objects::Location& location() const { return location_; }
47 virtual ~SyncTaskToken(); 48 virtual ~SyncTaskToken();
48 49
49 static SyncStatusCallback WrapToCallback(scoped_ptr<SyncTaskToken> token); 50 static SyncStatusCallback WrapToCallback(
51 std::unique_ptr<SyncTaskToken> token);
50 52
51 SyncTaskManager* manager() { return manager_.get(); } 53 SyncTaskManager* manager() { return manager_.get(); }
52 54
53 const SyncStatusCallback& callback() const { return callback_; } 55 const SyncStatusCallback& callback() const { return callback_; }
54 void clear_callback() { callback_.Reset(); } 56 void clear_callback() { callback_.Reset(); }
55 57
56 void set_task_blocker(scoped_ptr<TaskBlocker> task_blocker); 58 void set_task_blocker(std::unique_ptr<TaskBlocker> task_blocker);
57 const TaskBlocker* task_blocker() const; 59 const TaskBlocker* task_blocker() const;
58 void clear_task_blocker(); 60 void clear_task_blocker();
59 61
60 int64_t token_id() const { return token_id_; } 62 int64_t token_id() const { return token_id_; }
61 63
62 void InitializeTaskLog(const std::string& task_description); 64 void InitializeTaskLog(const std::string& task_description);
63 void FinalizeTaskLog(const std::string& result_description); 65 void FinalizeTaskLog(const std::string& result_description);
64 void RecordLog(const std::string& message); 66 void RecordLog(const std::string& message);
65 67
66 bool has_task_log() const { return !!task_log_; } 68 bool has_task_log() const { return !!task_log_; }
67 void SetTaskLog(scoped_ptr<TaskLogger::TaskLog> task_log); 69 void SetTaskLog(std::unique_ptr<TaskLogger::TaskLog> task_log);
68 scoped_ptr<TaskLogger::TaskLog> PassTaskLog(); 70 std::unique_ptr<TaskLogger::TaskLog> PassTaskLog();
69 71
70 private: 72 private:
71 SyncTaskToken(const base::WeakPtr<SyncTaskManager>& manager, 73 SyncTaskToken(const base::WeakPtr<SyncTaskManager>& manager,
72 const scoped_refptr<base::SequencedTaskRunner>& task_runner, 74 const scoped_refptr<base::SequencedTaskRunner>& task_runner,
73 int64_t token_id, 75 int64_t token_id,
74 scoped_ptr<TaskBlocker> task_blocker, 76 std::unique_ptr<TaskBlocker> task_blocker,
75 const SyncStatusCallback& callback); 77 const SyncStatusCallback& callback);
76 78
77 base::WeakPtr<SyncTaskManager> manager_; 79 base::WeakPtr<SyncTaskManager> manager_;
78 scoped_refptr<base::SequencedTaskRunner> task_runner_; 80 scoped_refptr<base::SequencedTaskRunner> task_runner_;
79 tracked_objects::Location location_; 81 tracked_objects::Location location_;
80 int64_t token_id_; 82 int64_t token_id_;
81 SyncStatusCallback callback_; 83 SyncStatusCallback callback_;
82 84
83 scoped_ptr<TaskLogger::TaskLog> task_log_; 85 std::unique_ptr<TaskLogger::TaskLog> task_log_;
84 scoped_ptr<TaskBlocker> task_blocker_; 86 std::unique_ptr<TaskBlocker> task_blocker_;
85 87
86 DISALLOW_COPY_AND_ASSIGN(SyncTaskToken); 88 DISALLOW_COPY_AND_ASSIGN(SyncTaskToken);
87 }; 89 };
88 90
89 } // namespace drive_backend 91 } // namespace drive_backend
90 } // namespace sync_file_system 92 } // namespace sync_file_system
91 93
92 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_TASK_TOKEN_H_ 94 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_TASK_TOKEN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698