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