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

Side by Side Diff: chrome/browser/chromeos/drive/drive_sync_client.h

Issue 14348013: Remove legacy in DriveSyncClient. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fix + alpha Created 7 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/drive_sync_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_DRIVE_SYNC_CLIENT_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_SYNC_CLIENT_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_SYNC_CLIENT_H_ 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_SYNC_CLIENT_H_
7 7
8 #include <deque> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback_forward.h"
13 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
14 #include "base/time.h" 13 #include "base/time.h"
15 #include "chrome/browser/chromeos/drive/drive_cache.h"
16 #include "chrome/browser/chromeos/drive/drive_cache_observer.h" 14 #include "chrome/browser/chromeos/drive/drive_cache_observer.h"
17 #include "chrome/browser/chromeos/drive/drive_file_system_observer.h" 15 #include "chrome/browser/chromeos/drive/drive_file_system_observer.h"
18 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h" 16 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h"
19 #include "net/base/network_change_notifier.h"
20
21 class Profile;
22 class PrefChangeRegistrar;
23 17
24 namespace drive { 18 namespace drive {
25 19
20 class DriveCache;
21 class DriveCacheEntry;
26 class DriveEntryProto; 22 class DriveEntryProto;
27 class DriveFileSystemInterface; 23 class DriveFileSystemInterface;
28 class DrivePrefetcher;
29 24
30 // The DriveSyncClient is used to synchronize pinned files on Drive and the 25 // The DriveSyncClient is used to synchronize pinned files on Drive and the
31 // cache on the local drive. The sync client works as follows. 26 // cache on the local drive. The sync client works as follows.
32 // 27 //
33 // When the user pins files on Drive, this client is notified about the files 28 // When the user pins files on Drive, this client is notified about the files
34 // that get pinned, and queues tasks and starts fetching these files in the 29 // that get pinned, and queues tasks and starts fetching these files in the
35 // background. 30 // background.
36 // 31 //
37 // When the user unpins files on Drive, this client is notified about the 32 // When the user unpins files on Drive, this client is notified about the
38 // files that get unpinned, cancels tasks if these are still in the queue. 33 // files that get unpinned, cancels tasks if these are still in the queue.
39 // 34 //
40 // If the user logs out before fetching of the pinned files is complete, this 35 // If the user logs out before fetching of the pinned files is complete, this
41 // client resumes fetching operations next time the user logs in, based on 36 // client resumes fetching operations next time the user logs in, based on
42 // the states left in the cache. 37 // the states left in the cache.
43 class DriveSyncClient 38 class DriveSyncClient : public DriveFileSystemObserver,
44 : public DriveFileSystemObserver, 39 public DriveCacheObserver {
45 public DriveCacheObserver {
46 public: 40 public:
47 // Types of sync tasks. 41 // Types of sync tasks.
48 enum SyncType { 42 enum SyncType {
49 FETCH, // Fetch a file from the Drive server. 43 FETCH, // Fetch a file from the Drive server.
50 UPLOAD, // Upload a file to the Drive server. 44 UPLOAD, // Upload a file to the Drive server.
51 }; 45 };
52 46
53 // |profile| is used to access user preferences. 47 DriveSyncClient(DriveFileSystemInterface* file_system, DriveCache* cache);
54 // |file_system| is used access the
55 // cache (ex. store a file to the cache when the file is downloaded).
56 DriveSyncClient(Profile* profile,
57 DriveFileSystemInterface* file_system,
58 DriveCache* cache);
59 virtual ~DriveSyncClient(); 48 virtual ~DriveSyncClient();
60 49
61 // Initializes the DriveSyncClient.
62 void Initialize();
63
64 // DriveFileSystemInterface::Observer overrides. 50 // DriveFileSystemInterface::Observer overrides.
65 virtual void OnInitialLoadFinished() OVERRIDE; 51 virtual void OnInitialLoadFinished() OVERRIDE;
66 virtual void OnFeedFromServerLoaded() OVERRIDE; 52 virtual void OnFeedFromServerLoaded() OVERRIDE;
67 53
68 // DriveCache::Observer overrides. 54 // DriveCache::Observer overrides.
69 virtual void OnCachePinned(const std::string& resource_id, 55 virtual void OnCachePinned(const std::string& resource_id,
70 const std::string& md5) OVERRIDE; 56 const std::string& md5) OVERRIDE;
71 virtual void OnCacheUnpinned(const std::string& resource_id, 57 virtual void OnCacheUnpinned(const std::string& resource_id,
72 const std::string& md5) OVERRIDE; 58 const std::string& md5) OVERRIDE;
73 virtual void OnCacheCommitted(const std::string& resource_id) OVERRIDE; 59 virtual void OnCacheCommitted(const std::string& resource_id) OVERRIDE;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 DriveFileError error, 129 DriveFileError error,
144 const base::FilePath& local_path, 130 const base::FilePath& local_path,
145 const std::string& ununsed_mime_type, 131 const std::string& ununsed_mime_type,
146 DriveFileType file_type); 132 DriveFileType file_type);
147 133
148 // Called when the file for |resource_id| is uploaded. 134 // Called when the file for |resource_id| is uploaded.
149 // Calls DoSyncLoop() to go back to the sync loop. 135 // Calls DoSyncLoop() to go back to the sync loop.
150 void OnUploadFileComplete(const std::string& resource_id, 136 void OnUploadFileComplete(const std::string& resource_id,
151 DriveFileError error); 137 DriveFileError error);
152 138
153 Profile* profile_;
154 DriveFileSystemInterface* file_system_; // Owned by DriveSystemService. 139 DriveFileSystemInterface* file_system_; // Owned by DriveSystemService.
155 DriveCache* cache_; // Owned by DriveSystemService. 140 DriveCache* cache_; // Owned by DriveSystemService.
156 141
157 // List of the resource ids of resources which have a fetch task created. 142 // List of the resource ids of resources which have a fetch task created.
158 std::set<std::string> fetch_list_; 143 std::set<std::string> fetch_list_;
159 144
160 // List of the resource ids of resources which have a upload task created. 145 // List of the resource ids of resources which have a upload task created.
161 std::set<std::string> upload_list_; 146 std::set<std::string> upload_list_;
162 147
163 // Fetch tasks which have been created, but not started yet. If they are 148 // Fetch tasks which have been created, but not started yet. If they are
164 // removed before starting, they will be cancelled. 149 // removed before starting, they will be cancelled.
165 std::set<std::string> pending_fetch_list_; 150 std::set<std::string> pending_fetch_list_;
166 151
167 // The delay is used for delaying processing SyncTasks in DoSyncLoop(). 152 // The delay is used for delaying processing SyncTasks in DoSyncLoop().
168 base::TimeDelta delay_; 153 base::TimeDelta delay_;
169 154
170 // Note: This should remain the last member so it'll be destroyed and 155 // Note: This should remain the last member so it'll be destroyed and
171 // invalidate its weak pointers before any other members are destroyed. 156 // invalidate its weak pointers before any other members are destroyed.
172 base::WeakPtrFactory<DriveSyncClient> weak_ptr_factory_; 157 base::WeakPtrFactory<DriveSyncClient> weak_ptr_factory_;
173 158
174 DISALLOW_COPY_AND_ASSIGN(DriveSyncClient); 159 DISALLOW_COPY_AND_ASSIGN(DriveSyncClient);
175 }; 160 };
176 161
177 } // namespace drive 162 } // namespace drive
178 163
179 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_SYNC_CLIENT_H_ 164 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_SYNC_CLIENT_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/drive_sync_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698