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

Unified Diff: chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.h

Issue 23949002: [SyncFS] Implement SyncEngineInitializer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: +comment Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.h
diff --git a/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.h b/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.h
index dc31beacf8e1a777428b13f11a2369b6f020be0a..fcd280557d5ecb1c0764317640291cd43212ff73 100644
--- a/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.h
+++ b/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.h
@@ -7,13 +7,22 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/scoped_vector.h"
#include "base/memory/weak_ptr.h"
#include "base/sequenced_task_runner.h"
+#include "chrome/browser/google_apis/drive_common_callbacks.h"
+#include "chrome/browser/google_apis/gdata_errorcode.h"
#include "chrome/browser/sync_file_system/sync_callbacks.h"
#include "chrome/browser/sync_file_system/sync_task.h"
namespace drive {
-class DriveAPIService;
+class DriveServiceInterface;
+}
+
+namespace google_apis {
+class AboutResource;
+class ResourceEntry;
+class ResourceList;
}
namespace sync_file_system {
@@ -21,24 +30,86 @@ namespace drive_backend {
class MetadataDatabase;
+// This class performs initializion sequence of SyncEngine.
+//
+// After initialize sequence completed, the Database must have
+// - Largest change ID,
+// - Sync-root folder and its tracker,
+// - All children of sync-root folder that have inactive and non-dirty
+// trackers.
+//
+// The initialization sequence is:
+// - Open database and load its contents,
+// - If the database is already populated, complete the sequence.
+// - Get AboutResource to get the largest change ID and the root folder ID.
+// - Find the remote sync-root folder, that title is
kinuko 2013/09/09 12:35:50 that -> whose (that cannot be used for possessive)
tzik 2013/09/10 06:00:42 Done.
+// "Chrome Syncable FileSystem" and has no parent.
+// Note that if the initialization interrupted by the browser restart or an
kinuko 2013/09/09 12:35:50 interrupted -> is interrupted
tzik 2013/09/10 06:00:42 Done.
+// error, the sequence leaves the folder in the root directory. So, if we
kinuko 2013/09/09 12:35:50 directory -> folder? There're many 'root' directo
tzik 2013/09/10 06:00:42 Done.
+// find the folder in the root folder, handle it as the sync-root folder.
+// - Create the remote sync-root folder if we don't have.
+// - Detach the remote sync-root folder from its parent if it has.
+// - Fetch the folder contents of the remote sync-root folder.
+// The contents are likely registered as app-root folders, but handle them
+// handle as regular inactive folders until they are registered explicitly.
nhiroki 2013/09/09 14:21:57 "but handle them handle as..." -> "but handle them
tzik 2013/09/10 06:00:42 Done.
+// - Populate database with the largest change ID, the sync-root folder and
+// its contents.
+//
class SyncEngineInitializer : public SyncTask {
public:
SyncEngineInitializer(base::SequencedTaskRunner* task_runner,
- drive::DriveAPIService* drive_api,
+ drive::DriveServiceInterface* drive_api,
const base::FilePath& database_path);
virtual ~SyncEngineInitializer();
virtual void Run(const SyncStatusCallback& callback) OVERRIDE;
+ scoped_ptr<MetadataDatabase> PassMetadataDatabase();
+
private:
+ typedef base::Callback<void(const SyncStatusCallback& callback)> Task;
+
void DidCreateMetadataDatabase(const SyncStatusCallback& callback,
SyncStatusCode status,
scoped_ptr<MetadataDatabase> instance);
+ void GetAboutResource(const SyncStatusCallback& callback);
+ void DidGetAboutResource(
+ const SyncStatusCallback& callback,
+ google_apis::GDataErrorCode error,
+ scoped_ptr<google_apis::AboutResource> about_resource);
+ void FindSyncRoot(const SyncStatusCallback& callback);
+ void DidFindSyncRoot(const SyncStatusCallback& callback,
+ google_apis::GDataErrorCode error,
+ scoped_ptr<google_apis::ResourceList> resource_list);
+ void CreateSyncRoot(const SyncStatusCallback& callback);
+ void DidCreateSyncRoot(const SyncStatusCallback& callback,
+ google_apis::GDataErrorCode error,
+ scoped_ptr<google_apis::ResourceEntry> entry);
+ void DetachSyncRoot(const SyncStatusCallback& callback);
+ void DidDetachSyncRoot(const SyncStatusCallback& callback,
+ google_apis::GDataErrorCode error);
+ void ListAppRootFolders(const SyncStatusCallback& callback);
+ void DidListAppRootFolders(
+ const SyncStatusCallback& callback,
+ google_apis::GDataErrorCode error,
+ scoped_ptr<google_apis::ResourceList> resource_list);
+ void PopulateDatabase(const SyncStatusCallback& callback);
+ void DidPopulateDatabase(const SyncStatusCallback& callback,
+ SyncStatusCode status);
+ void Finish(const SyncStatusCallback& callback);
+
scoped_refptr<base::SequencedTaskRunner> task_runner_;
- drive::DriveAPIService* drive_api_;
+ drive::DriveServiceInterface* drive_api_;
kinuko 2013/09/09 12:35:50 nit: if we use this type can we use more regular n
tzik 2013/09/10 06:00:42 Done.
+ google_apis::CancelCallback cancel_callback_;
base::FilePath database_path_;
scoped_ptr<MetadataDatabase> metadata_database_;
+ ScopedVector<google_apis::ResourceEntry> app_root_folders_;
+
+ int64 largest_change_id_;
+ std::string root_folder_id_;
+
+ scoped_ptr<google_apis::ResourceEntry> sync_root_folder_;
base::WeakPtrFactory<SyncEngineInitializer> weak_ptr_factory_;

Powered by Google App Engine
This is Rietveld 408576698