| OLD | NEW |
| 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_SYNC_FILE_SYSTEM_DRIVE_METADATA_STORE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_METADATA_STORE_H_ |
| 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_METADATA_STORE_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_METADATA_STORE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 // Returns true if |origin| is a batch sync origin, i.e. the origin's entire | 76 // Returns true if |origin| is a batch sync origin, i.e. the origin's entire |
| 77 // file list hasn't been fully fetched and processed yet. | 77 // file list hasn't been fully fetched and processed yet. |
| 78 bool IsBatchSyncOrigin(const GURL& origin) const; | 78 bool IsBatchSyncOrigin(const GURL& origin) const; |
| 79 | 79 |
| 80 // Returns true if |origin| is an incremental sync origin, i.e. the origin's | 80 // Returns true if |origin| is an incremental sync origin, i.e. the origin's |
| 81 // entire file list has been cached and is ready to apply changes | 81 // entire file list has been cached and is ready to apply changes |
| 82 // incrementally. | 82 // incrementally. |
| 83 bool IsIncrementalSyncOrigin(const GURL& origin) const; | 83 bool IsIncrementalSyncOrigin(const GURL& origin) const; |
| 84 | 84 |
| 85 // Returns true if |origin| is a disabled origin. |
| 86 bool IsOriginDisabled(const GURL& origin) const; |
| 87 |
| 85 // Marks |origin| as a batch sync origin and associates it with the directory | 88 // Marks |origin| as a batch sync origin and associates it with the directory |
| 86 // identified by |resource_id|. | 89 // identified by |resource_id|. |
| 87 // |origin| must not be a batch sync origin nor an incremental sync origin. | 90 // |origin| must not be a batch sync origin nor an incremental sync origin. |
| 88 void AddBatchSyncOrigin(const GURL& origin, const std::string& resource_id); | 91 void AddBatchSyncOrigin(const GURL& origin, const std::string& resource_id); |
| 89 | 92 |
| 90 // Marks |origin| as an incremental sync origin. | 93 // Marks |origin| as an incremental sync origin. |
| 91 // |origin| must be a batch sync origin. | 94 // |origin| must be a batch sync origin. |
| 92 void MoveBatchSyncOriginToIncremental(const GURL& origin); | 95 void MoveBatchSyncOriginToIncremental(const GURL& origin); |
| 93 | 96 |
| 97 void EnableOrigin(const GURL& origin, |
| 98 const SyncStatusCallback& callback); |
| 99 |
| 100 void DisableOrigin(const GURL& origin, |
| 101 const SyncStatusCallback& callback); |
| 102 |
| 94 void RemoveOrigin(const GURL& origin, | 103 void RemoveOrigin(const GURL& origin, |
| 95 const SyncStatusCallback& callback); | 104 const SyncStatusCallback& callback); |
| 96 | 105 |
| 97 // Sets the directory identified by |resource_id| as the sync data directory. | 106 // Sets the directory identified by |resource_id| as the sync data directory. |
| 98 // All data for the Sync FileSystem should be store into the directory. | 107 // All data for the Sync FileSystem should be store into the directory. |
| 99 // It is invalid to overwrite the directory. | 108 // It is invalid to overwrite the directory. |
| 100 void SetSyncRootDirectory(const std::string& resource_id); | 109 void SetSyncRootDirectory(const std::string& resource_id); |
| 101 | 110 |
| 102 // Returns a set of URLs for files in conflict. | 111 // Returns a set of URLs for files in conflict. |
| 103 SyncStatusCode GetConflictURLs( | 112 SyncStatusCode GetConflictURLs( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 121 const ResourceIdByOrigin& batch_sync_origins() const { | 130 const ResourceIdByOrigin& batch_sync_origins() const { |
| 122 DCHECK(CalledOnValidThread()); | 131 DCHECK(CalledOnValidThread()); |
| 123 return batch_sync_origins_; | 132 return batch_sync_origins_; |
| 124 } | 133 } |
| 125 | 134 |
| 126 const ResourceIdByOrigin& incremental_sync_origins() const { | 135 const ResourceIdByOrigin& incremental_sync_origins() const { |
| 127 DCHECK(CalledOnValidThread()); | 136 DCHECK(CalledOnValidThread()); |
| 128 return incremental_sync_origins_; | 137 return incremental_sync_origins_; |
| 129 } | 138 } |
| 130 | 139 |
| 131 // Returns all origins that are tracked. i.e. Union of batch_sync_origins_ and | 140 const ResourceIdByOrigin& disabled_origins() const { |
| 141 DCHECK(CalledOnValidThread()); |
| 142 return disabled_origins_; |
| 143 } |
| 144 |
| 145 // Returns tracked and enabled origins. i.e. Union of batch_sync_origins_ and |
| 132 // incremental_sync_origins_. | 146 // incremental_sync_origins_. |
| 133 void GetAllOrigins(std::vector<GURL>* origins); | 147 void GetEnabledOrigins(std::vector<GURL>* origins); |
| 148 |
| 149 // Returns tracked but disabled origins. i.e. disabled_origins_. |
| 150 void GetDisabledOrigins(std::vector<GURL>* origins); |
| 134 | 151 |
| 135 // Maps |resource_id| to corresponding |origin|. | 152 // Maps |resource_id| to corresponding |origin|. |
| 136 // Returns true if the directory indicated by |resource_id| is not an origin | 153 // Returns true if the directory indicated by |resource_id| is not an origin |
| 137 // root directory. | 154 // root directory. |
| 138 bool GetOriginByOriginRootDirectoryId(const std::string& resource_id, | 155 bool GetOriginByOriginRootDirectoryId(const std::string& resource_id, |
| 139 GURL* origin); | 156 GURL* origin); |
| 140 | 157 |
| 141 private: | 158 private: |
| 142 friend class DriveMetadataStoreTest; | 159 friend class DriveMetadataStoreTest; |
| 143 | 160 |
| 144 void UpdateDBStatus(SyncStatusCode status); | 161 void UpdateDBStatus(SyncStatusCode status); |
| 145 void UpdateDBStatusAndInvokeCallback(const SyncStatusCallback& callback, | 162 void UpdateDBStatusAndInvokeCallback(const SyncStatusCallback& callback, |
| 146 SyncStatusCode status); | 163 SyncStatusCode status); |
| 147 void DidInitialize(const InitializationCallback& callback, | 164 void DidInitialize(const InitializationCallback& callback, |
| 148 DriveMetadataDBContents* contents, | 165 DriveMetadataDBContents* contents, |
| 149 SyncStatusCode error); | 166 SyncStatusCode error); |
| 150 void DidRemoveOrigin(const SyncStatusCallback& callback, | 167 void DidUpdateOrigin(const SyncStatusCallback& callback, |
| 151 SyncStatusCode status); | 168 SyncStatusCode status); |
| 152 | 169 |
| 153 // These are only for testing. | 170 // These are only for testing. |
| 154 void RestoreSyncRootDirectory(const SyncStatusCallback& callback); | 171 void RestoreSyncRootDirectory(const SyncStatusCallback& callback); |
| 155 void DidRestoreSyncRootDirectory(const SyncStatusCallback& callback, | 172 void DidRestoreSyncRootDirectory(const SyncStatusCallback& callback, |
| 156 std::string* sync_root_directory_resource_id, | 173 std::string* sync_root_directory_resource_id, |
| 157 SyncStatusCode status); | 174 SyncStatusCode status); |
| 158 void RestoreSyncOrigins(const SyncStatusCallback& callback); | 175 void RestoreOrigins(const SyncStatusCallback& callback); |
| 159 void DidRestoreSyncOrigins(const SyncStatusCallback& callback, | 176 void DidRestoreOrigins(const SyncStatusCallback& callback, |
| 160 ResourceIdByOrigin* batch_sync_origins, | 177 ResourceIdByOrigin* batch_sync_origins, |
| 161 ResourceIdByOrigin* incremental_sync_origins, | 178 ResourceIdByOrigin* incremental_sync_origins, |
| 162 SyncStatusCode status); | 179 ResourceIdByOrigin* disabled_origins, |
| 180 SyncStatusCode status); |
| 163 | 181 |
| 164 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; | 182 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; |
| 165 scoped_ptr<DriveMetadataDB> db_; | 183 scoped_ptr<DriveMetadataDB> db_; |
| 166 SyncStatusCode db_status_; | 184 SyncStatusCode db_status_; |
| 167 | 185 |
| 168 int64 largest_changestamp_; | 186 int64 largest_changestamp_; |
| 169 MetadataMap metadata_map_; | 187 MetadataMap metadata_map_; |
| 170 | 188 |
| 171 std::string sync_root_directory_resource_id_; | 189 std::string sync_root_directory_resource_id_; |
| 172 ResourceIdByOrigin batch_sync_origins_; | 190 ResourceIdByOrigin batch_sync_origins_; |
| 173 ResourceIdByOrigin incremental_sync_origins_; | 191 ResourceIdByOrigin incremental_sync_origins_; |
| 192 ResourceIdByOrigin disabled_origins_; |
| 174 | 193 |
| 175 OriginByResourceId origin_by_resource_id_; | 194 OriginByResourceId origin_by_resource_id_; |
| 176 | 195 |
| 177 DISALLOW_COPY_AND_ASSIGN(DriveMetadataStore); | 196 DISALLOW_COPY_AND_ASSIGN(DriveMetadataStore); |
| 178 }; | 197 }; |
| 179 | 198 |
| 180 } // namespace sync_file_system | 199 } // namespace sync_file_system |
| 181 | 200 |
| 182 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_METADATA_STORE_H_ | 201 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_METADATA_STORE_H_ |
| OLD | NEW |