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

Side by Side Diff: chrome/browser/sync_file_system/drive_file_sync_client.h

Issue 11419281: DriveFileSyncService listens to OnNetworkConnected event to restart synchronization (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 (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_FILE_SYNC_CLIENT_H_ 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_CLIENT_H_
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_CLIENT_H_ 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_CLIENT_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback_forward.h" 10 #include "base/callback_forward.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "base/threading/non_thread_safe.h" 14 #include "base/threading/non_thread_safe.h"
15 #include "chrome/browser/google_apis/drive_service_interface.h" 15 #include "chrome/browser/google_apis/drive_service_interface.h"
16 #include "chrome/browser/google_apis/drive_upload_error.h" 16 #include "chrome/browser/google_apis/drive_upload_error.h"
17 #include "chrome/browser/google_apis/gdata_errorcode.h" 17 #include "chrome/browser/google_apis/gdata_errorcode.h"
18 #include "chrome/browser/google_apis/gdata_wapi_parser.h" 18 #include "chrome/browser/google_apis/gdata_wapi_parser.h"
19 #include "net/base/network_change_notifier.h"
19 20
20 class GURL; 21 class GURL;
21 class Profile; 22 class Profile;
22 23
23 namespace google_apis { 24 namespace google_apis {
24 class DriveUploaderInterface; 25 class DriveUploaderInterface;
25 } 26 }
26 27
27 namespace sync_file_system { 28 namespace sync_file_system {
28 29
29 class DriveFileSyncClientObserver { 30 class DriveFileSyncClientObserver {
30 public: 31 public:
31 DriveFileSyncClientObserver() {} 32 DriveFileSyncClientObserver() {}
32 virtual ~DriveFileSyncClientObserver() {} 33 virtual ~DriveFileSyncClientObserver() {}
33 virtual void OnAuthenticated() = 0; 34 virtual void OnAuthenticated() = 0;
35 virtual void OnNetworkConnected() = 0;
34 36
35 private: 37 private:
36 DISALLOW_COPY_AND_ASSIGN(DriveFileSyncClientObserver); 38 DISALLOW_COPY_AND_ASSIGN(DriveFileSyncClientObserver);
37 }; 39 };
38 40
39 // This class is responsible for talking to the Drive service to get and put 41 // This class is responsible for talking to the Drive service to get and put
40 // Drive directories, files and metadata. 42 // Drive directories, files and metadata.
41 // This class is owned by DriveFileSyncService. 43 // This class is owned by DriveFileSyncService.
42 class DriveFileSyncClient : public google_apis::DriveServiceObserver, 44 class DriveFileSyncClient
43 public base::NonThreadSafe, 45 : public google_apis::DriveServiceObserver,
44 public base::SupportsWeakPtr<DriveFileSyncClient> { 46 public net::NetworkChangeNotifier::ConnectionTypeObserver,
47 public base::NonThreadSafe,
48 public base::SupportsWeakPtr<DriveFileSyncClient> {
45 public: 49 public:
46 typedef base::Callback<void(google_apis::GDataErrorCode error)> 50 typedef base::Callback<void(google_apis::GDataErrorCode error)>
47 GDataErrorCallback; 51 GDataErrorCallback;
48 typedef base::Callback<void(google_apis::GDataErrorCode error, 52 typedef base::Callback<void(google_apis::GDataErrorCode error,
49 const std::string& file_md5)> 53 const std::string& file_md5)>
50 DownloadFileCallback; 54 DownloadFileCallback;
51 typedef base::Callback<void(google_apis::GDataErrorCode error, 55 typedef base::Callback<void(google_apis::GDataErrorCode error,
52 const std::string& resource_id, 56 const std::string& resource_id,
53 const std::string& file_md5)> 57 const std::string& file_md5)>
54 UploadFileCallback; 58 UploadFileCallback;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // deleted from Drive. If |remote_file_md5| is different from the actual 165 // deleted from Drive. If |remote_file_md5| is different from the actual
162 // value, cancels the deletion and invokes |callback| with 166 // value, cancels the deletion and invokes |callback| with
163 // GDataErrorCode::HTTP_CONFLICT immediately. 167 // GDataErrorCode::HTTP_CONFLICT immediately.
164 void DeleteFile(const std::string& resource_id, 168 void DeleteFile(const std::string& resource_id,
165 const std::string& remote_file_md5, 169 const std::string& remote_file_md5,
166 const GDataErrorCallback& callback); 170 const GDataErrorCallback& callback);
167 171
168 // DriveServiceObserver overrides. 172 // DriveServiceObserver overrides.
169 virtual void OnReadyToPerformOperations() OVERRIDE; 173 virtual void OnReadyToPerformOperations() OVERRIDE;
170 174
175 // ConnectionTypeObserver overrides.
176 virtual void OnConnectionTypeChanged(
177 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE;
178
171 private: 179 private:
172 friend class DriveFileSyncClientTest; 180 friend class DriveFileSyncClientTest;
173 friend class DriveFileSyncServiceTest; 181 friend class DriveFileSyncServiceTest;
174 182
175 // Constructor for test use. 183 // Constructor for test use.
176 DriveFileSyncClient( 184 DriveFileSyncClient(
177 Profile* profile, 185 Profile* profile,
178 scoped_ptr<google_apis::DriveServiceInterface> drive_service, 186 scoped_ptr<google_apis::DriveServiceInterface> drive_service,
179 scoped_ptr<google_apis::DriveUploaderInterface> drive_uploader); 187 scoped_ptr<google_apis::DriveUploaderInterface> drive_uploader);
180 188
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 scoped_ptr<google_apis::DriveUploaderInterface> drive_uploader_; 265 scoped_ptr<google_apis::DriveUploaderInterface> drive_uploader_;
258 266
259 ObserverList<DriveFileSyncClientObserver> observers_; 267 ObserverList<DriveFileSyncClientObserver> observers_;
260 268
261 DISALLOW_COPY_AND_ASSIGN(DriveFileSyncClient); 269 DISALLOW_COPY_AND_ASSIGN(DriveFileSyncClient);
262 }; 270 };
263 271
264 } // namespace sync_file_system 272 } // namespace sync_file_system
265 273
266 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_CLIENT_H_ 274 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698