| 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_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 <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 JobScheduler* scheduler, | 62 JobScheduler* scheduler, |
| 63 ResourceMetadata* metadata, | 63 ResourceMetadata* metadata, |
| 64 FileCache* cache); | 64 FileCache* cache); |
| 65 virtual ~SyncClient(); | 65 virtual ~SyncClient(); |
| 66 | 66 |
| 67 // FileCache::Observer overrides. | 67 // FileCache::Observer overrides. |
| 68 virtual void OnCachePinned(const std::string& resource_id, | 68 virtual void OnCachePinned(const std::string& resource_id, |
| 69 const std::string& md5) OVERRIDE; | 69 const std::string& md5) OVERRIDE; |
| 70 virtual void OnCacheUnpinned(const std::string& resource_id, | 70 virtual void OnCacheUnpinned(const std::string& resource_id, |
| 71 const std::string& md5) OVERRIDE; | 71 const std::string& md5) OVERRIDE; |
| 72 virtual void OnCacheCommitted(const std::string& resource_id) OVERRIDE; | 72 |
| 73 // Adds a fetch task to the queue. |
| 74 void AddFetchTask(const std::string& resource_id); |
| 75 |
| 76 // Adds an upload task to the queue. |
| 77 void AddUploadTask(const std::string& resource_id); |
| 73 | 78 |
| 74 // Starts processing the backlog (i.e. pinned-but-not-filed files and | 79 // Starts processing the backlog (i.e. pinned-but-not-filed files and |
| 75 // dirty-but-not-uploaded files). Kicks off retrieval of the resource | 80 // dirty-but-not-uploaded files). Kicks off retrieval of the resource |
| 76 // IDs of these files, and then starts the sync loop. | 81 // IDs of these files, and then starts the sync loop. |
| 77 void StartProcessingBacklog(); | 82 void StartProcessingBacklog(); |
| 78 | 83 |
| 79 // Starts checking the existing pinned files to see if these are | 84 // Starts checking the existing pinned files to see if these are |
| 80 // up-to-date. If stale files are detected, the resource IDs of these files | 85 // up-to-date. If stale files are detected, the resource IDs of these files |
| 81 // are added to the queue and the sync loop is started. | 86 // are added to the queue and the sync loop is started. |
| 82 void StartCheckingExistingPinnedFiles(); | 87 void StartCheckingExistingPinnedFiles(); |
| 83 | 88 |
| 84 // Returns the resource IDs in |queue_| for the given sync type. Used only | 89 // Returns the resource IDs in |queue_| for the given sync type. Used only |
| 85 // for testing. | 90 // for testing. |
| 86 std::vector<std::string> GetResourceIdsForTesting(SyncType sync_type) const; | 91 std::vector<std::string> GetResourceIdsForTesting(SyncType sync_type) const; |
| 87 | 92 |
| 88 // Adds the resource ID to the queue. Used only for testing. | |
| 89 void AddResourceIdForTesting(SyncType sync_type, | |
| 90 const std::string& resource_id) { | |
| 91 AddTaskToQueue(sync_type, resource_id); | |
| 92 } | |
| 93 | |
| 94 // Sets a delay for testing. | 93 // Sets a delay for testing. |
| 95 void set_delay_for_testing(const base::TimeDelta& delay) { | 94 void set_delay_for_testing(const base::TimeDelta& delay) { |
| 96 delay_ = delay; | 95 delay_ = delay; |
| 97 } | 96 } |
| 98 | 97 |
| 99 // Starts the sync loop if it's not running. | 98 // Starts the sync loop if it's not running. |
| 100 void StartSyncLoop(); | 99 void StartSyncLoop(); |
| 101 | 100 |
| 102 private: | 101 private: |
| 103 // Adds the given task to the queue. If the same task is queued, remove the | 102 // Adds the given task to the queue. If the same task is queued, remove the |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 // invalidate its weak pointers before any other members are destroyed. | 170 // invalidate its weak pointers before any other members are destroyed. |
| 172 base::WeakPtrFactory<SyncClient> weak_ptr_factory_; | 171 base::WeakPtrFactory<SyncClient> weak_ptr_factory_; |
| 173 | 172 |
| 174 DISALLOW_COPY_AND_ASSIGN(SyncClient); | 173 DISALLOW_COPY_AND_ASSIGN(SyncClient); |
| 175 }; | 174 }; |
| 176 | 175 |
| 177 } // namespace internal | 176 } // namespace internal |
| 178 } // namespace drive | 177 } // namespace drive |
| 179 | 178 |
| 180 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_SYNC_CLIENT_H_ | 179 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_SYNC_CLIENT_H_ |
| OLD | NEW |