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

Side by Side Diff: chrome/browser/chromeos/drive/sync_client.h

Issue 372713004: Wait for parent directory sync before performing server-side copy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add operation_observer.cc Created 6 years, 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_CHROMEOS_DRIVE_SYNC_CLIENT_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_SYNC_CLIENT_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_SYNC_CLIENT_H_ 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_SYNC_CLIENT_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 // Adds a fetch task. 61 // Adds a fetch task.
62 void AddFetchTask(const std::string& local_id); 62 void AddFetchTask(const std::string& local_id);
63 63
64 // Removes a fetch task. 64 // Removes a fetch task.
65 void RemoveFetchTask(const std::string& local_id); 65 void RemoveFetchTask(const std::string& local_id);
66 66
67 // Adds a update task. 67 // Adds a update task.
68 void AddUpdateTask(const ClientContext& context, const std::string& local_id); 68 void AddUpdateTask(const ClientContext& context, const std::string& local_id);
69 69
70 // Waits for the update task to complete and runs the callback.
71 // Returns false if no task is found for the spcecified ID.
72 bool WaitForUpdateTaskToComplete(const std::string& local_id,
73 const FileOperationCallback& callback);
74
70 // Starts processing the backlog (i.e. pinned-but-not-filed files and 75 // Starts processing the backlog (i.e. pinned-but-not-filed files and
71 // dirty-but-not-uploaded files). Kicks off retrieval of the local 76 // dirty-but-not-uploaded files). Kicks off retrieval of the local
72 // IDs of these files, and then starts the sync loop. 77 // IDs of these files, and then starts the sync loop.
73 void StartProcessingBacklog(); 78 void StartProcessingBacklog();
74 79
75 // Starts checking the existing pinned files to see if these are 80 // Starts checking the existing pinned files to see if these are
76 // up-to-date. If stale files are detected, the local IDs of these files 81 // up-to-date. If stale files are detected, the local IDs of these files
77 // are added and the sync loop is started. 82 // are added and the sync loop is started.
78 void StartCheckingExistingPinnedFiles(); 83 void StartCheckingExistingPinnedFiles();
79 84
80 // Sets a delay for testing. 85 // Sets a delay for testing.
81 void set_delay_for_testing(const base::TimeDelta& delay) { 86 void set_delay_for_testing(const base::TimeDelta& delay) {
82 delay_ = delay; 87 delay_ = delay;
83 } 88 }
84 89
85 // Starts the sync loop if it's not running.
86 void StartSyncLoop();
87
88 private: 90 private:
89 // Types of sync tasks. 91 // Types of sync tasks.
90 enum SyncType { 92 enum SyncType {
91 FETCH, // Fetch a file from the Drive server. 93 FETCH, // Fetch a file from the Drive server.
92 UPDATE, // Updates an entry's metadata or content on the Drive server. 94 UPDATE, // Updates an entry's metadata or content on the Drive server.
93 }; 95 };
94 96
95 // States of sync tasks. 97 // States of sync tasks.
96 enum SyncState { 98 enum SyncState {
97 SUSPENDED, // Task is currently inactive. 99 SUSPENDED, // Task is currently inactive.
98 PENDING, // Task is going to run. 100 PENDING, // Task is going to run.
99 RUNNING, // Task is running. 101 RUNNING, // Task is running.
100 }; 102 };
101 103
102 typedef std::pair<SyncType, std::string> SyncTaskKey; 104 typedef std::pair<SyncType, std::string> SyncTaskKey;
103 105
104 struct SyncTask { 106 struct SyncTask {
105 SyncTask(); 107 SyncTask();
106 ~SyncTask(); 108 ~SyncTask();
107 SyncState state; 109 SyncState state;
108 ClientContext context; 110 ClientContext context;
109 base::Callback<base::Closure(const ClientContext& context)> task; 111 base::Callback<base::Closure(const ClientContext& context)> task;
110 bool should_run_again; 112 bool should_run_again;
111 base::Closure cancel_closure; 113 base::Closure cancel_closure;
112 std::vector<SyncTaskKey> dependent_tasks; 114 std::vector<SyncTaskKey> dependent_tasks;
115 std::vector<FileOperationCallback> waiting_callbacks;
113 }; 116 };
114 117
115 typedef std::map<SyncTaskKey, SyncTask> SyncTasks; 118 typedef std::map<SyncTaskKey, SyncTask> SyncTasks;
116 119
117 // Performs a FETCH task. 120 // Performs a FETCH task.
118 base::Closure PerformFetchTask(const std::string& local_id, 121 base::Closure PerformFetchTask(const std::string& local_id,
119 const ClientContext& context); 122 const ClientContext& context);
120 123
121 // Adds a FETCH task. 124 // Adds a FETCH task.
122 void AddFetchTaskInternal(const std::string& local_id, 125 void AddFetchTaskInternal(const std::string& local_id,
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 // invalidate its weak pointers before any other members are destroyed. 187 // invalidate its weak pointers before any other members are destroyed.
185 base::WeakPtrFactory<SyncClient> weak_ptr_factory_; 188 base::WeakPtrFactory<SyncClient> weak_ptr_factory_;
186 189
187 DISALLOW_COPY_AND_ASSIGN(SyncClient); 190 DISALLOW_COPY_AND_ASSIGN(SyncClient);
188 }; 191 };
189 192
190 } // namespace internal 193 } // namespace internal
191 } // namespace drive 194 } // namespace drive
192 195
193 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_SYNC_CLIENT_H_ 196 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_SYNC_CLIENT_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/file_system/operation_test_base.cc ('k') | chrome/browser/chromeos/drive/sync_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698