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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_ENGINE_INITIALIZER_H_ 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_ENGINE_INITIALIZER_H_
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_ENGINE_INITIALIZER_H_ 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_ENGINE_INITIALIZER_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_vector.h"
10 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
11 #include "base/sequenced_task_runner.h" 12 #include "base/sequenced_task_runner.h"
13 #include "chrome/browser/google_apis/drive_common_callbacks.h"
14 #include "chrome/browser/google_apis/gdata_errorcode.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/sync_task.h" 16 #include "chrome/browser/sync_file_system/sync_task.h"
14 17
15 namespace drive { 18 namespace drive {
16 class DriveAPIService; 19 class DriveServiceInterface;
20 }
21
22 namespace google_apis {
23 class AboutResource;
24 class ResourceEntry;
25 class ResourceList;
17 } 26 }
18 27
19 namespace sync_file_system { 28 namespace sync_file_system {
20 namespace drive_backend { 29 namespace drive_backend {
21 30
22 class MetadataDatabase; 31 class MetadataDatabase;
23 32
33 // This class performs initializion sequence of SyncEngine.
34 //
35 // After initialize sequence completed, the Database must have
36 // - Largest change ID,
37 // - Sync-root folder and its tracker,
38 // - All children of sync-root folder that have inactive and non-dirty
39 // trackers.
40 //
41 // The initialization sequence is:
42 // - Open database and load its contents,
43 // - If the database is already populated, complete the sequence.
44 // - Get AboutResource to get the largest change ID and the root folder ID.
45 // - 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.
46 // "Chrome Syncable FileSystem" and has no parent.
47 // 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.
48 // 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.
49 // find the folder in the root folder, handle it as the sync-root folder.
50 // - Create the remote sync-root folder if we don't have.
51 // - Detach the remote sync-root folder from its parent if it has.
52 // - Fetch the folder contents of the remote sync-root folder.
53 // The contents are likely registered as app-root folders, but handle them
54 // 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.
55 // - Populate database with the largest change ID, the sync-root folder and
56 // its contents.
57 //
24 class SyncEngineInitializer : public SyncTask { 58 class SyncEngineInitializer : public SyncTask {
25 public: 59 public:
26 SyncEngineInitializer(base::SequencedTaskRunner* task_runner, 60 SyncEngineInitializer(base::SequencedTaskRunner* task_runner,
27 drive::DriveAPIService* drive_api, 61 drive::DriveServiceInterface* drive_api,
28 const base::FilePath& database_path); 62 const base::FilePath& database_path);
29 virtual ~SyncEngineInitializer(); 63 virtual ~SyncEngineInitializer();
30 virtual void Run(const SyncStatusCallback& callback) OVERRIDE; 64 virtual void Run(const SyncStatusCallback& callback) OVERRIDE;
31 65
66 scoped_ptr<MetadataDatabase> PassMetadataDatabase();
67
32 private: 68 private:
69 typedef base::Callback<void(const SyncStatusCallback& callback)> Task;
70
33 void DidCreateMetadataDatabase(const SyncStatusCallback& callback, 71 void DidCreateMetadataDatabase(const SyncStatusCallback& callback,
34 SyncStatusCode status, 72 SyncStatusCode status,
35 scoped_ptr<MetadataDatabase> instance); 73 scoped_ptr<MetadataDatabase> instance);
36 74
75 void GetAboutResource(const SyncStatusCallback& callback);
76 void DidGetAboutResource(
77 const SyncStatusCallback& callback,
78 google_apis::GDataErrorCode error,
79 scoped_ptr<google_apis::AboutResource> about_resource);
80 void FindSyncRoot(const SyncStatusCallback& callback);
81 void DidFindSyncRoot(const SyncStatusCallback& callback,
82 google_apis::GDataErrorCode error,
83 scoped_ptr<google_apis::ResourceList> resource_list);
84 void CreateSyncRoot(const SyncStatusCallback& callback);
85 void DidCreateSyncRoot(const SyncStatusCallback& callback,
86 google_apis::GDataErrorCode error,
87 scoped_ptr<google_apis::ResourceEntry> entry);
88 void DetachSyncRoot(const SyncStatusCallback& callback);
89 void DidDetachSyncRoot(const SyncStatusCallback& callback,
90 google_apis::GDataErrorCode error);
91 void ListAppRootFolders(const SyncStatusCallback& callback);
92 void DidListAppRootFolders(
93 const SyncStatusCallback& callback,
94 google_apis::GDataErrorCode error,
95 scoped_ptr<google_apis::ResourceList> resource_list);
96 void PopulateDatabase(const SyncStatusCallback& callback);
97 void DidPopulateDatabase(const SyncStatusCallback& callback,
98 SyncStatusCode status);
99 void Finish(const SyncStatusCallback& callback);
100
37 scoped_refptr<base::SequencedTaskRunner> task_runner_; 101 scoped_refptr<base::SequencedTaskRunner> task_runner_;
38 drive::DriveAPIService* drive_api_; 102 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.
103 google_apis::CancelCallback cancel_callback_;
39 base::FilePath database_path_; 104 base::FilePath database_path_;
40 105
41 scoped_ptr<MetadataDatabase> metadata_database_; 106 scoped_ptr<MetadataDatabase> metadata_database_;
107 ScopedVector<google_apis::ResourceEntry> app_root_folders_;
108
109 int64 largest_change_id_;
110 std::string root_folder_id_;
111
112 scoped_ptr<google_apis::ResourceEntry> sync_root_folder_;
42 113
43 base::WeakPtrFactory<SyncEngineInitializer> weak_ptr_factory_; 114 base::WeakPtrFactory<SyncEngineInitializer> weak_ptr_factory_;
44 115
45 DISALLOW_COPY_AND_ASSIGN(SyncEngineInitializer); 116 DISALLOW_COPY_AND_ASSIGN(SyncEngineInitializer);
46 }; 117 };
47 118
48 } // namespace drive_backend 119 } // namespace drive_backend
49 } // namespace sync_file_system 120 } // namespace sync_file_system
50 121
51 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_ENGINE_INITIALIZER _H_ 122 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_ENGINE_INITIALIZER _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698