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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_file_system.h

Issue 10352004: gdata: Implement periodic file system update checks. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Use base timer class and other miscellaneous fixes Created 8 years, 7 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
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_GDATA_GDATA_FILE_SYSTEM_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_
6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_
7 #pragma once 7 #pragma once
8 8
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 10
11 #include <map> 11 #include <map>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/singleton.h" 17 #include "base/memory/singleton.h"
18 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
19 #include "base/message_loop.h" 19 #include "base/message_loop.h"
20 #include "base/platform_file.h" 20 #include "base/platform_file.h"
21 #include "base/timer.h"
21 #include "base/synchronization/lock.h" 22 #include "base/synchronization/lock.h"
22 #include "base/threading/sequenced_worker_pool.h" 23 #include "base/threading/sequenced_worker_pool.h"
23 #include "chrome/browser/chromeos/gdata/find_entry_delegate.h" 24 #include "chrome/browser/chromeos/gdata/find_entry_delegate.h"
24 #include "chrome/browser/chromeos/gdata/gdata_documents_service.h" 25 #include "chrome/browser/chromeos/gdata/gdata_documents_service.h"
25 #include "chrome/browser/chromeos/gdata/gdata_files.h" 26 #include "chrome/browser/chromeos/gdata/gdata_files.h"
26 #include "chrome/browser/chromeos/gdata/gdata_operation_registry.h" 27 #include "chrome/browser/chromeos/gdata/gdata_operation_registry.h"
27 #include "chrome/browser/chromeos/gdata/gdata_params.h" 28 #include "chrome/browser/chromeos/gdata/gdata_params.h"
28 #include "chrome/browser/chromeos/gdata/gdata_parser.h" 29 #include "chrome/browser/chromeos/gdata/gdata_parser.h"
29 #include "chrome/browser/chromeos/gdata/gdata_uploader.h" 30 #include "chrome/browser/chromeos/gdata/gdata_uploader.h"
30 #include "chrome/browser/prefs/pref_change_registrar.h" 31 #include "chrome/browser/prefs/pref_change_registrar.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 }; 169 };
169 170
170 // Initializes the object. This function should be called before any 171 // Initializes the object. This function should be called before any
171 // other functions. 172 // other functions.
172 virtual void Initialize() = 0; 173 virtual void Initialize() = 0;
173 174
174 // Adds and removes the observer. 175 // Adds and removes the observer.
175 virtual void AddObserver(Observer* observer) = 0; 176 virtual void AddObserver(Observer* observer) = 0;
176 virtual void RemoveObserver(Observer* observer) = 0; 177 virtual void RemoveObserver(Observer* observer) = 0;
177 178
179 // Requests to start periodic updates.
180 // This function only starts periodic updates if it is not yet started.
181 virtual void RequestStartUpdates() = 0;
182
183 // Requests to stop periodic updates.
184 // This function only stops periodic updates if the number of outstanding
185 // update requests reaches zero.
186 virtual void RequestStopUpdates() = 0;
187
178 // Enum defining origin of a cached file. 188 // Enum defining origin of a cached file.
179 enum CachedFileOrigin { 189 enum CachedFileOrigin {
180 CACHED_FILE_FROM_SERVER = 0, 190 CACHED_FILE_FROM_SERVER = 0,
181 CACHED_FILE_LOCALLY_MODIFIED, 191 CACHED_FILE_LOCALLY_MODIFIED,
182 CACHED_FILE_MOUNTED, 192 CACHED_FILE_MOUNTED,
183 }; 193 };
184 194
185 // Enum defining type of file operation e.g. copy or move, etc. 195 // Enum defining type of file operation e.g. copy or move, etc.
186 // For now, it's used for StoreToCache. 196 // For now, it's used for StoreToCache.
187 enum FileOperationType { 197 enum FileOperationType {
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 public content::NotificationObserver { 403 public content::NotificationObserver {
394 public: 404 public:
395 GDataFileSystem(Profile* profile, 405 GDataFileSystem(Profile* profile,
396 DocumentsServiceInterface* documents_service); 406 DocumentsServiceInterface* documents_service);
397 virtual ~GDataFileSystem(); 407 virtual ~GDataFileSystem();
398 408
399 // GDataFileSystem overrides. 409 // GDataFileSystem overrides.
400 virtual void Initialize() OVERRIDE; 410 virtual void Initialize() OVERRIDE;
401 virtual void AddObserver(Observer* observer) OVERRIDE; 411 virtual void AddObserver(Observer* observer) OVERRIDE;
402 virtual void RemoveObserver(Observer* observer) OVERRIDE; 412 virtual void RemoveObserver(Observer* observer) OVERRIDE;
413 virtual void RequestStartUpdates() OVERRIDE;
414 virtual void RequestStopUpdates() OVERRIDE;
403 virtual void Authenticate(const AuthStatusCallback& callback) OVERRIDE; 415 virtual void Authenticate(const AuthStatusCallback& callback) OVERRIDE;
404 virtual void FindEntryByResourceIdSync(const std::string& resource_id, 416 virtual void FindEntryByResourceIdSync(const std::string& resource_id,
405 FindEntryDelegate* delegate) OVERRIDE; 417 FindEntryDelegate* delegate) OVERRIDE;
406 virtual void TransferFile(const FilePath& local_file_path, 418 virtual void TransferFile(const FilePath& local_file_path,
407 const FilePath& remote_dest_file_path, 419 const FilePath& remote_dest_file_path,
408 const FileOperationCallback& callback) OVERRIDE; 420 const FileOperationCallback& callback) OVERRIDE;
409 virtual void Copy(const FilePath& src_file_path, 421 virtual void Copy(const FilePath& src_file_path,
410 const FilePath& dest_file_path, 422 const FilePath& dest_file_path,
411 const FileOperationCallback& callback) OVERRIDE; 423 const FileOperationCallback& callback) OVERRIDE;
412 virtual void Move(const FilePath& src_file_path, 424 virtual void Move(const FilePath& src_file_path,
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 const std::string& md5, 1308 const std::string& md5,
1297 const GetCacheStateCallback& callback); 1309 const GetCacheStateCallback& callback);
1298 void GetAvailableSpaceOnUIThread(const GetAvailableSpaceCallback& callback); 1310 void GetAvailableSpaceOnUIThread(const GetAvailableSpaceCallback& callback);
1299 void SetPinStateOnUIThread(const FilePath& file_path, bool to_pin, 1311 void SetPinStateOnUIThread(const FilePath& file_path, bool to_pin,
1300 const FileOperationCallback& callback); 1312 const FileOperationCallback& callback);
1301 void SetMountedStateOnUIThread( 1313 void SetMountedStateOnUIThread(
1302 const FilePath& file_path, 1314 const FilePath& file_path,
1303 bool to_mount, 1315 bool to_mount,
1304 const SetMountedStateCallback& callback); 1316 const SetMountedStateCallback& callback);
1305 1317
1318 // Checks for updates on the server.
1319 void CheckForUpdates();
1320
1306 scoped_ptr<GDataRootDirectory> root_; 1321 scoped_ptr<GDataRootDirectory> root_;
1307 1322
1308 // This guards regular states. 1323 // This guards regular states.
1309 base::Lock lock_; 1324 base::Lock lock_;
1310 1325
1311 // The profile hosts the GDataFileSystem via GDataSystemService. 1326 // The profile hosts the GDataFileSystem via GDataSystemService.
1312 Profile* profile_; 1327 Profile* profile_;
1313 1328
1314 // The document service for the GDataFileSystem. 1329 // The document service for the GDataFileSystem.
1315 scoped_ptr<DocumentsServiceInterface> documents_service_; 1330 scoped_ptr<DocumentsServiceInterface> documents_service_;
(...skipping 10 matching lines...) Expand all
1326 scoped_ptr<base::WaitableEvent> on_io_completed_; 1341 scoped_ptr<base::WaitableEvent> on_io_completed_;
1327 1342
1328 // True if cache initialization has started, is in progress or has completed, 1343 // True if cache initialization has started, is in progress or has completed,
1329 // we only want to initialize cache once. 1344 // we only want to initialize cache once.
1330 bool cache_initialization_started_; 1345 bool cache_initialization_started_;
1331 1346
1332 // Number of pending tasks on the blocking thread pool. 1347 // Number of pending tasks on the blocking thread pool.
1333 int num_pending_tasks_; 1348 int num_pending_tasks_;
1334 base::Lock num_pending_tasks_lock_; 1349 base::Lock num_pending_tasks_lock_;
1335 1350
1351 // Number of active update requests.
1352 int num_update_requests_;
1353
1354 // Periodic timer for checking updates.
1355 base::Timer update_timer_;
1356
1336 // True if hosted documents should be hidden. 1357 // True if hosted documents should be hidden.
1337 bool hide_hosted_docs_; 1358 bool hide_hosted_docs_;
1338 1359
1339 scoped_ptr<PrefChangeRegistrar> pref_registrar_; 1360 scoped_ptr<PrefChangeRegistrar> pref_registrar_;
1340 1361
1341 // WeakPtrFactory and WeakPtr bound to the UI thread. 1362 // WeakPtrFactory and WeakPtr bound to the UI thread.
1342 scoped_ptr<base::WeakPtrFactory<GDataFileSystem> > ui_weak_ptr_factory_; 1363 scoped_ptr<base::WeakPtrFactory<GDataFileSystem> > ui_weak_ptr_factory_;
1343 base::WeakPtr<GDataFileSystem> ui_weak_ptr_; 1364 base::WeakPtr<GDataFileSystem> ui_weak_ptr_;
1344 1365
1345 ObserverList<Observer> observers_; 1366 ObserverList<Observer> observers_;
(...skipping 18 matching lines...) Expand all
1364 }; 1385 };
1365 1386
1366 // Sets the free disk space getter for testing. 1387 // Sets the free disk space getter for testing.
1367 // The existing getter is deleted. 1388 // The existing getter is deleted.
1368 void SetFreeDiskSpaceGetterForTesting( 1389 void SetFreeDiskSpaceGetterForTesting(
1369 FreeDiskSpaceGetterInterface* getter); 1390 FreeDiskSpaceGetterInterface* getter);
1370 1391
1371 } // namespace gdata 1392 } // namespace gdata
1372 1393
1373 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ 1394 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698