| 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_DRIVE_DOWNLOAD_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DOWNLOAD_HANDLER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DOWNLOAD_HANDLER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DOWNLOAD_HANDLER_H_ |
| 7 | 7 |
| 8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "chrome/browser/chromeos/drive/file_errors.h" | 10 #include "chrome/browser/chromeos/drive/file_errors.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 namespace drive { | 21 namespace drive { |
| 22 | 22 |
| 23 class FileSystemInterface; | 23 class FileSystemInterface; |
| 24 class ResourceEntry; | 24 class ResourceEntry; |
| 25 | 25 |
| 26 // Observes downloads to temporary local drive folder. Schedules these | 26 // Observes downloads to temporary local drive folder. Schedules these |
| 27 // downloads for upload to drive service. | 27 // downloads for upload to drive service. |
| 28 class DownloadHandler : public AllDownloadItemNotifier::Observer { | 28 class DownloadHandler : public AllDownloadItemNotifier::Observer { |
| 29 public: | 29 public: |
| 30 explicit DownloadHandler(FileSystemInterface* file_system); | 30 explicit DownloadHandler(FileSystemInterface* file_system); |
| 31 virtual ~DownloadHandler(); | 31 ~DownloadHandler() override; |
| 32 | 32 |
| 33 // Utility method to get DownloadHandler with profile. | 33 // Utility method to get DownloadHandler with profile. |
| 34 static DownloadHandler* GetForProfile(Profile* profile); | 34 static DownloadHandler* GetForProfile(Profile* profile); |
| 35 | 35 |
| 36 // Become an observer of DownloadManager. | 36 // Become an observer of DownloadManager. |
| 37 void Initialize(content::DownloadManager* download_manager, | 37 void Initialize(content::DownloadManager* download_manager, |
| 38 const base::FilePath& drive_tmp_download_path); | 38 const base::FilePath& drive_tmp_download_path); |
| 39 | 39 |
| 40 // In addition to the DownloadManager passed to Initialize(), observe another | 40 // In addition to the DownloadManager passed to Initialize(), observe another |
| 41 // download manager. This should be called only for the DownloadManager of the | 41 // download manager. This should be called only for the DownloadManager of the |
| (...skipping 26 matching lines...) Expand all Loading... |
| 68 // Checks if there is a Drive upload associated with |download| | 68 // Checks if there is a Drive upload associated with |download| |
| 69 bool IsDriveDownload(const content::DownloadItem* download); | 69 bool IsDriveDownload(const content::DownloadItem* download); |
| 70 | 70 |
| 71 // Checks a file corresponding to the download item exists in Drive. | 71 // Checks a file corresponding to the download item exists in Drive. |
| 72 void CheckForFileExistence( | 72 void CheckForFileExistence( |
| 73 const content::DownloadItem* download, | 73 const content::DownloadItem* download, |
| 74 const content::CheckForFileExistenceCallback& callback); | 74 const content::CheckForFileExistenceCallback& callback); |
| 75 | 75 |
| 76 private: | 76 private: |
| 77 // AllDownloadItemNotifier::Observer overrides: | 77 // AllDownloadItemNotifier::Observer overrides: |
| 78 virtual void OnDownloadCreated(content::DownloadManager* manager, | 78 void OnDownloadCreated(content::DownloadManager* manager, |
| 79 content::DownloadItem* download) override; | 79 content::DownloadItem* download) override; |
| 80 virtual void OnDownloadUpdated(content::DownloadManager* manager, | 80 void OnDownloadUpdated(content::DownloadManager* manager, |
| 81 content::DownloadItem* download) override; | 81 content::DownloadItem* download) override; |
| 82 | 82 |
| 83 // Removes the download. | 83 // Removes the download. |
| 84 void RemoveDownload(void* manager_id, int id); | 84 void RemoveDownload(void* manager_id, int id); |
| 85 | 85 |
| 86 // Callback for FileSystem::CreateDirectory(). | 86 // Callback for FileSystem::CreateDirectory(). |
| 87 // Used to implement SubstituteDriveDownloadPath(). | 87 // Used to implement SubstituteDriveDownloadPath(). |
| 88 void OnCreateDirectory(const SubstituteDriveDownloadPathCallback& callback, | 88 void OnCreateDirectory(const SubstituteDriveDownloadPathCallback& callback, |
| 89 FileError error); | 89 FileError error); |
| 90 | 90 |
| 91 // Starts the upload of a downloaded/downloading file. | 91 // Starts the upload of a downloaded/downloading file. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 114 // Note: This should remain the last member so it'll be destroyed and | 114 // Note: This should remain the last member so it'll be destroyed and |
| 115 // invalidate its weak pointers before any other members are destroyed. | 115 // invalidate its weak pointers before any other members are destroyed. |
| 116 base::WeakPtrFactory<DownloadHandler> weak_ptr_factory_; | 116 base::WeakPtrFactory<DownloadHandler> weak_ptr_factory_; |
| 117 | 117 |
| 118 DISALLOW_COPY_AND_ASSIGN(DownloadHandler); | 118 DISALLOW_COPY_AND_ASSIGN(DownloadHandler); |
| 119 }; | 119 }; |
| 120 | 120 |
| 121 } // namespace drive | 121 } // namespace drive |
| 122 | 122 |
| 123 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DOWNLOAD_HANDLER_H_ | 123 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DOWNLOAD_HANDLER_H_ |
| OLD | NEW |