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

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: Bind the ui_weak_ptr_ in a callback to Timer::Start 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 // Starts and stops periodic updates.
180 virtual void StartUpdates() = 0;
satorux1 2012/05/03 18:46:20 Please also explain a bit more about these functio
hshi 2012/05/03 19:09:19 Done. Although I think "Periodic" may be redundant
satorux1 2012/05/03 19:18:36 Agreed.
181 virtual void StopUpdates() = 0;
182
178 // Enum defining origin of a cached file. 183 // Enum defining origin of a cached file.
179 enum CachedFileOrigin { 184 enum CachedFileOrigin {
180 CACHED_FILE_FROM_SERVER = 0, 185 CACHED_FILE_FROM_SERVER = 0,
181 CACHED_FILE_LOCALLY_MODIFIED, 186 CACHED_FILE_LOCALLY_MODIFIED,
182 CACHED_FILE_MOUNTED, 187 CACHED_FILE_MOUNTED,
183 }; 188 };
184 189
185 // Enum defining type of file operation e.g. copy or move, etc. 190 // Enum defining type of file operation e.g. copy or move, etc.
186 // For now, it's used for StoreToCache. 191 // For now, it's used for StoreToCache.
187 enum FileOperationType { 192 enum FileOperationType {
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 public content::NotificationObserver { 398 public content::NotificationObserver {
394 public: 399 public:
395 GDataFileSystem(Profile* profile, 400 GDataFileSystem(Profile* profile,
396 DocumentsServiceInterface* documents_service); 401 DocumentsServiceInterface* documents_service);
397 virtual ~GDataFileSystem(); 402 virtual ~GDataFileSystem();
398 403
399 // GDataFileSystem overrides. 404 // GDataFileSystem overrides.
400 virtual void Initialize() OVERRIDE; 405 virtual void Initialize() OVERRIDE;
401 virtual void AddObserver(Observer* observer) OVERRIDE; 406 virtual void AddObserver(Observer* observer) OVERRIDE;
402 virtual void RemoveObserver(Observer* observer) OVERRIDE; 407 virtual void RemoveObserver(Observer* observer) OVERRIDE;
408 virtual void StartUpdates() OVERRIDE;
409 virtual void StopUpdates() OVERRIDE;
403 virtual void Authenticate(const AuthStatusCallback& callback) OVERRIDE; 410 virtual void Authenticate(const AuthStatusCallback& callback) OVERRIDE;
404 virtual void FindEntryByResourceIdSync(const std::string& resource_id, 411 virtual void FindEntryByResourceIdSync(const std::string& resource_id,
405 FindEntryDelegate* delegate) OVERRIDE; 412 FindEntryDelegate* delegate) OVERRIDE;
406 virtual void TransferFile(const FilePath& local_file_path, 413 virtual void TransferFile(const FilePath& local_file_path,
407 const FilePath& remote_dest_file_path, 414 const FilePath& remote_dest_file_path,
408 const FileOperationCallback& callback) OVERRIDE; 415 const FileOperationCallback& callback) OVERRIDE;
409 virtual void Copy(const FilePath& src_file_path, 416 virtual void Copy(const FilePath& src_file_path,
410 const FilePath& dest_file_path, 417 const FilePath& dest_file_path,
411 const FileOperationCallback& callback) OVERRIDE; 418 const FileOperationCallback& callback) OVERRIDE;
412 virtual void Move(const FilePath& src_file_path, 419 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, 1303 const std::string& md5,
1297 const GetCacheStateCallback& callback); 1304 const GetCacheStateCallback& callback);
1298 void GetAvailableSpaceOnUIThread(const GetAvailableSpaceCallback& callback); 1305 void GetAvailableSpaceOnUIThread(const GetAvailableSpaceCallback& callback);
1299 void SetPinStateOnUIThread(const FilePath& file_path, bool to_pin, 1306 void SetPinStateOnUIThread(const FilePath& file_path, bool to_pin,
1300 const FileOperationCallback& callback); 1307 const FileOperationCallback& callback);
1301 void SetMountedStateOnUIThread( 1308 void SetMountedStateOnUIThread(
1302 const FilePath& file_path, 1309 const FilePath& file_path,
1303 bool to_mount, 1310 bool to_mount,
1304 const SetMountedStateCallback& callback); 1311 const SetMountedStateCallback& callback);
1305 1312
1313 // Checks for updates on the server.
1314 void CheckForUpdates();
1315
1306 scoped_ptr<GDataRootDirectory> root_; 1316 scoped_ptr<GDataRootDirectory> root_;
1307 1317
1308 // This guards regular states. 1318 // This guards regular states.
1309 base::Lock lock_; 1319 base::Lock lock_;
1310 1320
1311 // The profile hosts the GDataFileSystem via GDataSystemService. 1321 // The profile hosts the GDataFileSystem via GDataSystemService.
1312 Profile* profile_; 1322 Profile* profile_;
1313 1323
1314 // The document service for the GDataFileSystem. 1324 // The document service for the GDataFileSystem.
1315 scoped_ptr<DocumentsServiceInterface> documents_service_; 1325 scoped_ptr<DocumentsServiceInterface> documents_service_;
(...skipping 10 matching lines...) Expand all
1326 scoped_ptr<base::WaitableEvent> on_io_completed_; 1336 scoped_ptr<base::WaitableEvent> on_io_completed_;
1327 1337
1328 // True if cache initialization has started, is in progress or has completed, 1338 // True if cache initialization has started, is in progress or has completed,
1329 // we only want to initialize cache once. 1339 // we only want to initialize cache once.
1330 bool cache_initialization_started_; 1340 bool cache_initialization_started_;
1331 1341
1332 // Number of pending tasks on the blocking thread pool. 1342 // Number of pending tasks on the blocking thread pool.
1333 int num_pending_tasks_; 1343 int num_pending_tasks_;
1334 base::Lock num_pending_tasks_lock_; 1344 base::Lock num_pending_tasks_lock_;
1335 1345
1346 // Number of active update requests.
1347 int num_update_requests_;
1348
1349 // Periodic timer for checking updates.
1350 base::RepeatingTimer<GDataFileSystem> update_timer_;
1351
1336 // True if hosted documents should be hidden. 1352 // True if hosted documents should be hidden.
1337 bool hide_hosted_docs_; 1353 bool hide_hosted_docs_;
1338 1354
1339 scoped_ptr<PrefChangeRegistrar> pref_registrar_; 1355 scoped_ptr<PrefChangeRegistrar> pref_registrar_;
1340 1356
1341 // WeakPtrFactory and WeakPtr bound to the UI thread. 1357 // WeakPtrFactory and WeakPtr bound to the UI thread.
1342 scoped_ptr<base::WeakPtrFactory<GDataFileSystem> > ui_weak_ptr_factory_; 1358 scoped_ptr<base::WeakPtrFactory<GDataFileSystem> > ui_weak_ptr_factory_;
1343 base::WeakPtr<GDataFileSystem> ui_weak_ptr_; 1359 base::WeakPtr<GDataFileSystem> ui_weak_ptr_;
1344 1360
1345 ObserverList<Observer> observers_; 1361 ObserverList<Observer> observers_;
(...skipping 18 matching lines...) Expand all
1364 }; 1380 };
1365 1381
1366 // Sets the free disk space getter for testing. 1382 // Sets the free disk space getter for testing.
1367 // The existing getter is deleted. 1383 // The existing getter is deleted.
1368 void SetFreeDiskSpaceGetterForTesting( 1384 void SetFreeDiskSpaceGetterForTesting(
1369 FreeDiskSpaceGetterInterface* getter); 1385 FreeDiskSpaceGetterInterface* getter);
1370 1386
1371 } // namespace gdata 1387 } // namespace gdata
1372 1388
1373 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ 1389 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698