| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_LOCAL_SYNC_OPERATION_RESOLVER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_SYNC_OPERATION_RESOLVER_H_ |
| 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_SYNC_OPERATION_RESOLVER_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_SYNC_OPERATION_RESOLVER_H_ |
| 7 | 7 |
| 8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
| 9 #include "webkit/fileapi/syncable/file_change.h" | 9 #include "webkit/fileapi/syncable/file_change.h" |
| 10 #include "webkit/fileapi/syncable/sync_file_type.h" | 10 #include "webkit/fileapi/syncable/sync_file_type.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 LOCAL_SYNC_OPERATION_NONE, | 23 LOCAL_SYNC_OPERATION_NONE, |
| 24 LOCAL_SYNC_OPERATION_CONFLICT, | 24 LOCAL_SYNC_OPERATION_CONFLICT, |
| 25 LOCAL_SYNC_OPERATION_RESOLVE_TO_LOCAL, | 25 LOCAL_SYNC_OPERATION_RESOLVE_TO_LOCAL, |
| 26 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, | 26 LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE, |
| 27 LOCAL_SYNC_OPERATION_DELETE_METADATA, | 27 LOCAL_SYNC_OPERATION_DELETE_METADATA, |
| 28 LOCAL_SYNC_OPERATION_FAIL, | 28 LOCAL_SYNC_OPERATION_FAIL, |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 class LocalSyncOperationResolver { | 31 class LocalSyncOperationResolver { |
| 32 public: | 32 public: |
| 33 // |remote_file_change| is non-null when we have a remote change for the file, |
| 34 // and |drive_metadata| is also non-null when we have metadata. |
| 33 static LocalSyncOperationType Resolve( | 35 static LocalSyncOperationType Resolve( |
| 34 const FileChange& local_file_change, | 36 const FileChange& local_file_change, |
| 35 bool has_remote_change, | 37 const FileChange* remote_file_change, |
| 36 const FileChange& remote_file_change, | 38 const DriveMetadata* drive_metadata); |
| 37 DriveMetadata* drive_metadata); | |
| 38 | 39 |
| 39 private: | 40 private: |
| 40 static LocalSyncOperationType ResolveForAddOrUpdateFile( | 41 static LocalSyncOperationType ResolveForAddOrUpdateFile( |
| 41 bool has_remote_change, | 42 const FileChange* remote_file_change, |
| 42 const FileChange& remote_file_change, | |
| 43 SyncFileType remote_file_type_in_metadata); | 43 SyncFileType remote_file_type_in_metadata); |
| 44 static LocalSyncOperationType ResolveForAddOrUpdateFileInConflict( | 44 static LocalSyncOperationType ResolveForAddOrUpdateFileInConflict( |
| 45 bool has_remote_change, | 45 const FileChange* remote_file_change); |
| 46 const FileChange& remote_file_change); | |
| 47 static LocalSyncOperationType ResolveForAddDirectory( | 46 static LocalSyncOperationType ResolveForAddDirectory( |
| 48 bool has_remote_change, | 47 const FileChange* remote_file_change, |
| 49 const FileChange& remote_file_change, | |
| 50 SyncFileType remote_file_type_in_metadata); | 48 SyncFileType remote_file_type_in_metadata); |
| 51 static LocalSyncOperationType ResolveForAddDirectoryInConflict( | 49 static LocalSyncOperationType ResolveForAddDirectoryInConflict(); |
| 52 bool has_remote_change, | |
| 53 const FileChange& remote_file_change); | |
| 54 static LocalSyncOperationType ResolveForDeleteFile( | 50 static LocalSyncOperationType ResolveForDeleteFile( |
| 55 bool has_remote_change, | 51 const FileChange* remote_file_change, |
| 56 const FileChange& remote_file_change, | |
| 57 SyncFileType remote_file_type_in_metadata); | 52 SyncFileType remote_file_type_in_metadata); |
| 58 static LocalSyncOperationType ResolveForDeleteFileInConflict( | 53 static LocalSyncOperationType ResolveForDeleteFileInConflict( |
| 59 bool has_remote_change, | 54 const FileChange* remote_file_change); |
| 60 const FileChange& remote_file_change); | |
| 61 static LocalSyncOperationType ResolveForDeleteDirectory( | 55 static LocalSyncOperationType ResolveForDeleteDirectory( |
| 62 bool has_remote_change, | 56 const FileChange* remote_file_change, |
| 63 const FileChange& remote_file_change, | |
| 64 SyncFileType remote_file_type_in_metadata); | 57 SyncFileType remote_file_type_in_metadata); |
| 65 static LocalSyncOperationType ResolveForDeleteDirectoryInConflict( | 58 static LocalSyncOperationType ResolveForDeleteDirectoryInConflict( |
| 66 bool has_remote_change, | 59 const FileChange* remote_file_change); |
| 67 const FileChange& remote_file_change); | |
| 68 | 60 |
| 69 FRIEND_TEST_ALL_PREFIXES(LocalSyncOperationResolverTest, | 61 FRIEND_TEST_ALL_PREFIXES(LocalSyncOperationResolverTest, |
| 70 ResolveForAddOrUpdateFile); | 62 ResolveForAddOrUpdateFile); |
| 71 FRIEND_TEST_ALL_PREFIXES(LocalSyncOperationResolverTest, | 63 FRIEND_TEST_ALL_PREFIXES(LocalSyncOperationResolverTest, |
| 72 ResolveForAddOrUpdateFileInConflict); | 64 ResolveForAddOrUpdateFileInConflict); |
| 73 FRIEND_TEST_ALL_PREFIXES(LocalSyncOperationResolverTest, | 65 FRIEND_TEST_ALL_PREFIXES(LocalSyncOperationResolverTest, |
| 74 ResolveForAddDirectory); | 66 ResolveForAddDirectory); |
| 75 FRIEND_TEST_ALL_PREFIXES(LocalSyncOperationResolverTest, | 67 FRIEND_TEST_ALL_PREFIXES(LocalSyncOperationResolverTest, |
| 76 ResolveForAddDirectoryInConflict); | 68 ResolveForAddDirectoryInConflict); |
| 77 FRIEND_TEST_ALL_PREFIXES(LocalSyncOperationResolverTest, | 69 FRIEND_TEST_ALL_PREFIXES(LocalSyncOperationResolverTest, |
| 78 ResolveForDeleteFile); | 70 ResolveForDeleteFile); |
| 79 FRIEND_TEST_ALL_PREFIXES(LocalSyncOperationResolverTest, | 71 FRIEND_TEST_ALL_PREFIXES(LocalSyncOperationResolverTest, |
| 80 ResolveForDeleteFileInConflict); | 72 ResolveForDeleteFileInConflict); |
| 81 FRIEND_TEST_ALL_PREFIXES(LocalSyncOperationResolverTest, | 73 FRIEND_TEST_ALL_PREFIXES(LocalSyncOperationResolverTest, |
| 82 ResolveForDeleteDirectory); | 74 ResolveForDeleteDirectory); |
| 83 FRIEND_TEST_ALL_PREFIXES(LocalSyncOperationResolverTest, | 75 FRIEND_TEST_ALL_PREFIXES(LocalSyncOperationResolverTest, |
| 84 ResolveForDeleteDirectoryInConflict); | 76 ResolveForDeleteDirectoryInConflict); |
| 85 }; | 77 }; |
| 86 | 78 |
| 87 } // namespace sync_file_system | 79 } // namespace sync_file_system |
| 88 | 80 |
| 89 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_SYNC_OPERATION_RESOLVER_H_ | 81 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_SYNC_OPERATION_RESOLVER_H_ |
| OLD | NEW |