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

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

Issue 297803011: [SyncFS] Run LocalToRemoteSyncer as SyncTask (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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 "base/callback.h" 8 #include "base/callback.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/sync_file_system/sync_callbacks.h" 12 #include "chrome/browser/sync_file_system/sync_callbacks.h"
13 13
14 namespace sync_file_system { 14 namespace sync_file_system {
15 namespace drive_backend { 15 namespace drive_backend {
16 16
17 class SyncTaskManager; 17 class SyncTaskManager;
18 struct BlockingFactor; 18 struct BlockingFactor;
19 19
20 // Represents a running sequence of SyncTasks. Owned by a callback chain that 20 // Represents a running sequence of SyncTasks. Owned by a callback chain that
21 // should run exclusively, and held by SyncTaskManager when no task is running. 21 // should run exclusively, and held by SyncTaskManager when no task is running.
22 class SyncTaskToken { 22 class SyncTaskToken {
23 public: 23 public:
24 static const int64 kTestingTaskTokenID;
24 static const int64 kForegroundTaskTokenID; 25 static const int64 kForegroundTaskTokenID;
25 static const int64 kMinimumBackgroundTaskTokenID; 26 static const int64 kMinimumBackgroundTaskTokenID;
26 27
28 static scoped_ptr<SyncTaskToken> CreateForTesting(
29 const SyncStatusCallback& callback);
27 static scoped_ptr<SyncTaskToken> CreateForForegroundTask( 30 static scoped_ptr<SyncTaskToken> CreateForForegroundTask(
28 const base::WeakPtr<SyncTaskManager>& manager); 31 const base::WeakPtr<SyncTaskManager>& manager);
29 static scoped_ptr<SyncTaskToken> CreateForBackgroundTask( 32 static scoped_ptr<SyncTaskToken> CreateForBackgroundTask(
30 const base::WeakPtr<SyncTaskManager>& manager, 33 const base::WeakPtr<SyncTaskManager>& manager,
31 int64 token_id, 34 int64 token_id,
32 scoped_ptr<BlockingFactor> blocking_factor); 35 scoped_ptr<BlockingFactor> blocking_factor);
33 36
34 void UpdateTask(const tracked_objects::Location& location, 37 void UpdateTask(const tracked_objects::Location& location,
35 const SyncStatusCallback& callback); 38 const SyncStatusCallback& callback);
36 39
37 const tracked_objects::Location& location() const { return location_; } 40 const tracked_objects::Location& location() const { return location_; }
38 virtual ~SyncTaskToken(); 41 virtual ~SyncTaskToken();
39 42
40 static SyncStatusCallback WrapToCallback(scoped_ptr<SyncTaskToken> token); 43 static SyncStatusCallback WrapToCallback(scoped_ptr<SyncTaskToken> token);
41 44
42 SyncTaskManager* manager() { return manager_.get(); } 45 SyncTaskManager* manager() { return manager_.get(); }
43 46
44 const SyncStatusCallback& callback() const { return callback_; } 47 const SyncStatusCallback& callback() const { return callback_; }
45 void clear_callback() { callback_.Reset(); } 48 void clear_callback() { callback_.Reset(); }
46 49
47 void set_blocking_factor(scoped_ptr<BlockingFactor> blocking_factor); 50 void set_blocking_factor(scoped_ptr<BlockingFactor> blocking_factor);
48 const BlockingFactor* blocking_factor() const; 51 const BlockingFactor* blocking_factor() const;
49 void clear_blocking_factor(); 52 void clear_blocking_factor();
50 53
51 int64 token_id() const { return token_id_; } 54 int64 token_id() const { return token_id_; }
52 55
53 private: 56 private:
54 SyncTaskToken(const base::WeakPtr<SyncTaskManager>& manager, 57 SyncTaskToken(const base::WeakPtr<SyncTaskManager>& manager,
55 int64 token_id, 58 int64 token_id,
56 scoped_ptr<BlockingFactor> blocking_factor); 59 scoped_ptr<BlockingFactor> blocking_factor,
60 const SyncStatusCallback& callback);
57 61
58 base::WeakPtr<SyncTaskManager> manager_; 62 base::WeakPtr<SyncTaskManager> manager_;
59 tracked_objects::Location location_; 63 tracked_objects::Location location_;
60 int64 token_id_; 64 int64 token_id_;
61 SyncStatusCallback callback_; 65 SyncStatusCallback callback_;
62 66
63 scoped_ptr<BlockingFactor> blocking_factor_; 67 scoped_ptr<BlockingFactor> blocking_factor_;
64 68
65 DISALLOW_COPY_AND_ASSIGN(SyncTaskToken); 69 DISALLOW_COPY_AND_ASSIGN(SyncTaskToken);
66 }; 70 };
67 71
68 } // namespace drive_backend 72 } // namespace drive_backend
69 } // namespace sync_file_system 73 } // namespace sync_file_system
70 74
71 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_TASK_TOKEN_H_ 75 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_TASK_TOKEN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698