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_TASK_DEPENDENCY_MANAGER_H_
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_TASK_DEPENDENCY_MANAGER_H_
13 #include "base/files/file_path.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "chrome/browser/sync_file_system/subtree_set.h"
17 namespace sync_file_system
{
18 namespace drive_backend
{
23 std::vector
<base::FilePath
> paths
;
24 std::vector
<std::string
> file_ids
;
25 std::vector
<int64
> tracker_ids
;
31 // This class manages dependency of the background tasks.
32 class TaskDependencyManager
{
34 TaskDependencyManager();
35 ~TaskDependencyManager();
37 // Inserts |task_blocker| to the collection and returns true if it
38 // completes successfully. Returns false and doesn't modify the collection
39 // if |task_blocker| conflicts other |task_blocker| that is inserted
41 // Two |task_blocker| are handled as conflict if:
42 // - They have common |file_id| or |tracker_id|.
43 // - Or, they have the same |app_id| and have a |path| that one of its parent
44 // belongs to the |task_blocker|.
45 bool Insert(const TaskBlocker
* task_blocker
);
47 void Erase(const TaskBlocker
* task_blocker
);
50 friend class TaskDependencyManagerTest
;
52 int running_task_count_
;
53 bool running_exclusive_task_
;
54 std::map
<std::string
, SubtreeSet
> paths_by_app_id_
;
55 std::set
<std::string
> file_ids_
;
56 std::set
<int64
> tracker_ids_
;
58 DISALLOW_COPY_AND_ASSIGN(TaskDependencyManager
);
61 } // namespace drive_backend
62 } // namespace sync_file_system
64 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_TASK_DEPENDENCY_MANAGER_H_