| 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_GOOGLE_APIS_DRIVE_UPLOADER_H_ | 5 #ifndef CHROME_BROWSER_GOOGLE_APIS_DRIVE_UPLOADER_H_ |
| 6 #define CHROME_BROWSER_GOOGLE_APIS_DRIVE_UPLOADER_H_ | 6 #define CHROME_BROWSER_GOOGLE_APIS_DRIVE_UPLOADER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 const std::string& etag, | 79 const std::string& etag, |
| 80 const UploadCompletionCallback& callback) = 0; | 80 const UploadCompletionCallback& callback) = 0; |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 class DriveUploader : public DriveUploaderInterface { | 83 class DriveUploader : public DriveUploaderInterface { |
| 84 public: | 84 public: |
| 85 explicit DriveUploader(DriveServiceInterface* drive_service); | 85 explicit DriveUploader(DriveServiceInterface* drive_service); |
| 86 virtual ~DriveUploader(); | 86 virtual ~DriveUploader(); |
| 87 | 87 |
| 88 // DriveUploaderInterface overrides. | 88 // DriveUploaderInterface overrides. |
| 89 virtual void UploadNewFile(const GURL& upload_location, | 89 virtual void UploadNewFile(const GURL& parent_upload_url, |
| 90 const base::FilePath& drive_file_path, | 90 const base::FilePath& drive_file_path, |
| 91 const base::FilePath& local_file_path, | 91 const base::FilePath& local_file_path, |
| 92 const std::string& title, | 92 const std::string& title, |
| 93 const std::string& content_type, | 93 const std::string& content_type, |
| 94 const UploadCompletionCallback& callback) OVERRIDE; | 94 const UploadCompletionCallback& callback) OVERRIDE; |
| 95 virtual void UploadExistingFile( | 95 virtual void UploadExistingFile( |
| 96 const GURL& upload_location, | 96 const GURL& upload_url, |
| 97 const base::FilePath& drive_file_path, | 97 const base::FilePath& drive_file_path, |
| 98 const base::FilePath& local_file_path, | 98 const base::FilePath& local_file_path, |
| 99 const std::string& content_type, | 99 const std::string& content_type, |
| 100 const std::string& etag, | 100 const std::string& etag, |
| 101 const UploadCompletionCallback& callback) OVERRIDE; | 101 const UploadCompletionCallback& callback) OVERRIDE; |
| 102 | 102 |
| 103 private: | 103 private: |
| 104 struct UploadFileInfo; | 104 struct UploadFileInfo; |
| 105 typedef base::Callback<void(scoped_ptr<UploadFileInfo> upload_file_info)> |
| 106 StartInitiateUploadCallback; |
| 105 | 107 |
| 106 // Starts uploading a file with |upload_file_info|. | 108 // Starts uploading a file with |upload_file_info|. |
| 107 void StartUploadFile(scoped_ptr<UploadFileInfo> upload_file_info); | 109 void StartUploadFile( |
| 110 scoped_ptr<UploadFileInfo> upload_file_info, |
| 111 const StartInitiateUploadCallback& start_initiate_upload_callback); |
| 108 | 112 |
| 109 // net::FileStream::Open completion callback. The result of the file open | 113 // net::FileStream::Open completion callback. The result of the file open |
| 110 // operation is passed as |result|, and the size is stored in |file_size|. | 114 // operation is passed as |result|, and the size is stored in |file_size|. |
| 111 void OpenCompletionCallback(scoped_ptr<UploadFileInfo> upload_file_info, | 115 void OpenCompletionCallback( |
| 112 int64 file_size); | 116 scoped_ptr<UploadFileInfo> upload_file_info, |
| 117 const StartInitiateUploadCallback& start_initiate_upload_callback, |
| 118 int64 file_size); |
| 119 |
| 120 // Starts to initate the new file uploading. |
| 121 // Upon completion, OnUploadLocationReceived should be called. |
| 122 void StartInitiateUploadNewFile( |
| 123 const GURL& parent_upload_url, |
| 124 const std::string& title, |
| 125 scoped_ptr<UploadFileInfo> upload_file_info); |
| 126 |
| 127 // Starts to initate the existing file uploading. |
| 128 // Upon completion, OnUploadLocationReceived should be called. |
| 129 void StartInitiateUploadExistingFile( |
| 130 const GURL& upload_url, |
| 131 const std::string& etag, |
| 132 scoped_ptr<UploadFileInfo> upload_file_info); |
| 113 | 133 |
| 114 // DriveService callback for InitiateUpload. | 134 // DriveService callback for InitiateUpload. |
| 115 void OnUploadLocationReceived(scoped_ptr<UploadFileInfo> upload_file_info, | 135 void OnUploadLocationReceived(scoped_ptr<UploadFileInfo> upload_file_info, |
| 116 GDataErrorCode code, | 136 GDataErrorCode code, |
| 117 const GURL& upload_location); | 137 const GURL& upload_location); |
| 118 | 138 |
| 119 // Uploads the next chunk of data from the file. | 139 // Uploads the next chunk of data from the file. |
| 120 void UploadNextChunk(scoped_ptr<UploadFileInfo> upload_file_info); | 140 void UploadNextChunk(scoped_ptr<UploadFileInfo> upload_file_info); |
| 121 | 141 |
| 122 // net::FileStream::Read completion callback. | 142 // net::FileStream::Read completion callback. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 149 // Note: This should remain the last member so it'll be destroyed and | 169 // Note: This should remain the last member so it'll be destroyed and |
| 150 // invalidate its weak pointers before any other members are destroyed. | 170 // invalidate its weak pointers before any other members are destroyed. |
| 151 base::WeakPtrFactory<DriveUploader> weak_ptr_factory_; | 171 base::WeakPtrFactory<DriveUploader> weak_ptr_factory_; |
| 152 | 172 |
| 153 DISALLOW_COPY_AND_ASSIGN(DriveUploader); | 173 DISALLOW_COPY_AND_ASSIGN(DriveUploader); |
| 154 }; | 174 }; |
| 155 | 175 |
| 156 } // namespace google_apis | 176 } // namespace google_apis |
| 157 | 177 |
| 158 #endif // CHROME_BROWSER_GOOGLE_APIS_DRIVE_UPLOADER_H_ | 178 #endif // CHROME_BROWSER_GOOGLE_APIS_DRIVE_UPLOADER_H_ |
| OLD | NEW |