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_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 Loading... | |
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 // Adds and removes file watch. | |
180 virtual void AddFileWatch(const FilePath& watch_path) = 0; | |
181 virtual void RemoveFileWatch(const FilePath& watch_path) = 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 Loading... | |
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 AddFileWatch(const FilePath& watch_path) OVERRIDE; | |
zel
2012/05/03 03:41:07
Please add StartUpdates() and StopUpdates() method
hshi
2012/05/03 17:46:35
Done.
| |
409 virtual void RemoveFileWatch(const FilePath& watch_path) 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 Loading... | |
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 // Check for updates on the server. | |
satorux1
2012/05/03 16:49:29
Check -> Checks per our style guide
hshi
2012/05/03 17:46:35
Done.
| |
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 Loading... | |
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 file watches. | |
1347 int num_file_watches_; | |
1348 base::RepeatingTimer<GDataFileSystem> file_watch_timer_; | |
1349 | |
1336 // True if hosted documents should be hidden. | 1350 // True if hosted documents should be hidden. |
1337 bool hide_hosted_docs_; | 1351 bool hide_hosted_docs_; |
1338 | 1352 |
1339 scoped_ptr<PrefChangeRegistrar> pref_registrar_; | 1353 scoped_ptr<PrefChangeRegistrar> pref_registrar_; |
1340 | 1354 |
1341 // WeakPtrFactory and WeakPtr bound to the UI thread. | 1355 // WeakPtrFactory and WeakPtr bound to the UI thread. |
1342 scoped_ptr<base::WeakPtrFactory<GDataFileSystem> > ui_weak_ptr_factory_; | 1356 scoped_ptr<base::WeakPtrFactory<GDataFileSystem> > ui_weak_ptr_factory_; |
1343 base::WeakPtr<GDataFileSystem> ui_weak_ptr_; | 1357 base::WeakPtr<GDataFileSystem> ui_weak_ptr_; |
1344 | 1358 |
1345 ObserverList<Observer> observers_; | 1359 ObserverList<Observer> observers_; |
(...skipping 18 matching lines...) Expand all Loading... | |
1364 }; | 1378 }; |
1365 | 1379 |
1366 // Sets the free disk space getter for testing. | 1380 // Sets the free disk space getter for testing. |
1367 // The existing getter is deleted. | 1381 // The existing getter is deleted. |
1368 void SetFreeDiskSpaceGetterForTesting( | 1382 void SetFreeDiskSpaceGetterForTesting( |
1369 FreeDiskSpaceGetterInterface* getter); | 1383 FreeDiskSpaceGetterInterface* getter); |
1370 | 1384 |
1371 } // namespace gdata | 1385 } // namespace gdata |
1372 | 1386 |
1373 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ | 1387 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
OLD | NEW |