Index: chrome/browser/chromeos/gdata/gdata_file_system.h |
diff --git a/chrome/browser/chromeos/gdata/gdata_file_system.h b/chrome/browser/chromeos/gdata/gdata_file_system.h |
index 707ddc3bf917d3f2730dc31e9f7cea945e0a5e3b..bc3d247ff570c0eba4df6cd917542b10ede1e11b 100644 |
--- a/chrome/browser/chromeos/gdata/gdata_file_system.h |
+++ b/chrome/browser/chromeos/gdata/gdata_file_system.h |
@@ -19,6 +19,7 @@ |
#include "chrome/browser/chromeos/gdata/gdata_file_system_interface.h" |
#include "chrome/browser/chromeos/gdata/gdata_errorcode.h" |
#include "chrome/browser/chromeos/gdata/gdata_files.h" |
+#include "chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.h" |
#include "chrome/browser/chromeos/gdata/gdata_wapi_feed_processor.h" |
#include "chrome/browser/prefs/pref_change_registrar.h" |
#include "content/public/browser/notification_observer.h" |
@@ -34,167 +35,8 @@ namespace gdata { |
class DocumentsServiceInterface; |
class DriveWebAppsRegistryInterface; |
class GDataWapiFeedLoader; |
-struct GetDocumentsParams; |
-struct GetDocumentsUiState; |
struct UploadFileInfo; |
-// Callback run as a response to LoadFromServer. |
-// |
-// TODO(satorux): Move this to a new file: crbug.com/138268 |
-typedef base::Callback<void(GetDocumentsParams* params, |
- GDataFileError error)> |
- LoadDocumentFeedCallback; |
- |
-// GDataWapiFeedLoader is used to load feeds from WAPI (codename for |
-// Documents List API) and load the cached proto file. |
-// |
-// TODO(satorux): Move this to a new file: crbug.com/138268 |
-class GDataWapiFeedLoader { |
- public: |
- // Used to notify events from the loader. |
- // All events are notified on UI thread. |
- class Observer { |
- public: |
- // Triggered when a content of a directory has been changed. |
- // |directory_path| is a virtual directory path representing the |
- // changed directory. |
- virtual void OnDirectoryChanged(const FilePath& directory_path) {} |
- |
- // Triggered when a document feed is fetched. |num_accumulated_entries| |
- // tells the number of entries fetched so far. |
- virtual void OnDocumentFeedFetched(int num_accumulated_entries) {} |
- |
- // Triggered when the feed from the server is loaded. |
- virtual void OnFeedFromServerLoaded() {} |
- |
- protected: |
- virtual ~Observer() {} |
- }; |
- |
- GDataWapiFeedLoader( |
- GDataDirectoryService* directory_service, |
- DocumentsServiceInterface* documents_service, |
- DriveWebAppsRegistryInterface* webapps_registry, |
- GDataCache* cache, |
- scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_); |
- ~GDataWapiFeedLoader(); |
- |
- // Adds and removes the observer. |
- void AddObserver(Observer* observer); |
- void RemoveObserver(Observer* observer); |
- |
- // Starts root feed load from the cache. If successful, it will try to find |
- // the file upon retrieval completion. In addition to that, it will |
- // initiate retrieval of the root feed from the server unless |
- // |should_load_from_server| is set to false. |should_load_from_server| is |
- // false only for testing. |
- void LoadFromCache(bool should_load_from_server, |
- const FilePath& search_file_path, |
- const FindEntryCallback& callback); |
- |
- // Starts root feed load from the server. Value of |start_changestamp| |
- // determines the type of feed to load - 0 means root feed, every other |
- // value would trigger delta feed. |
- // In the case of loading the root feed we use |root_feed_changestamp| as its |
- // initial changestamp value since it does not come with that info. |
- // When done |load_feed_callback| is invoked. |
- // |entry_found_callback| is used only when this is invoked while searching |
- // for file info, and is used in |load_feed_callback|. If successful, it will |
- // try to find the file upon retrieval completion. |
- // |should_fetch_multiple_feeds| is true iff don't want to stop feed loading |
- // after we retrieve first feed chunk. |
- // If invoked as a part of content search, query will be set in |
- // |search_query|. |
- // If |feed_to_load| is set, this is feed url that will be used to load feed. |
- void LoadFromServer( |
- ContentOrigin initial_origin, |
- int start_changestamp, |
- int root_feed_changestamp, |
- bool should_fetch_multiple_feeds, |
- const FilePath& search_file_path, |
- const std::string& search_query, |
- const GURL& feed_to_load, |
- const std::string& directory_resource_id, |
- const FindEntryCallback& entry_found_callback, |
- const LoadDocumentFeedCallback& feed_load_callback); |
- |
- // Retrieves account metadata and determines from the last change timestamp |
- // if the feed content loading from the server needs to be initiated. |
- void ReloadFromServerIfNeeded( |
- ContentOrigin initial_origin, |
- int local_changestamp, |
- const FilePath& search_file_path, |
- const FindEntryCallback& callback); |
- |
- // Updates whole directory structure feeds collected in |feed_list|. |
- // On success, returns PLATFORM_FILE_OK. Record file statistics as UMA |
- // histograms. |
- // |
- // See comments at GDataWapiFeedProcessor::ApplyFeeds() for |
- // |start_changestamp| and |root_feed_changestamp|. |
- GDataFileError UpdateFromFeed( |
- const std::vector<DocumentFeed*>& feed_list, |
- int start_changestamp, |
- int root_feed_changestamp); |
- |
- private: |
- // Callback for handling root directory refresh from the cache. |
- void OnProtoLoaded(LoadRootFeedParams* params); |
- |
- // Continues handling root directory refresh after the directory service |
- // is fully loaded. |
- void ContinueWithInitializedDirectoryService(LoadRootFeedParams* params, |
- GDataFileError error); |
- |
- // Helper callback for handling results of metadata retrieval initiated from |
- // ReloadFeedFromServerIfNeeded(). This method makes a decision about fetching |
- // the content of the root feed during the root directory refresh process. |
- void OnGetAccountMetadata( |
- ContentOrigin initial_origin, |
- int local_changestamp, |
- const FilePath& search_file_path, |
- const FindEntryCallback& callback, |
- GDataErrorCode status, |
- scoped_ptr<base::Value> feed_data); |
- |
- // Callback for handling feed content fetching while searching for file info. |
- // This callback is invoked after async feed fetch operation that was |
- // invoked by StartDirectoryRefresh() completes. This callback will update |
- // the content of the refreshed directory object and continue initially |
- // started FindEntryByPath() request. |
- void OnFeedFromServerLoaded(GetDocumentsParams* params, |
- GDataFileError error); |
- |
- // Callback for handling response from |GDataDocumentsService::GetDocuments|. |
- // Invokes |callback| when done. |
- void OnGetDocuments( |
- ContentOrigin initial_origin, |
- const LoadDocumentFeedCallback& callback, |
- GetDocumentsParams* params, |
- base::TimeTicks start_time, |
- GDataErrorCode status, |
- scoped_ptr<base::Value> data); |
- |
- // Save filesystem to disk. |
- void SaveFileSystem(); |
- |
- // Callback for handling UI updates caused by document fetching. |
- void OnNotifyDocumentFeedFetched( |
- base::WeakPtr<GetDocumentsUiState> ui_state); |
- |
- GDataDirectoryService* directory_service_; // Not owned. |
- DocumentsServiceInterface* documents_service_; // Not owned. |
- DriveWebAppsRegistryInterface* webapps_registry_; // Not owned. |
- GDataCache* cache_; // Not owned. |
- scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
- ObserverList<Observer> observers_; |
- |
- // Note: This should remain the last member so it'll be destroyed and |
- // invalidate its weak pointers before any other members are destroyed. |
- base::WeakPtrFactory<GDataWapiFeedLoader> weak_ptr_factory_; |
- DISALLOW_COPY_AND_ASSIGN(GDataWapiFeedLoader); |
-}; |
- |
// The production implementation of GDataFileSystemInterface. |
class GDataFileSystem : public GDataFileSystemInterface, |
public GDataWapiFeedLoader::Observer, |