Home | History | Annotate | Download | only in file_system
      1 // Copyright 2014 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_OPERATION_DELEGATE_H_
      6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_OPERATION_DELEGATE_H_
      7 
      8 #include "chrome/browser/chromeos/drive/file_errors.h"
      9 
     10 namespace base {
     11 class FilePath;
     12 }
     13 
     14 namespace drive {
     15 class FileChange;
     16 
     17 namespace file_system {
     18 
     19 // Error type of sync client.
     20 // Keep it synced with "DriveSyncErrorType" in file_manager_private.idl.
     21 enum DriveSyncErrorType {
     22   // Request to delete a file without permission.
     23   DRIVE_SYNC_ERROR_DELETE_WITHOUT_PERMISSION,
     24   // Google Drive is temporary unavailable.
     25   DRIVE_SYNC_ERROR_SERVICE_UNAVAILABLE,
     26   // Errors other than above ones. No fallback is provided for the error.
     27   DRIVE_SYNC_ERROR_MISC,
     28 };
     29 
     30 // Passes notifications from Drive operations back to the file system.
     31 class OperationDelegate {
     32  public:
     33   // Sent when a content of a directory has been changed.
     34   // |directory_path| is a virtual directory path representing the
     35   // changed directory.
     36   virtual void OnFileChangedByOperation(const FileChange& changed_files) {}
     37 
     38   // Sent when an entry is updated and sync is needed.
     39   virtual void OnEntryUpdatedByOperation(const std::string& local_id) {}
     40 
     41   // Sent when a specific drive sync error occurred.
     42   // |local_id| is the local ID of the resource entry.
     43   virtual void OnDriveSyncError(DriveSyncErrorType type,
     44                                 const std::string& local_id) {}
     45 
     46   // Waits for the sync task to complete and runs the callback.
     47   // Returns false if no task is found for the spcecified ID.
     48   virtual bool WaitForSyncComplete(const std::string& local_id,
     49                                    const FileOperationCallback& callback);
     50 };
     51 
     52 }  // namespace file_system
     53 }  // namespace drive
     54 
     55 #endif  // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_OPERATION_DELEGATE_H_
     56