| 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/contacts/gdata_contacts_service.h" | 5 #include "chrome/browser/chromeos/contacts/gdata_contacts_service.h" |
| 6 | 6 |
| 7 #include <cstring> | 7 #include <cstring> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 // group has previously been cached, then the contacts download is started. | 473 // group has previously been cached, then the contacts download is started. |
| 474 // Otherwise, the contact groups download is started. | 474 // Otherwise, the contact groups download is started. |
| 475 void Run() { | 475 void Run() { |
| 476 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 476 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 477 download_start_time_ = base::TimeTicks::Now(); | 477 download_start_time_ = base::TimeTicks::Now(); |
| 478 if (!my_contacts_group_id_.empty()) { | 478 if (!my_contacts_group_id_.empty()) { |
| 479 StartContactsDownload(); | 479 StartContactsDownload(); |
| 480 } else { | 480 } else { |
| 481 google_apis::GetContactGroupsOperation* operation = | 481 google_apis::GetContactGroupsOperation* operation = |
| 482 new google_apis::GetContactGroupsOperation( | 482 new google_apis::GetContactGroupsOperation( |
| 483 runner_->operation_registry(), | 483 runner_, |
| 484 url_request_context_getter_, | 484 url_request_context_getter_, |
| 485 base::Bind(&DownloadContactsRequest::HandleGroupsFeedData, | 485 base::Bind(&DownloadContactsRequest::HandleGroupsFeedData, |
| 486 weak_ptr_factory_.GetWeakPtr())); | 486 weak_ptr_factory_.GetWeakPtr())); |
| 487 if (!service_->groups_feed_url_for_testing_.is_empty()) { | 487 if (!service_->groups_feed_url_for_testing_.is_empty()) { |
| 488 operation->set_feed_url_for_testing( | 488 operation->set_feed_url_for_testing( |
| 489 service_->groups_feed_url_for_testing_); | 489 service_->groups_feed_url_for_testing_); |
| 490 } | 490 } |
| 491 runner_->StartOperationWithRetry(operation); | 491 runner_->StartOperationWithRetry(operation); |
| 492 } | 492 } |
| 493 } | 493 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 LOG(WARNING) << "Unable to find ID for \"My Contacts\" group"; | 581 LOG(WARNING) << "Unable to find ID for \"My Contacts\" group"; |
| 582 ReportFailure(HISTOGRAM_RESULT_MY_CONTACTS_GROUP_NOT_FOUND); | 582 ReportFailure(HISTOGRAM_RESULT_MY_CONTACTS_GROUP_NOT_FOUND); |
| 583 } | 583 } |
| 584 } | 584 } |
| 585 | 585 |
| 586 // Starts a download of the contacts from the "My Contacts" group. | 586 // Starts a download of the contacts from the "My Contacts" group. |
| 587 void StartContactsDownload() { | 587 void StartContactsDownload() { |
| 588 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 588 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 589 google_apis::GetContactsOperation* operation = | 589 google_apis::GetContactsOperation* operation = |
| 590 new google_apis::GetContactsOperation( | 590 new google_apis::GetContactsOperation( |
| 591 runner_->operation_registry(), | 591 runner_, |
| 592 url_request_context_getter_, | 592 url_request_context_getter_, |
| 593 my_contacts_group_id_, | 593 my_contacts_group_id_, |
| 594 min_update_time_, | 594 min_update_time_, |
| 595 base::Bind(&DownloadContactsRequest::HandleContactsFeedData, | 595 base::Bind(&DownloadContactsRequest::HandleContactsFeedData, |
| 596 weak_ptr_factory_.GetWeakPtr())); | 596 weak_ptr_factory_.GetWeakPtr())); |
| 597 if (!service_->contacts_feed_url_for_testing_.is_empty()) { | 597 if (!service_->contacts_feed_url_for_testing_.is_empty()) { |
| 598 operation->set_feed_url_for_testing( | 598 operation->set_feed_url_for_testing( |
| 599 service_->contacts_feed_url_for_testing_); | 599 service_->contacts_feed_url_for_testing_); |
| 600 } | 600 } |
| 601 runner_->StartOperationWithRetry(operation); | 601 runner_->StartOperationWithRetry(operation); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 service_->max_photo_downloads_per_second_)) { | 738 service_->max_photo_downloads_per_second_)) { |
| 739 contacts::Contact* contact = contacts_needing_photo_downloads_.back(); | 739 contacts::Contact* contact = contacts_needing_photo_downloads_.back(); |
| 740 contacts_needing_photo_downloads_.pop_back(); | 740 contacts_needing_photo_downloads_.pop_back(); |
| 741 DCHECK(contact_photo_urls_.count(contact)); | 741 DCHECK(contact_photo_urls_.count(contact)); |
| 742 std::string url = contact_photo_urls_[contact]; | 742 std::string url = contact_photo_urls_[contact]; |
| 743 | 743 |
| 744 VLOG(1) << "Starting download of photo " << url << " for " | 744 VLOG(1) << "Starting download of photo " << url << " for " |
| 745 << contact->contact_id(); | 745 << contact->contact_id(); |
| 746 runner_->StartOperationWithRetry( | 746 runner_->StartOperationWithRetry( |
| 747 new google_apis::GetContactPhotoOperation( | 747 new google_apis::GetContactPhotoOperation( |
| 748 runner_->operation_registry(), | 748 runner_, |
| 749 url_request_context_getter_, | 749 url_request_context_getter_, |
| 750 GURL(url), | 750 GURL(url), |
| 751 base::Bind(&DownloadContactsRequest::HandlePhotoData, | 751 base::Bind(&DownloadContactsRequest::HandlePhotoData, |
| 752 weak_ptr_factory_.GetWeakPtr(), | 752 weak_ptr_factory_.GetWeakPtr(), |
| 753 contact))); | 753 contact))); |
| 754 num_in_progress_photo_downloads_++; | 754 num_in_progress_photo_downloads_++; |
| 755 } | 755 } |
| 756 } | 756 } |
| 757 | 757 |
| 758 // Callback for GetContactPhotoOperation calls. Updates the associated | 758 // Callback for GetContactPhotoOperation calls. Updates the associated |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 905 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 906 DCHECK(request); | 906 DCHECK(request); |
| 907 VLOG(1) << "Download request " << request << " complete"; | 907 VLOG(1) << "Download request " << request << " complete"; |
| 908 if (!request->my_contacts_group_id().empty()) | 908 if (!request->my_contacts_group_id().empty()) |
| 909 cached_my_contacts_group_id_ = request->my_contacts_group_id(); | 909 cached_my_contacts_group_id_ = request->my_contacts_group_id(); |
| 910 requests_.erase(request); | 910 requests_.erase(request); |
| 911 delete request; | 911 delete request; |
| 912 } | 912 } |
| 913 | 913 |
| 914 } // namespace contacts | 914 } // namespace contacts |
| OLD | NEW |