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/chromeos/gdata/gdata_operations.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_operations.h" |
6 | 6 |
7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/chromeos/gdata/gdata_util.h" | 10 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 } | 148 } |
149 | 149 |
150 } // namespace | 150 } // namespace |
151 | 151 |
152 namespace gdata { | 152 namespace gdata { |
153 | 153 |
154 //============================ GetDocumentsOperation =========================== | 154 //============================ GetDocumentsOperation =========================== |
155 | 155 |
156 GetDocumentsOperation::GetDocumentsOperation( | 156 GetDocumentsOperation::GetDocumentsOperation( |
157 GDataOperationRegistry* registry, | 157 GDataOperationRegistry* registry, |
158 Profile* profile, | |
159 int start_changestamp, | 158 int start_changestamp, |
160 const std::string& search_string, | 159 const std::string& search_string, |
161 const std::string& directory_resource_id, | 160 const std::string& directory_resource_id, |
162 const GetDataCallback& callback) | 161 const GetDataCallback& callback) |
163 : GetDataOperation(registry, profile, callback), | 162 : GetDataOperation(registry, callback), |
164 start_changestamp_(start_changestamp), | 163 start_changestamp_(start_changestamp), |
165 search_string_(search_string), | 164 search_string_(search_string), |
166 directory_resource_id_(directory_resource_id) { | 165 directory_resource_id_(directory_resource_id) { |
167 } | 166 } |
168 | 167 |
169 GetDocumentsOperation::~GetDocumentsOperation() {} | 168 GetDocumentsOperation::~GetDocumentsOperation() {} |
170 | 169 |
171 void GetDocumentsOperation::SetUrl(const GURL& url) { | 170 void GetDocumentsOperation::SetUrl(const GURL& url) { |
172 override_url_ = url; | 171 override_url_ = url; |
173 } | 172 } |
(...skipping 18 matching lines...) Expand all Loading... |
192 return AddFeedUrlParams(GURL(kGetChangesListURL), | 191 return AddFeedUrlParams(GURL(kGetChangesListURL), |
193 kMaxDocumentsPerFeed, | 192 kMaxDocumentsPerFeed, |
194 start_changestamp_, | 193 start_changestamp_, |
195 std::string()); | 194 std::string()); |
196 } | 195 } |
197 | 196 |
198 //============================ GetDocumentEntryOperation ======================= | 197 //============================ GetDocumentEntryOperation ======================= |
199 | 198 |
200 GetDocumentEntryOperation::GetDocumentEntryOperation( | 199 GetDocumentEntryOperation::GetDocumentEntryOperation( |
201 GDataOperationRegistry* registry, | 200 GDataOperationRegistry* registry, |
202 Profile* profile, | |
203 const std::string& resource_id, | 201 const std::string& resource_id, |
204 const GetDataCallback& callback) | 202 const GetDataCallback& callback) |
205 : GetDataOperation(registry, profile, callback), | 203 : GetDataOperation(registry, callback), |
206 resource_id_(resource_id) { | 204 resource_id_(resource_id) { |
207 } | 205 } |
208 | 206 |
209 GetDocumentEntryOperation::~GetDocumentEntryOperation() {} | 207 GetDocumentEntryOperation::~GetDocumentEntryOperation() {} |
210 | 208 |
211 GURL GetDocumentEntryOperation::GetURL() const { | 209 GURL GetDocumentEntryOperation::GetURL() const { |
212 GURL result = GURL(base::StringPrintf(kGetDocumentEntryURLFormat, | 210 GURL result = GURL(base::StringPrintf(kGetDocumentEntryURLFormat, |
213 net::EscapePath(resource_id_).c_str())); | 211 net::EscapePath(resource_id_).c_str())); |
214 return AddStandardUrlParams(result); | 212 return AddStandardUrlParams(result); |
215 } | 213 } |
216 | 214 |
217 //========================= GetAccountMetadataOperation ======================== | 215 //========================= GetAccountMetadataOperation ======================== |
218 | 216 |
219 GetAccountMetadataOperation::GetAccountMetadataOperation( | 217 GetAccountMetadataOperation::GetAccountMetadataOperation( |
220 GDataOperationRegistry* registry, | 218 GDataOperationRegistry* registry, |
221 Profile* profile, | |
222 const GetDataCallback& callback) | 219 const GetDataCallback& callback) |
223 : GetDataOperation(registry, profile, callback) { | 220 : GetDataOperation(registry, callback) { |
224 } | 221 } |
225 | 222 |
226 GetAccountMetadataOperation::~GetAccountMetadataOperation() {} | 223 GetAccountMetadataOperation::~GetAccountMetadataOperation() {} |
227 | 224 |
228 GURL GetAccountMetadataOperation::GetURL() const { | 225 GURL GetAccountMetadataOperation::GetURL() const { |
229 return AddMetadataUrlParams(GURL(kAccountMetadataURL)); | 226 return AddMetadataUrlParams(GURL(kAccountMetadataURL)); |
230 } | 227 } |
231 | 228 |
232 //============================ DownloadFileOperation =========================== | 229 //============================ DownloadFileOperation =========================== |
233 | 230 |
234 DownloadFileOperation::DownloadFileOperation( | 231 DownloadFileOperation::DownloadFileOperation( |
235 GDataOperationRegistry* registry, | 232 GDataOperationRegistry* registry, |
236 Profile* profile, | |
237 const DownloadActionCallback& download_action_callback, | 233 const DownloadActionCallback& download_action_callback, |
238 const GetDownloadDataCallback& get_download_data_callback, | 234 const GetDownloadDataCallback& get_download_data_callback, |
239 const GURL& document_url, | 235 const GURL& document_url, |
240 const FilePath& virtual_path, | 236 const FilePath& virtual_path, |
241 const FilePath& output_file_path) | 237 const FilePath& output_file_path) |
242 : UrlFetchOperationBase(registry, | 238 : UrlFetchOperationBase(registry, |
243 GDataOperationRegistry::OPERATION_DOWNLOAD, | 239 GDataOperationRegistry::OPERATION_DOWNLOAD, |
244 virtual_path, | 240 virtual_path), |
245 profile), | |
246 download_action_callback_(download_action_callback), | 241 download_action_callback_(download_action_callback), |
247 get_download_data_callback_(get_download_data_callback), | 242 get_download_data_callback_(get_download_data_callback), |
248 document_url_(document_url) { | 243 document_url_(document_url) { |
249 // Make sure we download the content into a temp file. | 244 // Make sure we download the content into a temp file. |
250 if (output_file_path.empty()) | 245 if (output_file_path.empty()) |
251 save_temp_file_ = true; | 246 save_temp_file_ = true; |
252 else | 247 else |
253 output_file_path_ = output_file_path; | 248 output_file_path_ = output_file_path; |
254 } | 249 } |
255 | 250 |
256 DownloadFileOperation::~DownloadFileOperation() {} | 251 DownloadFileOperation::~DownloadFileOperation() {} |
257 | 252 |
258 // Overridden from UrlFetchOperationBase. | 253 // Overridden from UrlFetchOperationBase. |
259 GURL DownloadFileOperation::GetURL() const { | 254 GURL DownloadFileOperation::GetURL() const { |
260 return document_url_; | 255 return document_url_; |
261 } | 256 } |
262 | 257 |
263 void DownloadFileOperation::OnURLFetchDownloadProgress( | 258 void DownloadFileOperation::OnURLFetchDownloadProgress(const URLFetcher* source, |
264 const URLFetcher* source, | 259 int64 current, |
265 int64 current, | 260 int64 total) { |
266 int64 total) { | |
267 NotifyProgress(current, total); | 261 NotifyProgress(current, total); |
268 } | 262 } |
269 | 263 |
270 bool DownloadFileOperation::ShouldSendDownloadData() { | 264 bool DownloadFileOperation::ShouldSendDownloadData() { |
271 return !get_download_data_callback_.is_null(); | 265 return !get_download_data_callback_.is_null(); |
272 } | 266 } |
273 | 267 |
274 void DownloadFileOperation::OnURLFetchDownloadData( | 268 void DownloadFileOperation::OnURLFetchDownloadData( |
275 const URLFetcher* source, | 269 const URLFetcher* source, |
276 scoped_ptr<std::string> download_data) { | 270 scoped_ptr<std::string> download_data) { |
(...skipping 19 matching lines...) Expand all Loading... |
296 | 290 |
297 void DownloadFileOperation::RunCallbackOnPrematureFailure(GDataErrorCode code) { | 291 void DownloadFileOperation::RunCallbackOnPrematureFailure(GDataErrorCode code) { |
298 if (!download_action_callback_.is_null()) | 292 if (!download_action_callback_.is_null()) |
299 download_action_callback_.Run(code, document_url_, FilePath()); | 293 download_action_callback_.Run(code, document_url_, FilePath()); |
300 } | 294 } |
301 | 295 |
302 //=========================== DeleteDocumentOperation ========================== | 296 //=========================== DeleteDocumentOperation ========================== |
303 | 297 |
304 DeleteDocumentOperation::DeleteDocumentOperation( | 298 DeleteDocumentOperation::DeleteDocumentOperation( |
305 GDataOperationRegistry* registry, | 299 GDataOperationRegistry* registry, |
306 Profile* profile, | |
307 const EntryActionCallback& callback, | 300 const EntryActionCallback& callback, |
308 const GURL& document_url) | 301 const GURL& document_url) |
309 : EntryActionOperation(registry, profile, callback, document_url) { | 302 : EntryActionOperation(registry, callback, document_url) { |
310 } | 303 } |
311 | 304 |
312 DeleteDocumentOperation::~DeleteDocumentOperation() {} | 305 DeleteDocumentOperation::~DeleteDocumentOperation() {} |
313 | 306 |
314 GURL DeleteDocumentOperation::GetURL() const { | 307 GURL DeleteDocumentOperation::GetURL() const { |
315 return AddStandardUrlParams(document_url()); | 308 return AddStandardUrlParams(document_url()); |
316 } | 309 } |
317 | 310 |
318 URLFetcher::RequestType DeleteDocumentOperation::GetRequestType() const { | 311 URLFetcher::RequestType DeleteDocumentOperation::GetRequestType() const { |
319 return URLFetcher::DELETE_REQUEST; | 312 return URLFetcher::DELETE_REQUEST; |
320 } | 313 } |
321 | 314 |
322 std::vector<std::string> | 315 std::vector<std::string> |
323 DeleteDocumentOperation::GetExtraRequestHeaders() const { | 316 DeleteDocumentOperation::GetExtraRequestHeaders() const { |
324 std::vector<std::string> headers; | 317 std::vector<std::string> headers; |
325 headers.push_back(kIfMatchAllHeader); | 318 headers.push_back(kIfMatchAllHeader); |
326 return headers; | 319 return headers; |
327 } | 320 } |
328 | 321 |
329 //========================== CreateDirectoryOperation ========================== | 322 //========================== CreateDirectoryOperation ========================== |
330 | 323 |
331 CreateDirectoryOperation::CreateDirectoryOperation( | 324 CreateDirectoryOperation::CreateDirectoryOperation( |
332 GDataOperationRegistry* registry, | 325 GDataOperationRegistry* registry, |
333 Profile* profile, | |
334 const GetDataCallback& callback, | 326 const GetDataCallback& callback, |
335 const GURL& parent_content_url, | 327 const GURL& parent_content_url, |
336 const FilePath::StringType& directory_name) | 328 const FilePath::StringType& directory_name) |
337 : GetDataOperation(registry, profile, callback), | 329 : GetDataOperation(registry, callback), |
338 parent_content_url_(parent_content_url), | 330 parent_content_url_(parent_content_url), |
339 directory_name_(directory_name) { | 331 directory_name_(directory_name) { |
340 } | 332 } |
341 | 333 |
342 CreateDirectoryOperation::~CreateDirectoryOperation() {} | 334 CreateDirectoryOperation::~CreateDirectoryOperation() {} |
343 | 335 |
344 GURL CreateDirectoryOperation::GetURL() const { | 336 GURL CreateDirectoryOperation::GetURL() const { |
345 if (!parent_content_url_.is_empty()) | 337 if (!parent_content_url_.is_empty()) |
346 return AddStandardUrlParams(parent_content_url_); | 338 return AddStandardUrlParams(parent_content_url_); |
347 | 339 |
(...skipping 27 matching lines...) Expand all Loading... |
375 upload_content->assign(xml_writer.GetWrittenString()); | 367 upload_content->assign(xml_writer.GetWrittenString()); |
376 DVLOG(1) << "CreateDirectory data: " << *upload_content_type << ", [" | 368 DVLOG(1) << "CreateDirectory data: " << *upload_content_type << ", [" |
377 << *upload_content << "]"; | 369 << *upload_content << "]"; |
378 return true; | 370 return true; |
379 } | 371 } |
380 | 372 |
381 //============================ CopyDocumentOperation =========================== | 373 //============================ CopyDocumentOperation =========================== |
382 | 374 |
383 CopyDocumentOperation::CopyDocumentOperation( | 375 CopyDocumentOperation::CopyDocumentOperation( |
384 GDataOperationRegistry* registry, | 376 GDataOperationRegistry* registry, |
385 Profile* profile, | |
386 const GetDataCallback& callback, | 377 const GetDataCallback& callback, |
387 const std::string& resource_id, | 378 const std::string& resource_id, |
388 const FilePath::StringType& new_name) | 379 const FilePath::StringType& new_name) |
389 : GetDataOperation(registry, profile, callback), | 380 : GetDataOperation(registry, callback), |
390 resource_id_(resource_id), | 381 resource_id_(resource_id), |
391 new_name_(new_name) { | 382 new_name_(new_name) { |
392 } | 383 } |
393 | 384 |
394 CopyDocumentOperation::~CopyDocumentOperation() {} | 385 CopyDocumentOperation::~CopyDocumentOperation() {} |
395 | 386 |
396 URLFetcher::RequestType CopyDocumentOperation::GetRequestType() const { | 387 URLFetcher::RequestType CopyDocumentOperation::GetRequestType() const { |
397 return URLFetcher::POST; | 388 return URLFetcher::POST; |
398 } | 389 } |
399 | 390 |
(...skipping 17 matching lines...) Expand all Loading... |
417 upload_content->assign(xml_writer.GetWrittenString()); | 408 upload_content->assign(xml_writer.GetWrittenString()); |
418 DVLOG(1) << "CopyDocumentOperation data: " << *upload_content_type << ", [" | 409 DVLOG(1) << "CopyDocumentOperation data: " << *upload_content_type << ", [" |
419 << *upload_content << "]"; | 410 << *upload_content << "]"; |
420 return true; | 411 return true; |
421 } | 412 } |
422 | 413 |
423 //=========================== RenameResourceOperation ========================== | 414 //=========================== RenameResourceOperation ========================== |
424 | 415 |
425 RenameResourceOperation::RenameResourceOperation( | 416 RenameResourceOperation::RenameResourceOperation( |
426 GDataOperationRegistry* registry, | 417 GDataOperationRegistry* registry, |
427 Profile* profile, | |
428 const EntryActionCallback& callback, | 418 const EntryActionCallback& callback, |
429 const GURL& document_url, | 419 const GURL& document_url, |
430 const FilePath::StringType& new_name) | 420 const FilePath::StringType& new_name) |
431 : EntryActionOperation(registry, profile, callback, document_url), | 421 : EntryActionOperation(registry, callback, document_url), |
432 new_name_(new_name) { | 422 new_name_(new_name) { |
433 } | 423 } |
434 | 424 |
435 RenameResourceOperation::~RenameResourceOperation() {} | 425 RenameResourceOperation::~RenameResourceOperation() {} |
436 | 426 |
437 URLFetcher::RequestType RenameResourceOperation::GetRequestType() const { | 427 URLFetcher::RequestType RenameResourceOperation::GetRequestType() const { |
438 return URLFetcher::PUT; | 428 return URLFetcher::PUT; |
439 } | 429 } |
440 | 430 |
441 std::vector<std::string> | 431 std::vector<std::string> |
(...skipping 22 matching lines...) Expand all Loading... |
464 upload_content->assign(xml_writer.GetWrittenString()); | 454 upload_content->assign(xml_writer.GetWrittenString()); |
465 DVLOG(1) << "RenameResourceOperation data: " << *upload_content_type << ", [" | 455 DVLOG(1) << "RenameResourceOperation data: " << *upload_content_type << ", [" |
466 << *upload_content << "]"; | 456 << *upload_content << "]"; |
467 return true; | 457 return true; |
468 } | 458 } |
469 | 459 |
470 //=========================== AuthorizeAppOperation ========================== | 460 //=========================== AuthorizeAppOperation ========================== |
471 | 461 |
472 AuthorizeAppsOperation::AuthorizeAppsOperation( | 462 AuthorizeAppsOperation::AuthorizeAppsOperation( |
473 GDataOperationRegistry* registry, | 463 GDataOperationRegistry* registry, |
474 Profile* profile, | |
475 const GetDataCallback& callback, | 464 const GetDataCallback& callback, |
476 const GURL& document_url, | 465 const GURL& document_url, |
477 const std::string& app_id) | 466 const std::string& app_id) |
478 : GetDataOperation(registry, profile, callback), | 467 : GetDataOperation(registry, callback), |
479 app_id_(app_id), | 468 app_id_(app_id), |
480 document_url_(document_url) { | 469 document_url_(document_url) { |
481 } | 470 } |
482 | 471 |
483 AuthorizeAppsOperation::~AuthorizeAppsOperation() {} | 472 AuthorizeAppsOperation::~AuthorizeAppsOperation() {} |
484 | 473 |
485 URLFetcher::RequestType AuthorizeAppsOperation::GetRequestType() const { | 474 URLFetcher::RequestType AuthorizeAppsOperation::GetRequestType() const { |
486 return URLFetcher::PUT; | 475 return URLFetcher::PUT; |
487 } | 476 } |
488 | 477 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 } | 543 } |
555 | 544 |
556 GURL AuthorizeAppsOperation::GetURL() const { | 545 GURL AuthorizeAppsOperation::GetURL() const { |
557 return document_url_; | 546 return document_url_; |
558 } | 547 } |
559 | 548 |
560 //======================= AddResourceToDirectoryOperation ====================== | 549 //======================= AddResourceToDirectoryOperation ====================== |
561 | 550 |
562 AddResourceToDirectoryOperation::AddResourceToDirectoryOperation( | 551 AddResourceToDirectoryOperation::AddResourceToDirectoryOperation( |
563 GDataOperationRegistry* registry, | 552 GDataOperationRegistry* registry, |
564 Profile* profile, | |
565 const EntryActionCallback& callback, | 553 const EntryActionCallback& callback, |
566 const GURL& parent_content_url, | 554 const GURL& parent_content_url, |
567 const GURL& document_url) | 555 const GURL& document_url) |
568 : EntryActionOperation(registry, profile, callback, document_url), | 556 : EntryActionOperation(registry, callback, document_url), |
569 parent_content_url_(parent_content_url) { | 557 parent_content_url_(parent_content_url) { |
570 } | 558 } |
571 | 559 |
572 AddResourceToDirectoryOperation::~AddResourceToDirectoryOperation() {} | 560 AddResourceToDirectoryOperation::~AddResourceToDirectoryOperation() {} |
573 | 561 |
574 GURL AddResourceToDirectoryOperation::GetURL() const { | 562 GURL AddResourceToDirectoryOperation::GetURL() const { |
575 if (!parent_content_url_.is_empty()) | 563 if (!parent_content_url_.is_empty()) |
576 return AddStandardUrlParams(parent_content_url_); | 564 return AddStandardUrlParams(parent_content_url_); |
577 | 565 |
578 return AddStandardUrlParams(GURL(kDocumentListRootURL)); | 566 return AddStandardUrlParams(GURL(kDocumentListRootURL)); |
(...skipping 19 matching lines...) Expand all Loading... |
598 upload_content->assign(xml_writer.GetWrittenString()); | 586 upload_content->assign(xml_writer.GetWrittenString()); |
599 DVLOG(1) << "AddResourceToDirectoryOperation data: " << *upload_content_type | 587 DVLOG(1) << "AddResourceToDirectoryOperation data: " << *upload_content_type |
600 << ", [" << *upload_content << "]"; | 588 << ", [" << *upload_content << "]"; |
601 return true; | 589 return true; |
602 } | 590 } |
603 | 591 |
604 //==================== RemoveResourceFromDirectoryOperation ==================== | 592 //==================== RemoveResourceFromDirectoryOperation ==================== |
605 | 593 |
606 RemoveResourceFromDirectoryOperation::RemoveResourceFromDirectoryOperation( | 594 RemoveResourceFromDirectoryOperation::RemoveResourceFromDirectoryOperation( |
607 GDataOperationRegistry* registry, | 595 GDataOperationRegistry* registry, |
608 Profile* profile, | |
609 const EntryActionCallback& callback, | 596 const EntryActionCallback& callback, |
610 const GURL& parent_content_url, | 597 const GURL& parent_content_url, |
611 const GURL& document_url, | 598 const GURL& document_url, |
612 const std::string& document_resource_id) | 599 const std::string& document_resource_id) |
613 : EntryActionOperation(registry, profile, callback, document_url), | 600 : EntryActionOperation(registry, callback, document_url), |
614 resource_id_(document_resource_id), | 601 resource_id_(document_resource_id), |
615 parent_content_url_(parent_content_url) { | 602 parent_content_url_(parent_content_url) { |
616 } | 603 } |
617 | 604 |
618 RemoveResourceFromDirectoryOperation::~RemoveResourceFromDirectoryOperation() { | 605 RemoveResourceFromDirectoryOperation::~RemoveResourceFromDirectoryOperation() { |
619 } | 606 } |
620 | 607 |
621 GURL RemoveResourceFromDirectoryOperation::GetURL() const { | 608 GURL RemoveResourceFromDirectoryOperation::GetURL() const { |
622 std::string escaped_resource_id = net::EscapePath(resource_id_); | 609 std::string escaped_resource_id = net::EscapePath(resource_id_); |
623 GURL edit_url(base::StringPrintf("%s/%s", | 610 GURL edit_url(base::StringPrintf("%s/%s", |
(...skipping 11 matching lines...) Expand all Loading... |
635 RemoveResourceFromDirectoryOperation::GetExtraRequestHeaders() const { | 622 RemoveResourceFromDirectoryOperation::GetExtraRequestHeaders() const { |
636 std::vector<std::string> headers; | 623 std::vector<std::string> headers; |
637 headers.push_back(kIfMatchAllHeader); | 624 headers.push_back(kIfMatchAllHeader); |
638 return headers; | 625 return headers; |
639 } | 626 } |
640 | 627 |
641 //=========================== InitiateUploadOperation ========================== | 628 //=========================== InitiateUploadOperation ========================== |
642 | 629 |
643 InitiateUploadOperation::InitiateUploadOperation( | 630 InitiateUploadOperation::InitiateUploadOperation( |
644 GDataOperationRegistry* registry, | 631 GDataOperationRegistry* registry, |
645 Profile* profile, | |
646 const InitiateUploadCallback& callback, | 632 const InitiateUploadCallback& callback, |
647 const InitiateUploadParams& params) | 633 const InitiateUploadParams& params) |
648 : UrlFetchOperationBase(registry, | 634 : UrlFetchOperationBase(registry, |
649 GDataOperationRegistry::OPERATION_UPLOAD, | 635 GDataOperationRegistry::OPERATION_UPLOAD, |
650 params.virtual_path, | 636 params.virtual_path), |
651 profile), | |
652 callback_(callback), | 637 callback_(callback), |
653 params_(params), | 638 params_(params), |
654 initiate_upload_url_(chrome_common_net::AppendOrReplaceQueryParameter( | 639 initiate_upload_url_(chrome_common_net::AppendOrReplaceQueryParameter( |
655 params.upload_location, | 640 params.upload_location, |
656 kUploadParamConvertKey, | 641 kUploadParamConvertKey, |
657 kUploadParamConvertValue)) { | 642 kUploadParamConvertValue)) { |
658 } | 643 } |
659 | 644 |
660 InitiateUploadOperation::~InitiateUploadOperation() {} | 645 InitiateUploadOperation::~InitiateUploadOperation() {} |
661 | 646 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 upload_content->assign(xml_writer.GetWrittenString()); | 727 upload_content->assign(xml_writer.GetWrittenString()); |
743 DVLOG(1) << "Upload data: " << *upload_content_type << ", [" | 728 DVLOG(1) << "Upload data: " << *upload_content_type << ", [" |
744 << *upload_content << "]"; | 729 << *upload_content << "]"; |
745 return true; | 730 return true; |
746 } | 731 } |
747 | 732 |
748 //============================ ResumeUploadOperation =========================== | 733 //============================ ResumeUploadOperation =========================== |
749 | 734 |
750 ResumeUploadOperation::ResumeUploadOperation( | 735 ResumeUploadOperation::ResumeUploadOperation( |
751 GDataOperationRegistry* registry, | 736 GDataOperationRegistry* registry, |
752 Profile* profile, | |
753 const ResumeUploadCallback& callback, | 737 const ResumeUploadCallback& callback, |
754 const ResumeUploadParams& params) | 738 const ResumeUploadParams& params) |
755 : UrlFetchOperationBase(registry, | 739 : UrlFetchOperationBase(registry, |
756 GDataOperationRegistry::OPERATION_UPLOAD, | 740 GDataOperationRegistry::OPERATION_UPLOAD, |
757 params.virtual_path, | 741 params.virtual_path), |
758 profile), | |
759 callback_(callback), | 742 callback_(callback), |
760 params_(params), | 743 params_(params), |
761 last_chunk_completed_(false) { | 744 last_chunk_completed_(false) { |
762 } | 745 } |
763 | 746 |
764 ResumeUploadOperation::~ResumeUploadOperation() {} | 747 ResumeUploadOperation::~ResumeUploadOperation() {} |
765 | 748 |
766 GURL ResumeUploadOperation::GetURL() const { | 749 GURL ResumeUploadOperation::GetURL() const { |
767 return params_.upload_location; | 750 return params_.upload_location; |
768 } | 751 } |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 | 873 |
891 void ResumeUploadOperation::OnURLFetchUploadProgress( | 874 void ResumeUploadOperation::OnURLFetchUploadProgress( |
892 const URLFetcher* source, int64 current, int64 total) { | 875 const URLFetcher* source, int64 current, int64 total) { |
893 // Adjust the progress values according to the range currently uploaded. | 876 // Adjust the progress values according to the range currently uploaded. |
894 NotifyProgress(params_.start_range + current, params_.content_length); | 877 NotifyProgress(params_.start_range + current, params_.content_length); |
895 } | 878 } |
896 | 879 |
897 //============================ GetContactsOperation ============================ | 880 //============================ GetContactsOperation ============================ |
898 | 881 |
899 GetContactsOperation::GetContactsOperation(GDataOperationRegistry* registry, | 882 GetContactsOperation::GetContactsOperation(GDataOperationRegistry* registry, |
900 Profile* profile, | |
901 const base::Time& min_update_time, | 883 const base::Time& min_update_time, |
902 const GetDataCallback& callback) | 884 const GetDataCallback& callback) |
903 : GetDataOperation(registry, profile, callback), | 885 : GetDataOperation(registry, callback), |
904 min_update_time_(min_update_time) { | 886 min_update_time_(min_update_time) { |
905 } | 887 } |
906 | 888 |
907 GetContactsOperation::~GetContactsOperation() {} | 889 GetContactsOperation::~GetContactsOperation() {} |
908 | 890 |
909 GURL GetContactsOperation::GetURL() const { | 891 GURL GetContactsOperation::GetURL() const { |
910 if (!feed_url_for_testing_.is_empty()) | 892 if (!feed_url_for_testing_.is_empty()) |
911 return GURL(feed_url_for_testing_); | 893 return GURL(feed_url_for_testing_); |
912 | 894 |
913 GURL url(kGetContactsURL); | 895 GURL url(kGetContactsURL); |
914 if (!min_update_time_.is_null()) { | 896 if (!min_update_time_.is_null()) { |
915 std::string time_rfc3339 = util::FormatTimeAsString(min_update_time_); | 897 std::string time_rfc3339 = util::FormatTimeAsString(min_update_time_); |
916 url = chrome_common_net::AppendQueryParameter( | 898 url = chrome_common_net::AppendQueryParameter( |
917 url, kGetContactsUpdatedMinParam, time_rfc3339); | 899 url, kGetContactsUpdatedMinParam, time_rfc3339); |
918 } | 900 } |
919 return url; | 901 return url; |
920 } | 902 } |
921 | 903 |
922 //========================== GetContactPhotoOperation ========================== | 904 //========================== GetContactPhotoOperation ========================== |
923 | 905 |
924 GetContactPhotoOperation::GetContactPhotoOperation( | 906 GetContactPhotoOperation::GetContactPhotoOperation( |
925 GDataOperationRegistry* registry, | 907 GDataOperationRegistry* registry, |
926 Profile* profile, | |
927 const GURL& photo_url, | 908 const GURL& photo_url, |
928 const GetDownloadDataCallback& callback) | 909 const GetDownloadDataCallback& callback) |
929 : UrlFetchOperationBase(registry, profile), | 910 : UrlFetchOperationBase(registry), |
930 photo_url_(photo_url), | 911 photo_url_(photo_url), |
931 callback_(callback) { | 912 callback_(callback) { |
932 } | 913 } |
933 | 914 |
934 GetContactPhotoOperation::~GetContactPhotoOperation() {} | 915 GetContactPhotoOperation::~GetContactPhotoOperation() {} |
935 | 916 |
936 GURL GetContactPhotoOperation::GetURL() const { | 917 GURL GetContactPhotoOperation::GetURL() const { |
937 return photo_url_; | 918 return photo_url_; |
938 } | 919 } |
939 | 920 |
940 void GetContactPhotoOperation::ProcessURLFetchResults( | 921 void GetContactPhotoOperation::ProcessURLFetchResults( |
941 const net::URLFetcher* source) { | 922 const net::URLFetcher* source) { |
942 GDataErrorCode code = static_cast<GDataErrorCode>(source->GetResponseCode()); | 923 GDataErrorCode code = static_cast<GDataErrorCode>(source->GetResponseCode()); |
943 scoped_ptr<std::string> data(new std::string); | 924 scoped_ptr<std::string> data(new std::string); |
944 source->GetResponseAsString(data.get()); | 925 source->GetResponseAsString(data.get()); |
945 callback_.Run(code, data.Pass()); | 926 callback_.Run(code, data.Pass()); |
946 OnProcessURLFetchResultsComplete(code == HTTP_SUCCESS); | 927 OnProcessURLFetchResultsComplete(code == HTTP_SUCCESS); |
947 } | 928 } |
948 | 929 |
949 void GetContactPhotoOperation::RunCallbackOnPrematureFailure( | 930 void GetContactPhotoOperation::RunCallbackOnPrematureFailure( |
950 GDataErrorCode code) { | 931 GDataErrorCode code) { |
951 scoped_ptr<std::string> data(new std::string); | 932 scoped_ptr<std::string> data(new std::string); |
952 callback_.Run(code, data.Pass()); | 933 callback_.Run(code, data.Pass()); |
953 } | 934 } |
954 | 935 |
955 } // namespace gdata | 936 } // namespace gdata |
OLD | NEW |