Chromium Code Reviews| 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 #include "chrome/browser/google_apis/gdata_wapi_service.h" | 5 #include "chrome/browser/google_apis/gdata_wapi_service.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 bool GDataWapiService::CancelForFilePath(const FilePath& file_path) { | 127 bool GDataWapiService::CancelForFilePath(const FilePath& file_path) { |
| 128 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 128 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 129 return operation_registry()->CancelForFilePath(file_path); | 129 return operation_registry()->CancelForFilePath(file_path); |
| 130 } | 130 } |
| 131 | 131 |
| 132 OperationProgressStatusList GDataWapiService::GetProgressStatusList() const { | 132 OperationProgressStatusList GDataWapiService::GetProgressStatusList() const { |
| 133 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 133 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 134 return operation_registry()->GetProgressStatusList(); | 134 return operation_registry()->GetProgressStatusList(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 void GDataWapiService::GetDocuments( | 137 void GDataWapiService::GetDocuments( |
|
satorux1
2012/12/06 06:04:53
oh this also has to be renamed... but probably in
| |
| 138 const GURL& url, | 138 const GURL& url, |
| 139 int64 start_changestamp, | 139 int64 start_changestamp, |
| 140 const std::string& search_query, | 140 const std::string& search_query, |
| 141 bool shared_with_me, | 141 bool shared_with_me, |
| 142 const std::string& directory_resource_id, | 142 const std::string& directory_resource_id, |
| 143 const GetDataCallback& callback) { | 143 const GetDataCallback& callback) { |
| 144 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 144 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 145 DCHECK(!callback.is_null()); | 145 DCHECK(!callback.is_null()); |
| 146 | 146 |
| 147 // Drive V2 API defines changestamp in int64, while DocumentsList API uses | 147 // Drive V2 API defines changestamp in int64, while DocumentsList API uses |
| 148 // int32. This narrowing should not cause any trouble. | 148 // int32. This narrowing should not cause any trouble. |
| 149 runner_->StartOperationWithRetry( | 149 runner_->StartOperationWithRetry( |
| 150 new GetDocumentsOperation(operation_registry(), | 150 new GetDocumentsOperation(operation_registry(), |
| 151 url_request_context_getter_, | 151 url_request_context_getter_, |
| 152 url_generator_, | 152 url_generator_, |
| 153 url, | 153 url, |
| 154 static_cast<int>(start_changestamp), | 154 static_cast<int>(start_changestamp), |
| 155 search_query, | 155 search_query, |
| 156 shared_with_me, | 156 shared_with_me, |
| 157 directory_resource_id, | 157 directory_resource_id, |
| 158 callback)); | 158 callback)); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void GDataWapiService::GetDocumentEntry( | 161 void GDataWapiService::GetDocumentEntry( |
|
satorux1
2012/12/06 06:04:53
ditto.
| |
| 162 const std::string& resource_id, | 162 const std::string& resource_id, |
| 163 const GetDataCallback& callback) { | 163 const GetDataCallback& callback) { |
| 164 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 164 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 165 DCHECK(!callback.is_null()); | 165 DCHECK(!callback.is_null()); |
| 166 | 166 |
| 167 runner_->StartOperationWithRetry( | 167 runner_->StartOperationWithRetry( |
| 168 new GetDocumentEntryOperation(operation_registry(), | 168 new GetResourceEntryOperation(operation_registry(), |
| 169 url_request_context_getter_, | 169 url_request_context_getter_, |
| 170 url_generator_, | 170 url_generator_, |
| 171 resource_id, | 171 resource_id, |
| 172 callback)); | 172 callback)); |
| 173 } | 173 } |
| 174 | 174 |
| 175 void GDataWapiService::GetAccountMetadata(const GetDataCallback& callback) { | 175 void GDataWapiService::GetAccountMetadata(const GetDataCallback& callback) { |
| 176 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 176 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 177 DCHECK(!callback.is_null()); | 177 DCHECK(!callback.is_null()); |
| 178 | 178 |
| 179 runner_->StartOperationWithRetry( | 179 runner_->StartOperationWithRetry( |
| 180 new GetAccountMetadataOperation(operation_registry(), | 180 new GetAccountMetadataOperation(operation_registry(), |
| 181 url_request_context_getter_, | 181 url_request_context_getter_, |
| 182 url_generator_, | 182 url_generator_, |
| 183 callback)); | 183 callback)); |
| 184 } | 184 } |
| 185 | 185 |
| 186 void GDataWapiService::GetApplicationInfo( | 186 void GDataWapiService::GetApplicationInfo( |
| 187 const GetDataCallback& callback) { | 187 const GetDataCallback& callback) { |
| 188 // For WAPI, AccountMetadata includes Drive application information. | 188 // For WAPI, AccountMetadata includes Drive application information. |
| 189 GetAccountMetadata(callback); | 189 GetAccountMetadata(callback); |
| 190 } | 190 } |
| 191 | 191 |
| 192 void GDataWapiService::DownloadDocument( | 192 void GDataWapiService::DownloadDocument( |
|
satorux1
2012/12/06 06:04:53
ditto.
| |
| 193 const FilePath& virtual_path, | 193 const FilePath& virtual_path, |
| 194 const FilePath& local_cache_path, | 194 const FilePath& local_cache_path, |
| 195 const GURL& document_url, | 195 const GURL& document_url, |
| 196 DocumentExportFormat format, | 196 DocumentExportFormat format, |
| 197 const DownloadActionCallback& callback) { | 197 const DownloadActionCallback& callback) { |
| 198 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 198 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 199 DCHECK(!callback.is_null()); | 199 DCHECK(!callback.is_null()); |
| 200 | 200 |
| 201 DownloadFile( | 201 DownloadFile( |
| 202 virtual_path, | 202 virtual_path, |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 220 | 220 |
| 221 runner_->StartOperationWithRetry( | 221 runner_->StartOperationWithRetry( |
| 222 new DownloadFileOperation(operation_registry(), | 222 new DownloadFileOperation(operation_registry(), |
| 223 url_request_context_getter_, | 223 url_request_context_getter_, |
| 224 download_action_callback, | 224 download_action_callback, |
| 225 get_content_callback, document_url, | 225 get_content_callback, document_url, |
| 226 virtual_path, | 226 virtual_path, |
| 227 local_cache_path)); | 227 local_cache_path)); |
| 228 } | 228 } |
| 229 | 229 |
| 230 void GDataWapiService::DeleteDocument( | 230 void GDataWapiService::DeleteDocument( |
|
satorux1
2012/12/06 06:04:53
ditto.
| |
| 231 const GURL& document_url, | 231 const GURL& document_url, |
| 232 const EntryActionCallback& callback) { | 232 const EntryActionCallback& callback) { |
| 233 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 233 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 234 DCHECK(!callback.is_null()); | 234 DCHECK(!callback.is_null()); |
| 235 | 235 |
| 236 runner_->StartOperationWithRetry( | 236 runner_->StartOperationWithRetry( |
| 237 new DeleteDocumentOperation(operation_registry(), | 237 new DeleteResourceOperation(operation_registry(), |
| 238 url_request_context_getter_, | 238 url_request_context_getter_, |
| 239 callback, | 239 callback, |
| 240 document_url)); | 240 document_url)); |
| 241 } | 241 } |
| 242 | 242 |
| 243 void GDataWapiService::AddNewDirectory( | 243 void GDataWapiService::AddNewDirectory( |
| 244 const GURL& parent_content_url, | 244 const GURL& parent_content_url, |
| 245 const FilePath::StringType& directory_name, | 245 const FilePath::StringType& directory_name, |
| 246 const GetDataCallback& callback) { | 246 const GetDataCallback& callback) { |
| 247 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 247 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 248 DCHECK(!callback.is_null()); | 248 DCHECK(!callback.is_null()); |
| 249 | 249 |
| 250 runner_->StartOperationWithRetry( | 250 runner_->StartOperationWithRetry( |
| 251 new CreateDirectoryOperation(operation_registry(), | 251 new CreateDirectoryOperation(operation_registry(), |
| 252 url_request_context_getter_, | 252 url_request_context_getter_, |
| 253 url_generator_, | 253 url_generator_, |
| 254 callback, | 254 callback, |
| 255 parent_content_url, | 255 parent_content_url, |
| 256 directory_name)); | 256 directory_name)); |
| 257 } | 257 } |
| 258 | 258 |
| 259 void GDataWapiService::CopyDocument( | 259 void GDataWapiService::CopyDocument( |
|
satorux1
2012/12/06 06:04:53
ditto.
| |
| 260 const std::string& resource_id, | 260 const std::string& resource_id, |
| 261 const FilePath::StringType& new_name, | 261 const FilePath::StringType& new_name, |
| 262 const GetDataCallback& callback) { | 262 const GetDataCallback& callback) { |
| 263 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 263 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 264 DCHECK(!callback.is_null()); | 264 DCHECK(!callback.is_null()); |
| 265 | 265 |
| 266 runner_->StartOperationWithRetry( | 266 runner_->StartOperationWithRetry( |
| 267 new CopyDocumentOperation(operation_registry(), | 267 new CopyHostedDocumentOperation(operation_registry(), |
| 268 url_request_context_getter_, | 268 url_request_context_getter_, |
| 269 url_generator_, | 269 url_generator_, |
| 270 callback, | 270 callback, |
| 271 resource_id, | 271 resource_id, |
| 272 new_name)); | 272 new_name)); |
| 273 } | 273 } |
| 274 | 274 |
| 275 void GDataWapiService::RenameResource( | 275 void GDataWapiService::RenameResource( |
| 276 const GURL& resource_url, | 276 const GURL& resource_url, |
| 277 const FilePath::StringType& new_name, | 277 const FilePath::StringType& new_name, |
| 278 const EntryActionCallback& callback) { | 278 const EntryActionCallback& callback) { |
| 279 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 279 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 280 DCHECK(!callback.is_null()); | 280 DCHECK(!callback.is_null()); |
| 281 | 281 |
| 282 runner_->StartOperationWithRetry( | 282 runner_->StartOperationWithRetry( |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 393 DriveServiceObserver, observers_, OnProgressUpdate(list)); | 393 DriveServiceObserver, observers_, OnProgressUpdate(list)); |
| 394 } | 394 } |
| 395 | 395 |
| 396 void GDataWapiService::OnAuthenticationFailed(GDataErrorCode error) { | 396 void GDataWapiService::OnAuthenticationFailed(GDataErrorCode error) { |
| 397 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 397 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 398 FOR_EACH_OBSERVER( | 398 FOR_EACH_OBSERVER( |
| 399 DriveServiceObserver, observers_, OnAuthenticationFailed(error)); | 399 DriveServiceObserver, observers_, OnAuthenticationFailed(error)); |
| 400 } | 400 } |
| 401 | 401 |
| 402 } // namespace google_apis | 402 } // namespace google_apis |
| OLD | NEW |