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 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 15 matching lines...) Expand all Loading... |
26 namespace base { | 26 namespace base { |
27 | 27 |
28 class SequencedTaskRunner; | 28 class SequencedTaskRunner; |
29 | 29 |
30 } // namespace base | 30 } // namespace base |
31 | 31 |
32 namespace gdata { | 32 namespace gdata { |
33 | 33 |
34 class DocumentsServiceInterface; | 34 class DocumentsServiceInterface; |
35 class DriveWebAppsRegistryInterface; | 35 class DriveWebAppsRegistryInterface; |
| 36 class GDataWapiFeedLoader; |
| 37 struct GetDocumentsParams; |
36 struct UploadFileInfo; | 38 struct UploadFileInfo; |
37 | 39 |
38 namespace { | 40 namespace { |
39 struct LoadRootFeedParams; | 41 struct LoadRootFeedParams; |
40 } // namespace | 42 } // namespace |
41 | 43 |
| 44 // Callback run as a response to LoadFromServer. |
| 45 // |
| 46 // TODO(satorux): Move this to a new file: crbug.com/138268 |
| 47 typedef base::Callback<void(GetDocumentsParams* params, |
| 48 GDataFileError error)> |
| 49 LoadDocumentFeedCallback; |
| 50 |
| 51 // GDataWapiFeedLoader is used to load feeds from WAPI (codename for |
| 52 // Documents List API) and load the cached proto file. |
| 53 // |
| 54 // TODO(satorux): Move this to a new file: crbug.com/138268 |
| 55 class GDataWapiFeedLoader { |
| 56 public: |
| 57 // Used to notify events from the loader. |
| 58 // All events are notified on UI thread. |
| 59 class Observer { |
| 60 public: |
| 61 // Triggered when a content of a directory has been changed. |
| 62 // |directory_path| is a virtual directory path representing the |
| 63 // changed directory. |
| 64 virtual void OnDirectoryChanged(const FilePath& directory_path) {} |
| 65 |
| 66 // Triggered when a document feed is fetched. |num_accumulated_entries| |
| 67 // tells the number of entries fetched so far. |
| 68 virtual void OnDocumentFeedFetched(int num_accumulated_entries) {} |
| 69 |
| 70 // Triggered when the feed from the server is loaded. |
| 71 virtual void OnFeedFromServerLoaded() {} |
| 72 |
| 73 protected: |
| 74 virtual ~Observer() {} |
| 75 }; |
| 76 |
| 77 GDataWapiFeedLoader( |
| 78 GDataDirectoryService* directory_service, |
| 79 DocumentsServiceInterface* documents_service, |
| 80 DriveWebAppsRegistryInterface* webapps_registry, |
| 81 GDataCache* cache, |
| 82 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_); |
| 83 ~GDataWapiFeedLoader(); |
| 84 |
| 85 // Adds and removes the observer. |
| 86 void AddObserver(Observer* observer); |
| 87 void RemoveObserver(Observer* observer); |
| 88 |
| 89 // Starts root feed load from the cache. If successful, it will try to find |
| 90 // the file upon retrieval completion. In addition to that, it will |
| 91 // initiate retrieval of the root feed from the server unless |
| 92 // |should_load_from_server| is set to false. |should_load_from_server| is |
| 93 // false only for testing. |
| 94 void LoadFromCache(bool should_load_from_server, |
| 95 const FilePath& search_file_path, |
| 96 const FindEntryCallback& callback); |
| 97 |
| 98 // Starts root feed load from the server. Value of |start_changestamp| |
| 99 // determines the type of feed to load - 0 means root feed, every other |
| 100 // value would trigger delta feed. |
| 101 // In the case of loading the root feed we use |root_feed_changestamp| as its |
| 102 // initial changestamp value since it does not come with that info. |
| 103 // When done |load_feed_callback| is invoked. |
| 104 // |entry_found_callback| is used only when this is invoked while searching |
| 105 // for file info, and is used in |load_feed_callback|. If successful, it will |
| 106 // try to find the file upon retrieval completion. |
| 107 // |should_fetch_multiple_feeds| is true iff don't want to stop feed loading |
| 108 // after we retrieve first feed chunk. |
| 109 // If invoked as a part of content search, query will be set in |
| 110 // |search_query|. |
| 111 void LoadFromServer( |
| 112 ContentOrigin initial_origin, |
| 113 int start_changestamp, |
| 114 int root_feed_changestamp, |
| 115 bool should_fetch_multiple_feeds, |
| 116 const FilePath& search_file_path, |
| 117 const std::string& search_query, |
| 118 const std::string& directory_resource_id, |
| 119 const FindEntryCallback& entry_found_callback, |
| 120 const LoadDocumentFeedCallback& feed_load_callback); |
| 121 |
| 122 // Retrieves account metadata and determines from the last change timestamp |
| 123 // if the feed content loading from the server needs to be initiated. |
| 124 void ReloadFromServerIfNeeded( |
| 125 ContentOrigin initial_origin, |
| 126 int local_changestamp, |
| 127 const FilePath& search_file_path, |
| 128 const FindEntryCallback& callback); |
| 129 |
| 130 // Updates whole directory structure feeds collected in |feed_list|. |
| 131 // On success, returns PLATFORM_FILE_OK. Record file statistics as UMA |
| 132 // histograms. |
| 133 // |
| 134 // See comments at GDataWapiFeedProcessor::ApplyFeeds() for |
| 135 // |start_changestamp| and |root_feed_changestamp|. |
| 136 GDataFileError UpdateFromFeed( |
| 137 const std::vector<DocumentFeed*>& feed_list, |
| 138 int start_changestamp, |
| 139 int root_feed_changestamp); |
| 140 |
| 141 private: |
| 142 // Callback for handling root directory refresh from the cache. |
| 143 void OnProtoLoaded(LoadRootFeedParams* params); |
| 144 |
| 145 // Helper callback for handling results of metadata retrieval initiated from |
| 146 // ReloadFeedFromServerIfNeeded(). This method makes a decision about fetching |
| 147 // the content of the root feed during the root directory refresh process. |
| 148 void OnGetAccountMetadata( |
| 149 ContentOrigin initial_origin, |
| 150 int local_changestamp, |
| 151 const FilePath& search_file_path, |
| 152 const FindEntryCallback& callback, |
| 153 GDataErrorCode status, |
| 154 scoped_ptr<base::Value> feed_data); |
| 155 |
| 156 // Callback for handling feed content fetching while searching for file info. |
| 157 // This callback is invoked after async feed fetch operation that was |
| 158 // invoked by StartDirectoryRefresh() completes. This callback will update |
| 159 // the content of the refreshed directory object and continue initially |
| 160 // started FindEntryByPath() request. |
| 161 void OnFeedFromServerLoaded(GetDocumentsParams* params, |
| 162 GDataFileError error); |
| 163 |
| 164 // Callback for handling response from |GDataDocumentsService::GetDocuments|. |
| 165 // Invokes |callback| when done. |
| 166 void OnGetDocuments( |
| 167 ContentOrigin initial_origin, |
| 168 const LoadDocumentFeedCallback& callback, |
| 169 GetDocumentsParams* params, |
| 170 base::TimeTicks start_time, |
| 171 GDataErrorCode status, |
| 172 scoped_ptr<base::Value> data); |
| 173 |
| 174 // Save filesystem as proto file. |
| 175 void SaveFileSystemAsProto(); |
| 176 |
| 177 GDataDirectoryService* directory_service_; // Not owned. |
| 178 DocumentsServiceInterface* documents_service_; // Not owned. |
| 179 DriveWebAppsRegistryInterface* webapps_registry_; // Not owned. |
| 180 GDataCache* cache_; // Not owned. |
| 181 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
| 182 ObserverList<Observer> observers_; |
| 183 |
| 184 // Note: This should remain the last member so it'll be destroyed and |
| 185 // invalidate its weak pointers before any other members are destroyed. |
| 186 base::WeakPtrFactory<GDataWapiFeedLoader> weak_ptr_factory_; |
| 187 DISALLOW_COPY_AND_ASSIGN(GDataWapiFeedLoader); |
| 188 }; |
| 189 |
42 // The production implementation of GDataFileSystemInterface. | 190 // The production implementation of GDataFileSystemInterface. |
43 class GDataFileSystem : public GDataFileSystemInterface, | 191 class GDataFileSystem : public GDataFileSystemInterface, |
| 192 public GDataWapiFeedLoader::Observer, |
44 public content::NotificationObserver { | 193 public content::NotificationObserver { |
45 public: | 194 public: |
46 GDataFileSystem(Profile* profile, | 195 GDataFileSystem(Profile* profile, |
47 GDataCache* cache, | 196 GDataCache* cache, |
48 DocumentsServiceInterface* documents_service, | 197 DocumentsServiceInterface* documents_service, |
49 GDataUploaderInterface* uploader, | 198 GDataUploaderInterface* uploader, |
50 DriveWebAppsRegistryInterface* webapps_registry, | 199 DriveWebAppsRegistryInterface* webapps_registry, |
51 base::SequencedTaskRunner* blocking_task_runner); | 200 base::SequencedTaskRunner* blocking_task_runner); |
52 virtual ~GDataFileSystem(); | 201 virtual ~GDataFileSystem(); |
53 | 202 |
54 // GDataFileSystem overrides. | 203 // GDataFileSystem overrides. |
55 virtual void Initialize() OVERRIDE; | 204 virtual void Initialize() OVERRIDE; |
56 virtual void AddObserver(Observer* observer) OVERRIDE; | 205 virtual void AddObserver( |
57 virtual void RemoveObserver(Observer* observer) OVERRIDE; | 206 GDataFileSystemInterface::Observer* observer) OVERRIDE; |
| 207 virtual void RemoveObserver( |
| 208 GDataFileSystemInterface::Observer* observer) OVERRIDE; |
58 virtual void StartUpdates() OVERRIDE; | 209 virtual void StartUpdates() OVERRIDE; |
59 virtual void StopUpdates() OVERRIDE; | 210 virtual void StopUpdates() OVERRIDE; |
60 virtual void CheckForUpdates() OVERRIDE; | 211 virtual void CheckForUpdates() OVERRIDE; |
61 virtual void GetEntryInfoByResourceId( | 212 virtual void GetEntryInfoByResourceId( |
62 const std::string& resource_id, | 213 const std::string& resource_id, |
63 const GetEntryInfoWithFilePathCallback& callback) OVERRIDE; | 214 const GetEntryInfoWithFilePathCallback& callback) OVERRIDE; |
64 virtual void Search(const std::string& search_query, | 215 virtual void Search(const std::string& search_query, |
65 const SearchCallback& callback) OVERRIDE; | 216 const SearchCallback& callback) OVERRIDE; |
66 virtual void TransferFileFromRemoteToLocal( | 217 virtual void TransferFileFromRemoteToLocal( |
67 const FilePath& remote_src_file_path, | 218 const FilePath& remote_src_file_path, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 scoped_ptr<DocumentEntry> entry, | 268 scoped_ptr<DocumentEntry> entry, |
118 const FilePath& file_content_path, | 269 const FilePath& file_content_path, |
119 GDataCache::FileOperationType cache_operation, | 270 GDataCache::FileOperationType cache_operation, |
120 const base::Closure& callback) OVERRIDE; | 271 const base::Closure& callback) OVERRIDE; |
121 | 272 |
122 // content::NotificationObserver implementation. | 273 // content::NotificationObserver implementation. |
123 virtual void Observe(int type, | 274 virtual void Observe(int type, |
124 const content::NotificationSource& source, | 275 const content::NotificationSource& source, |
125 const content::NotificationDetails& details) OVERRIDE; | 276 const content::NotificationDetails& details) OVERRIDE; |
126 | 277 |
| 278 // GDataWapiFeedLoader::Observer overrides. |
| 279 // Used to propagate events from GDataWapiFeedLoader. |
| 280 virtual void OnDirectoryChanged(const FilePath& directory_path) OVERRIDE; |
| 281 virtual void OnDocumentFeedFetched(int num_accumulated_entries) OVERRIDE; |
| 282 virtual void OnFeedFromServerLoaded() OVERRIDE; |
| 283 |
127 // Used in tests to load the root feed from the cache. | 284 // Used in tests to load the root feed from the cache. |
128 void LoadRootFeedFromCacheForTesting(); | 285 void LoadRootFeedFromCacheForTesting(); |
129 | 286 |
| 287 // Used in tests to update the file system from |feed_list|. |
| 288 // See also the comment at GDataWapiFeedLoader::UpdateFromFeed(). |
| 289 GDataFileError UpdateFromFeedForTesting( |
| 290 const std::vector<DocumentFeed*>& feed_list, |
| 291 int start_changestamp, |
| 292 int root_feed_changestamp); |
| 293 |
130 private: | 294 private: |
131 friend class GDataFileSystemTest; | 295 friend class GDataFileSystemTest; |
132 FRIEND_TEST_ALL_PREFIXES(GDataFileSystemTest, | 296 FRIEND_TEST_ALL_PREFIXES(GDataFileSystemTest, |
133 FindFirstMissingParentDirectory); | 297 FindFirstMissingParentDirectory); |
134 | 298 |
135 // Defines possible search results of FindFirstMissingParentDirectory(). | 299 // Defines possible search results of FindFirstMissingParentDirectory(). |
136 enum FindMissingDirectoryResult { | 300 enum FindMissingDirectoryResult { |
137 // Target directory found, it's not a directory. | 301 // Target directory found, it's not a directory. |
138 FOUND_INVALID, | 302 FOUND_INVALID, |
139 // Found missing directory segment while searching for given directory. | 303 // Found missing directory segment while searching for given directory. |
140 FOUND_MISSING, | 304 FOUND_MISSING, |
141 // Found target directory, it already exists. | 305 // Found target directory, it already exists. |
142 DIRECTORY_ALREADY_PRESENT, | 306 DIRECTORY_ALREADY_PRESENT, |
143 }; | 307 }; |
144 | 308 |
145 // Defines set of parameters sent to callback OnGetDocuments(). | |
146 struct GetDocumentsParams; | |
147 | |
148 // Defines set of parameters passes to intermediate callbacks during | 309 // Defines set of parameters passes to intermediate callbacks during |
149 // execution of CreateDirectory() method. | 310 // execution of CreateDirectory() method. |
150 struct CreateDirectoryParams; | 311 struct CreateDirectoryParams; |
151 | 312 |
152 // Defines set of parameters passed to an intermediate callback | 313 // Defines set of parameters passed to an intermediate callback |
153 // OnGetFileCompleteForOpen, during execution of OpenFile() method. | 314 // OnGetFileCompleteForOpen, during execution of OpenFile() method. |
154 struct GetFileCompleteForOpenParams; | 315 struct GetFileCompleteForOpenParams; |
155 | 316 |
156 // Defines set of parameters passed to intermediate callbacks during | 317 // Defines set of parameters passed to intermediate callbacks during |
157 // execution of GetFileByPath() method. | 318 // execution of GetFileByPath() method. |
158 struct GetFileFromCacheParams; | 319 struct GetFileFromCacheParams; |
159 | 320 |
160 // Callback similar to FileOperationCallback but with a given |file_path|. | 321 // Callback similar to FileOperationCallback but with a given |file_path|. |
161 typedef base::Callback<void(GDataFileError error, | 322 typedef base::Callback<void(GDataFileError error, |
162 const FilePath& file_path)> | 323 const FilePath& file_path)> |
163 FilePathUpdateCallback; | 324 FilePathUpdateCallback; |
164 | 325 |
165 // Callback run as a response to LoadFeedFromServer. | |
166 typedef base::Callback<void(GetDocumentsParams* params, | |
167 GDataFileError error)> | |
168 LoadDocumentFeedCallback; | |
169 | |
170 // Struct used for StartFileUploadOnUIThread(). | 326 // Struct used for StartFileUploadOnUIThread(). |
171 struct StartFileUploadParams; | 327 struct StartFileUploadParams; |
172 | 328 |
173 // Callback passed to |LoadFeedFromServer| from |Search| method. | 329 // Callback passed to |LoadFeedFromServer| from |Search| method. |
174 // |callback| is that should be run with data received from | 330 // |callback| is that should be run with data received from |
175 // |LoadFeedFromServer|. | 331 // |LoadFeedFromServer|. |
176 // |params| params used for getting document feed for content search. | 332 // |params| params used for getting document feed for content search. |
177 // |error| error code returned by |LoadFeedFromServer|. | 333 // |error| error code returned by |LoadFeedFromServer|. |
178 void OnSearch(const SearchCallback& callback, | 334 void OnSearch(const SearchCallback& callback, |
179 GetDocumentsParams* params, | 335 GetDocumentsParams* params, |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 GDataFileError error, | 533 GDataFileError error, |
378 const FilePath& file_path); | 534 const FilePath& file_path); |
379 | 535 |
380 // Removes file under |file_path| from in-memory snapshot of the file system. | 536 // Removes file under |file_path| from in-memory snapshot of the file system. |
381 // |resource_id| contains the resource id of the removed file if it was a | 537 // |resource_id| contains the resource id of the removed file if it was a |
382 // file. | 538 // file. |
383 // Return PLATFORM_FILE_OK if successful. | 539 // Return PLATFORM_FILE_OK if successful. |
384 GDataFileError RemoveEntryFromGData(const FilePath& file_path, | 540 GDataFileError RemoveEntryFromGData(const FilePath& file_path, |
385 std::string* resource_id); | 541 std::string* resource_id); |
386 | 542 |
387 // Callback for handling response from |GDataDocumentsService::GetDocuments|. | |
388 // Invokes |callback| when done. | |
389 void OnGetDocuments(ContentOrigin initial_origin, | |
390 const LoadDocumentFeedCallback& callback, | |
391 GetDocumentsParams* params, | |
392 base::TimeTicks start_time, | |
393 GDataErrorCode status, | |
394 scoped_ptr<base::Value> data); | |
395 | |
396 // A pass-through callback used for bridging from | 543 // A pass-through callback used for bridging from |
397 // FilePathUpdateCallback to FileOperationCallback. | 544 // FilePathUpdateCallback to FileOperationCallback. |
398 void OnFilePathUpdated(const FileOperationCallback& cllback, | 545 void OnFilePathUpdated(const FileOperationCallback& cllback, |
399 GDataFileError error, | 546 GDataFileError error, |
400 const FilePath& file_path); | 547 const FilePath& file_path); |
401 | 548 |
402 // Invoked upon completion of MarkDirtyInCache initiated by OpenFile. Invokes | 549 // Invoked upon completion of MarkDirtyInCache initiated by OpenFile. Invokes |
403 // |callback| with |cache_file_path|, which is the path of the cache file | 550 // |callback| with |cache_file_path|, which is the path of the cache file |
404 // ready for modification. | 551 // ready for modification. |
405 // | 552 // |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 // Returns PLATFORM_FILE_OK if successful. | 651 // Returns PLATFORM_FILE_OK if successful. |
505 GDataFileError RemoveEntryFromDirectoryOnFilesystem( | 652 GDataFileError RemoveEntryFromDirectoryOnFilesystem( |
506 const FilePath& file_path, const FilePath& dir_path, | 653 const FilePath& file_path, const FilePath& dir_path, |
507 FilePath* updated_file_path); | 654 FilePath* updated_file_path); |
508 | 655 |
509 // Removes a file or directory under |file_path| from in-memory snapshot of | 656 // Removes a file or directory under |file_path| from in-memory snapshot of |
510 // the file system and the corresponding file from cache if it exists. | 657 // the file system and the corresponding file from cache if it exists. |
511 // Return PLATFORM_FILE_OK if successful. | 658 // Return PLATFORM_FILE_OK if successful. |
512 GDataFileError RemoveEntryFromFileSystem(const FilePath& file_path); | 659 GDataFileError RemoveEntryFromFileSystem(const FilePath& file_path); |
513 | 660 |
514 // Updates whole directory structure feeds collected in |feed_list|. | |
515 // On success, returns PLATFORM_FILE_OK. Record file statistics as UMA | |
516 // histograms. | |
517 GDataFileError UpdateFromFeed( | |
518 const std::vector<DocumentFeed*>& feed_list, | |
519 int largest_changestamp, | |
520 int root_feed_changestamp); | |
521 | |
522 // Callback for GetEntryByResourceIdAsync. | 661 // Callback for GetEntryByResourceIdAsync. |
523 // Removes stale entry upon upload of file. | 662 // Removes stale entry upon upload of file. |
524 static void RemoveStaleEntryOnUpload(const std::string& resource_id, | 663 static void RemoveStaleEntryOnUpload(const std::string& resource_id, |
525 GDataDirectory* parent_dir, | 664 GDataDirectory* parent_dir, |
526 GDataEntry* existing_entry); | 665 GDataEntry* existing_entry); |
527 | 666 |
528 // Converts |entry_value| into GFileDocument instance and adds it | 667 // Converts |entry_value| into GFileDocument instance and adds it |
529 // to virtual file system at |directory_path|. | 668 // to virtual file system at |directory_path|. |
530 GDataFileError AddNewDirectory(const FilePath& directory_path, | 669 GDataFileError AddNewDirectory(const FilePath& directory_path, |
531 base::Value* entry_value); | 670 base::Value* entry_value); |
532 | 671 |
533 // Given non-existing |directory_path|, finds the first missing parent | 672 // Given non-existing |directory_path|, finds the first missing parent |
534 // directory of |directory_path|. | 673 // directory of |directory_path|. |
535 FindMissingDirectoryResult FindFirstMissingParentDirectory( | 674 FindMissingDirectoryResult FindFirstMissingParentDirectory( |
536 const FilePath& directory_path, | 675 const FilePath& directory_path, |
537 GURL* last_dir_content_url, | 676 GURL* last_dir_content_url, |
538 FilePath* first_missing_parent_path); | 677 FilePath* first_missing_parent_path); |
539 | 678 |
540 // Retrieves account metadata and determines from the last change timestamp | |
541 // if the feed content loading from the server needs to be initiated. | |
542 void ReloadFeedFromServerIfNeeded(ContentOrigin initial_origin, | |
543 int local_changestamp, | |
544 const FilePath& search_file_path, | |
545 const FindEntryCallback& callback); | |
546 | |
547 // Helper callback for handling results of metadata retrieval initiated from | |
548 // ReloadFeedFromServerIfNeeded(). This method makes a decision about fetching | |
549 // the content of the root feed during the root directory refresh process. | |
550 void OnGetAccountMetadata(ContentOrigin initial_origin, | |
551 int local_changestamp, | |
552 const FilePath& search_file_path, | |
553 const FindEntryCallback& callback, | |
554 GDataErrorCode error, | |
555 scoped_ptr<base::Value> feed_data); | |
556 | |
557 // Starts root feed load from the server. Value of |start_changestamp| | |
558 // determines the type of feed to load - 0 means root feed, every other | |
559 // value would trigger delta feed. | |
560 // In the case of loading the root feed we use |root_feed_changestamp| as its | |
561 // initial changestamp value since it does not come with that info. | |
562 // When done |load_feed_callback| is invoked. | |
563 // |entry_found_callback| is used only when this is invoked while searching | |
564 // for file info, and is used in |load_feed_callback|. If successful, it will | |
565 // try to find the file upon retrieval completion. | |
566 // |should_fetch_multiple_feeds| is true iff don't want to stop feed loading | |
567 // after we retrieve first feed chunk. | |
568 // If invoked as a part of content search, query will be set in | |
569 // |search_query|. | |
570 void LoadFeedFromServer(ContentOrigin initial_origin, | |
571 int start_changestamp, | |
572 int root_feed_changestamp, | |
573 bool should_fetch_multiple_feeds, | |
574 const FilePath& search_file_path, | |
575 const std::string& search_query, | |
576 const std::string& directory_resource_id, | |
577 const FindEntryCallback& entry_found_callback, | |
578 const LoadDocumentFeedCallback& load_feed_callback); | |
579 | |
580 // Callback for handling feed content fetching while searching for file info. | |
581 // This callback is invoked after async feed fetch operation that was | |
582 // invoked by StartDirectoryRefresh() completes. This callback will update | |
583 // the content of the refreshed directory object and continue initially | |
584 // started FindEntryByPath() request. | |
585 void OnFeedFromServerLoaded(GetDocumentsParams* params, | |
586 GDataFileError status); | |
587 | |
588 // Callback for handling results of ReloadFeedFromServerIfNeeded() initiated | 679 // Callback for handling results of ReloadFeedFromServerIfNeeded() initiated |
589 // from CheckForUpdates(). This callback checks whether feed is successfully | 680 // from CheckForUpdates(). This callback checks whether feed is successfully |
590 // reloaded, and in case of failure, restores the content origin of the root | 681 // reloaded, and in case of failure, restores the content origin of the root |
591 // directory. | 682 // directory. |
592 void OnUpdateChecked(ContentOrigin initial_origin, | 683 void OnUpdateChecked(ContentOrigin initial_origin, |
593 GDataFileError error, | 684 GDataFileError error, |
594 GDataEntry* entry); | 685 GDataEntry* entry); |
595 | 686 |
596 // Starts root feed load from the cache. If successful, it will try to find | |
597 // the file upon retrieval completion. In addition to that, it will | |
598 // initiate retrieval of the root feed from the server unless | |
599 // |should_load_from_server| is set to false. |should_load_from_server| is | |
600 // false only for testing. | |
601 void LoadRootFeedFromCache(bool should_load_from_server, | |
602 const FilePath& search_file_path, | |
603 const FindEntryCallback& callback); | |
604 | |
605 // Callback for handling root directory refresh from the cache. | |
606 void OnProtoLoaded(LoadRootFeedParams* params); | |
607 | |
608 // Save filesystem as proto file. | |
609 void SaveFileSystemAsProto(); | |
610 | |
611 // Runs the callback and notifies that the initial load is finished. | 687 // Runs the callback and notifies that the initial load is finished. |
612 void RunAndNotifyInitialLoadFinished( | 688 void RunAndNotifyInitialLoadFinished( |
613 const FindEntryCallback& callback, | 689 const FindEntryCallback& callback, |
614 GDataFileError error, | 690 GDataFileError error, |
615 GDataEntry* entry); | 691 GDataEntry* entry); |
616 | 692 |
617 // Helper function that completes bookkeeping tasks related to | 693 // Helper function that completes bookkeeping tasks related to |
618 // completed file transfer. | 694 // completed file transfer. |
619 void OnTransferCompleted( | 695 void OnTransferCompleted( |
620 const FileOperationCallback& callback, | 696 const FileOperationCallback& callback, |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 base::Timer update_timer_; | 943 base::Timer update_timer_; |
868 | 944 |
869 // True if hosted documents should be hidden. | 945 // True if hosted documents should be hidden. |
870 bool hide_hosted_docs_; | 946 bool hide_hosted_docs_; |
871 | 947 |
872 // The set of paths opened by OpenFile but not yet closed by CloseFile. | 948 // The set of paths opened by OpenFile but not yet closed by CloseFile. |
873 std::set<FilePath> open_files_; | 949 std::set<FilePath> open_files_; |
874 | 950 |
875 scoped_ptr<PrefChangeRegistrar> pref_registrar_; | 951 scoped_ptr<PrefChangeRegistrar> pref_registrar_; |
876 | 952 |
877 ObserverList<Observer> observers_; | 953 // The loader is used to load the feeds. |
| 954 scoped_ptr<GDataWapiFeedLoader> feed_loader_; |
| 955 |
| 956 ObserverList<GDataFileSystemInterface::Observer> observers_; |
878 | 957 |
879 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 958 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
880 | 959 |
881 // WeakPtrFactory and WeakPtr bound to the UI thread. | 960 // WeakPtrFactory and WeakPtr bound to the UI thread. |
882 // Note: These should remain the last member so they'll be destroyed and | 961 // Note: These should remain the last member so they'll be destroyed and |
883 // invalidate the weak pointers before any other members are destroyed. | 962 // invalidate the weak pointers before any other members are destroyed. |
884 base::WeakPtrFactory<GDataFileSystem> ui_weak_ptr_factory_; | 963 base::WeakPtrFactory<GDataFileSystem> ui_weak_ptr_factory_; |
885 // Unlike other classes, we need this as we need this to redirect a task | 964 // Unlike other classes, we need this as we need this to redirect a task |
886 // from IO thread to UI thread. | 965 // from IO thread to UI thread. |
887 base::WeakPtr<GDataFileSystem> ui_weak_ptr_; | 966 base::WeakPtr<GDataFileSystem> ui_weak_ptr_; |
888 }; | 967 }; |
889 | 968 |
890 } // namespace gdata | 969 } // namespace gdata |
891 | 970 |
892 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ | 971 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
OLD | NEW |