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