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_wapi_parser.h" | 10 #include "chrome/browser/chromeos/gdata/gdata_wapi_parser.h" |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 xml_writer.WriteElement("docs:authorizedApp", app_id_); | 495 xml_writer.WriteElement("docs:authorizedApp", app_id_); |
496 | 496 |
497 xml_writer.EndElement(); // Ends "entry" element. | 497 xml_writer.EndElement(); // Ends "entry" element. |
498 xml_writer.StopWriting(); | 498 xml_writer.StopWriting(); |
499 upload_content->assign(xml_writer.GetWrittenString()); | 499 upload_content->assign(xml_writer.GetWrittenString()); |
500 DVLOG(1) << "AuthorizeAppOperation data: " << *upload_content_type << ", [" | 500 DVLOG(1) << "AuthorizeAppOperation data: " << *upload_content_type << ", [" |
501 << *upload_content << "]"; | 501 << *upload_content << "]"; |
502 return true; | 502 return true; |
503 } | 503 } |
504 | 504 |
505 base::Value* AuthorizeAppsOperation::ParseResponse(const std::string& data) { | 505 bool AuthorizeAppsOperation::ParseResponse(GDataErrorCode fetch_error_code, |
| 506 const std::string& data) { |
506 // Parse entry XML. | 507 // Parse entry XML. |
507 XmlReader xml_reader; | 508 XmlReader xml_reader; |
508 scoped_ptr<DocumentEntry> entry; | 509 scoped_ptr<DocumentEntry> entry; |
509 if (xml_reader.Load(data)) { | 510 if (xml_reader.Load(data)) { |
510 while (xml_reader.Read()) { | 511 while (xml_reader.Read()) { |
511 if (xml_reader.NodeName() == DocumentEntry::GetEntryNodeName()) { | 512 if (xml_reader.NodeName() == DocumentEntry::GetEntryNodeName()) { |
512 entry.reset(DocumentEntry::CreateFromXml(&xml_reader)); | 513 entry.reset(DocumentEntry::CreateFromXml(&xml_reader)); |
513 break; | 514 break; |
514 } | 515 } |
515 } | 516 } |
516 } | 517 } |
517 | 518 |
518 // From the response, we create a list of the links returned, since those | 519 // From the response, we create a list of the links returned, since those |
519 // are the only things we are interested in. | 520 // are the only things we are interested in. |
520 scoped_ptr<base::ListValue> link_list(new ListValue); | 521 scoped_ptr<base::ListValue> link_list(new ListValue); |
521 const ScopedVector<Link>& feed_links = entry->links(); | 522 const ScopedVector<Link>& feed_links = entry->links(); |
522 for (ScopedVector<Link>::const_iterator iter = feed_links.begin(); | 523 for (ScopedVector<Link>::const_iterator iter = feed_links.begin(); |
523 iter != feed_links.end(); ++iter) { | 524 iter != feed_links.end(); ++iter) { |
524 if ((*iter)->type() == Link::OPEN_WITH) { | 525 if ((*iter)->type() == Link::OPEN_WITH) { |
525 base::DictionaryValue* link = new DictionaryValue; | 526 base::DictionaryValue* link = new DictionaryValue; |
526 link->SetString(std::string("href"), (*iter)->href().spec()); | 527 link->SetString(std::string("href"), (*iter)->href().spec()); |
527 link->SetString(std::string("mime_type"), (*iter)->mime_type()); | 528 link->SetString(std::string("mime_type"), (*iter)->mime_type()); |
528 link->SetString(std::string("title"), (*iter)->title()); | 529 link->SetString(std::string("title"), (*iter)->title()); |
529 link->SetString(std::string("app_id"), (*iter)->app_id()); | 530 link->SetString(std::string("app_id"), (*iter)->app_id()); |
530 link_list->Append(link); | 531 link_list->Append(link); |
531 } | 532 } |
532 } | 533 } |
533 | 534 |
534 return link_list.release(); | 535 RunCallback(fetch_error_code, link_list.PassAs<base::Value>()); |
| 536 return true; |
535 } | 537 } |
536 | 538 |
537 GURL AuthorizeAppsOperation::GetURL() const { | 539 GURL AuthorizeAppsOperation::GetURL() const { |
538 return document_url_; | 540 return document_url_; |
539 } | 541 } |
540 | 542 |
541 //======================= AddResourceToDirectoryOperation ====================== | 543 //======================= AddResourceToDirectoryOperation ====================== |
542 | 544 |
543 AddResourceToDirectoryOperation::AddResourceToDirectoryOperation( | 545 AddResourceToDirectoryOperation::AddResourceToDirectoryOperation( |
544 GDataOperationRegistry* registry, | 546 GDataOperationRegistry* registry, |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 return true; | 871 return true; |
870 } | 872 } |
871 | 873 |
872 void ResumeUploadOperation::OnURLFetchUploadProgress( | 874 void ResumeUploadOperation::OnURLFetchUploadProgress( |
873 const URLFetcher* source, int64 current, int64 total) { | 875 const URLFetcher* source, int64 current, int64 total) { |
874 // Adjust the progress values according to the range currently uploaded. | 876 // Adjust the progress values according to the range currently uploaded. |
875 NotifyProgress(params_.start_range + current, params_.content_length); | 877 NotifyProgress(params_.start_range + current, params_.content_length); |
876 } | 878 } |
877 | 879 |
878 } // namespace gdata | 880 } // namespace gdata |
OLD | NEW |