Chromium Code Reviews| 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 <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 16 #include "base/platform_file.h" | 16 #include "base/platform_file.h" |
| 17 #include "base/timer.h" | 17 #include "base/timer.h" |
| 18 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
| 19 #include "base/threading/sequenced_worker_pool.h" | 19 #include "base/threading/sequenced_worker_pool.h" |
| 20 #include "chrome/browser/chromeos/gdata/find_entry_callback.h" | |
| 21 #include "chrome/browser/chromeos/gdata/gdata_cache.h" | 20 #include "chrome/browser/chromeos/gdata/gdata_cache.h" |
| 22 #include "chrome/browser/chromeos/gdata/gdata_files.h" | 21 #include "chrome/browser/chromeos/gdata/gdata_files.h" |
| 23 #include "chrome/browser/prefs/pref_change_registrar.h" | 22 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 24 #include "content/public/browser/notification_observer.h" | 23 #include "content/public/browser/notification_observer.h" |
| 25 | 24 |
| 26 namespace base { | 25 namespace base { |
| 27 class WaitableEvent; | 26 class WaitableEvent; |
| 28 } | 27 } |
| 29 | 28 |
| 30 namespace gdata { | 29 namespace gdata { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 | 106 |
| 108 // Used by GDataFileSystem::GetDocumentResourceIdOnBlockingPool to return | 107 // Used by GDataFileSystem::GetDocumentResourceIdOnBlockingPool to return |
| 109 // the resource ID read from a document JSON file on the local file system. | 108 // the resource ID read from a document JSON file on the local file system. |
| 110 typedef base::Callback<void(const std::string& resource_id)> | 109 typedef base::Callback<void(const std::string& resource_id)> |
| 111 GetDocumentResourceIdCallback; | 110 GetDocumentResourceIdCallback; |
| 112 | 111 |
| 113 // Callback for GetCacheState operation. | 112 // Callback for GetCacheState operation. |
| 114 typedef base::Callback<void(base::PlatformFileError error, | 113 typedef base::Callback<void(base::PlatformFileError error, |
| 115 int cache_state)> GetCacheStateCallback; | 114 int cache_state)> GetCacheStateCallback; |
| 116 | 115 |
| 116 // Callback used to find a directory element for file system updates. | |
| 117 void ReadOnlyFindEntryCallback(GDataEntry** out, | |
|
achuithb
2012/06/11 21:48:41
Is this only used in 2 places now? GDataFileSystem
hshi1
2012/06/11 22:42:21
Yes this is only called in GDataFileSystem::GetGDa
achuithb
2012/06/11 22:56:11
Both the functions in the unit test and GDataFileS
hshi1
2012/06/11 23:17:52
I see, thanks for the explanation! I've removed th
| |
| 118 base::PlatformFileError error, | |
| 119 GDataEntry* entry); | |
| 120 | |
| 117 // GData file system abstraction layer. | 121 // GData file system abstraction layer. |
| 118 // The interface is defined to make GDataFileSystem mockable. | 122 // The interface is defined to make GDataFileSystem mockable. |
| 119 class GDataFileSystemInterface { | 123 class GDataFileSystemInterface { |
| 120 public: | 124 public: |
| 121 virtual ~GDataFileSystemInterface() {} | 125 virtual ~GDataFileSystemInterface() {} |
| 122 | 126 |
| 123 // Used to notify events on the file system. | 127 // Used to notify events on the file system. |
| 124 // All events are notified on UI thread. | 128 // All events are notified on UI thread. |
| 125 class Observer { | 129 class Observer { |
| 126 public: | 130 public: |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 }; | 180 }; |
| 177 | 181 |
| 178 // Authenticates the user by fetching the auth token as | 182 // Authenticates the user by fetching the auth token as |
| 179 // needed. |callback| will be run with the error code and the auth | 183 // needed. |callback| will be run with the error code and the auth |
| 180 // token, on the thread this function is run. | 184 // token, on the thread this function is run. |
| 181 // | 185 // |
| 182 // Must be called on UI thread. | 186 // Must be called on UI thread. |
| 183 virtual void Authenticate(const AuthStatusCallback& callback) = 0; | 187 virtual void Authenticate(const AuthStatusCallback& callback) = 0; |
| 184 | 188 |
| 185 // Finds file info by using |resource_id|. This call does not initiate | 189 // Finds file info by using |resource_id|. This call does not initiate |
| 186 // content refreshing and will invoke one of |callback| methods directly as | 190 // content refreshing. |
| 187 // it executes. | |
| 188 // | 191 // |
| 189 // Can be called from UI/IO thread. |callback| is run on the calling thread | 192 // Can be called from UI/IO thread. |callback| is run on the calling thread. |
|
achuithb
2012/06/11 21:48:41
This is not true, right? |callback| is run on the
hshi1
2012/06/11 22:42:21
Actually this IS true and |callback| is run on the
achuithb
2012/06/11 22:56:11
Ah, ok. Didn't realize that's what CreateRelayCall
| |
| 190 // synchronously. | 193 virtual void FindEntryByResourceId(const std::string& resource_id, |
| 191 virtual void FindEntryByResourceIdSync(const std::string& resource_id, | 194 const FindEntryCallback& callback) = 0; |
| 192 const FindEntryCallback& callback) = 0; | |
| 193 | 195 |
| 194 // Initiates transfer of |remote_src_file_path| to |local_dest_file_path|. | 196 // Initiates transfer of |remote_src_file_path| to |local_dest_file_path|. |
| 195 // |remote_src_file_path| is the virtual source path on the gdata file system. | 197 // |remote_src_file_path| is the virtual source path on the gdata file system. |
| 196 // |local_dest_file_path| is the destination path on the local file system. | 198 // |local_dest_file_path| is the destination path on the local file system. |
| 197 // | 199 // |
| 198 // Must be called from *UI* thread. |callback| is run on the calling thread. | 200 // Must be called from *UI* thread. |callback| is run on the calling thread. |
| 199 virtual void TransferFileFromRemoteToLocal( | 201 virtual void TransferFileFromRemoteToLocal( |
| 200 const FilePath& remote_src_file_path, | 202 const FilePath& remote_src_file_path, |
| 201 const FilePath& local_dest_file_path, | 203 const FilePath& local_dest_file_path, |
| 202 const FileOperationCallback& callback) = 0; | 204 const FileOperationCallback& callback) = 0; |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 427 virtual ~GDataFileSystem(); | 429 virtual ~GDataFileSystem(); |
| 428 | 430 |
| 429 // GDataFileSystem overrides. | 431 // GDataFileSystem overrides. |
| 430 virtual void Initialize() OVERRIDE; | 432 virtual void Initialize() OVERRIDE; |
| 431 virtual void AddObserver(Observer* observer) OVERRIDE; | 433 virtual void AddObserver(Observer* observer) OVERRIDE; |
| 432 virtual void RemoveObserver(Observer* observer) OVERRIDE; | 434 virtual void RemoveObserver(Observer* observer) OVERRIDE; |
| 433 virtual void StartUpdates() OVERRIDE; | 435 virtual void StartUpdates() OVERRIDE; |
| 434 virtual void StopUpdates() OVERRIDE; | 436 virtual void StopUpdates() OVERRIDE; |
| 435 virtual void CheckForUpdates() OVERRIDE; | 437 virtual void CheckForUpdates() OVERRIDE; |
| 436 virtual void Authenticate(const AuthStatusCallback& callback) OVERRIDE; | 438 virtual void Authenticate(const AuthStatusCallback& callback) OVERRIDE; |
| 437 virtual void FindEntryByResourceIdSync( | 439 virtual void FindEntryByResourceId( |
| 438 const std::string& resource_id, | 440 const std::string& resource_id, |
| 439 const FindEntryCallback& callback) OVERRIDE; | 441 const FindEntryCallback& callback) OVERRIDE; |
| 440 virtual void SearchAsync(const std::string& search_query, | 442 virtual void SearchAsync(const std::string& search_query, |
| 441 const ReadDirectoryCallback& callback) OVERRIDE; | 443 const ReadDirectoryCallback& callback) OVERRIDE; |
| 442 virtual void TransferFileFromRemoteToLocal( | 444 virtual void TransferFileFromRemoteToLocal( |
| 443 const FilePath& remote_src_file_path, | 445 const FilePath& remote_src_file_path, |
| 444 const FilePath& local_dest_file_path, | 446 const FilePath& local_dest_file_path, |
| 445 const FileOperationCallback& callback) OVERRIDE; | 447 const FileOperationCallback& callback) OVERRIDE; |
| 446 virtual void TransferFileFromLocalToRemote( | 448 virtual void TransferFileFromLocalToRemote( |
| 447 const FilePath& local_src_file_path, | 449 const FilePath& local_src_file_path, |
| (...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1452 void GetFileByResourceIdOnUIThread( | 1454 void GetFileByResourceIdOnUIThread( |
| 1453 const std::string& resource_id, | 1455 const std::string& resource_id, |
| 1454 const GetFileCallback& get_file_callback, | 1456 const GetFileCallback& get_file_callback, |
| 1455 const GetDownloadDataCallback& get_download_data_callback); | 1457 const GetDownloadDataCallback& get_download_data_callback); |
| 1456 void GetEntryInfoByPathAsyncOnUIThread( | 1458 void GetEntryInfoByPathAsyncOnUIThread( |
| 1457 const FilePath& file_path, | 1459 const FilePath& file_path, |
| 1458 const GetEntryInfoCallback& callback); | 1460 const GetEntryInfoCallback& callback); |
| 1459 void GetFileInfoByPathAsyncOnUIThread( | 1461 void GetFileInfoByPathAsyncOnUIThread( |
| 1460 const FilePath& file_path, | 1462 const FilePath& file_path, |
| 1461 const GetFileInfoCallback& callback); | 1463 const GetFileInfoCallback& callback); |
| 1464 void FindEntryByResourceIdOnUIThread(const std::string& resource_id, | |
| 1465 const FindEntryCallback& callback); | |
| 1462 void ReadDirectoryByPathAsyncOnUIThread( | 1466 void ReadDirectoryByPathAsyncOnUIThread( |
| 1463 const FilePath& file_path, | 1467 const FilePath& file_path, |
| 1464 const ReadDirectoryCallback& callback); | 1468 const ReadDirectoryCallback& callback); |
| 1465 void RequestDirectoryRefreshOnUIThread( | 1469 void RequestDirectoryRefreshOnUIThread( |
| 1466 const FilePath& file_path); | 1470 const FilePath& file_path); |
| 1467 void OnRequestDirectoryRefresh(GetDocumentsParams* params, | 1471 void OnRequestDirectoryRefresh(GetDocumentsParams* params, |
| 1468 base::PlatformFileError error); | 1472 base::PlatformFileError error); |
| 1469 void GetCacheStateOnUIThread(const std::string& resource_id, | 1473 void GetCacheStateOnUIThread(const std::string& resource_id, |
| 1470 const std::string& md5, | 1474 const std::string& md5, |
| 1471 const GetCacheStateCallback& callback); | 1475 const GetCacheStateCallback& callback); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1535 }; | 1539 }; |
| 1536 | 1540 |
| 1537 // Sets the free disk space getter for testing. | 1541 // Sets the free disk space getter for testing. |
| 1538 // The existing getter is deleted. | 1542 // The existing getter is deleted. |
| 1539 void SetFreeDiskSpaceGetterForTesting( | 1543 void SetFreeDiskSpaceGetterForTesting( |
| 1540 FreeDiskSpaceGetterInterface* getter); | 1544 FreeDiskSpaceGetterInterface* getter); |
| 1541 | 1545 |
| 1542 } // namespace gdata | 1546 } // namespace gdata |
| 1543 | 1547 |
| 1544 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ | 1548 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
| OLD | NEW |