| 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_DOWNLOAD_OBSERVER_H__ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DOWNLOAD_OBSERVER_H__ |
| 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DOWNLOAD_OBSERVER_H__ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DOWNLOAD_OBSERVER_H__ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/platform_file.h" | 12 #include "base/platform_file.h" |
| 13 #include "content/public/browser/download_item.h" | 13 #include "content/public/browser/download_item.h" |
| 14 #include "content/public/browser/download_manager.h" | 14 #include "content/public/browser/download_manager.h" |
| 15 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h" | 15 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h" |
| 16 | 16 |
| 17 class Profile; | 17 class Profile; |
| 18 | 18 |
| 19 namespace gdata { | 19 namespace gdata { |
| 20 | 20 |
| 21 class DocumentEntry; | 21 class DocumentEntry; |
| 22 class GDataDirectoryProto; | 22 class GDataEntryProto; |
| 23 class GDataFileSystemInterface; | 23 class GDataFileSystemInterface; |
| 24 class GDataUploader; | 24 class GDataUploader; |
| 25 struct UploadFileInfo; | 25 struct UploadFileInfo; |
| 26 | 26 |
| 27 // Observes downloads to temporary local gdata folder. Schedules these | 27 // Observes downloads to temporary local gdata folder. Schedules these |
| 28 // downloads for upload to gdata service. | 28 // downloads for upload to gdata service. |
| 29 class GDataDownloadObserver : public content::DownloadManager::Observer, | 29 class GDataDownloadObserver : public content::DownloadManager::Observer, |
| 30 public content::DownloadItem::Observer { | 30 public content::DownloadItem::Observer { |
| 31 public: | 31 public: |
| 32 GDataDownloadObserver(GDataUploader* uploader, | 32 GDataDownloadObserver(GDataUploader* uploader, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 106 |
| 107 // Updates metadata of ongoing upload if it exists. | 107 // Updates metadata of ongoing upload if it exists. |
| 108 void UpdateUpload(content::DownloadItem* download); | 108 void UpdateUpload(content::DownloadItem* download); |
| 109 | 109 |
| 110 // Checks if this DownloadItem should be uploaded. | 110 // Checks if this DownloadItem should be uploaded. |
| 111 bool ShouldUpload(content::DownloadItem* download); | 111 bool ShouldUpload(content::DownloadItem* download); |
| 112 | 112 |
| 113 // Creates UploadFileInfo and initializes it using DownloadItem*. | 113 // Creates UploadFileInfo and initializes it using DownloadItem*. |
| 114 void CreateUploadFileInfo(content::DownloadItem* download); | 114 void CreateUploadFileInfo(content::DownloadItem* download); |
| 115 | 115 |
| 116 // Callback for handling results of GDataFileSystem::ReadDirectoryByPath() | 116 // Callback for handling results of GDataFileSystem::GetEntryInfoByPath() |
| 117 // initiated by CreateUploadFileInfo(). This callback reads the directory | 117 // initiated by CreateUploadFileInfo(). This callback reads the directory |
| 118 // entry to determine the upload path, then calls StartUpload() to actually | 118 // entry to determine the upload path, then calls StartUpload() to actually |
| 119 // start the upload. | 119 // start the upload. |
| 120 void OnReadDirectoryByPath( | 120 void OnGetEntryInfoByPath( |
| 121 int32 download_id, | 121 int32 download_id, |
| 122 scoped_ptr<UploadFileInfo> upload_file_info, | 122 scoped_ptr<UploadFileInfo> upload_file_info, |
| 123 GDataFileError error, | 123 GDataFileError error, |
| 124 bool /* hide_hosted_documents */, | 124 scoped_ptr<GDataEntryProto> entry_proto); |
| 125 scoped_ptr<GDataDirectoryProto> dir_proto); | |
| 126 | 125 |
| 127 // Starts the upload. | 126 // Starts the upload. |
| 128 void StartUpload(int32 download_id, | 127 void StartUpload(int32 download_id, |
| 129 scoped_ptr<UploadFileInfo> upload_file_info); | 128 scoped_ptr<UploadFileInfo> upload_file_info); |
| 130 | 129 |
| 131 // Callback invoked by GDataUploader when the upload associated with | 130 // Callback invoked by GDataUploader when the upload associated with |
| 132 // |download_id| has completed. |error| indicated whether the | 131 // |download_id| has completed. |error| indicated whether the |
| 133 // call was successful. This function takes ownership of DocumentEntry from | 132 // call was successful. This function takes ownership of DocumentEntry from |
| 134 // |upload_file_info| for use by MoveFileToGDataCache(). It also invokes the | 133 // |upload_file_info| for use by MoveFileToGDataCache(). It also invokes the |
| 135 // MaybeCompleteDownload() method on the DownloadItem to allow it to complete. | 134 // MaybeCompleteDownload() method on the DownloadItem to allow it to complete. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 157 DownloadMap pending_downloads_; | 156 DownloadMap pending_downloads_; |
| 158 | 157 |
| 159 base::WeakPtrFactory<GDataDownloadObserver> weak_ptr_factory_; | 158 base::WeakPtrFactory<GDataDownloadObserver> weak_ptr_factory_; |
| 160 | 159 |
| 161 DISALLOW_COPY_AND_ASSIGN(GDataDownloadObserver); | 160 DISALLOW_COPY_AND_ASSIGN(GDataDownloadObserver); |
| 162 }; | 161 }; |
| 163 | 162 |
| 164 } // namespace gdata | 163 } // namespace gdata |
| 165 | 164 |
| 166 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DOWNLOAD_OBSERVER_H__ | 165 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DOWNLOAD_OBSERVER_H__ |
| OLD | NEW |