Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(284)

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_contacts_service.cc

Issue 10837338: Remove "GData" prefix from non-GData specific classes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_contacts_service.h" 5 #include "chrome/browser/chromeos/gdata/gdata_contacts_service.h"
6 6
7 #include <cstring> 7 #include <cstring>
8 #include <string> 8 #include <string>
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/json/json_value_converter.h" 12 #include "base/json/json_value_converter.h"
13 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/stl_util.h" 16 #include "base/stl_util.h"
17 #include "base/time.h" 17 #include "base/time.h"
18 #include "base/timer.h" 18 #include "base/timer.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "chrome/browser/chromeos/contacts/contact.pb.h" 20 #include "chrome/browser/chromeos/contacts/contact.pb.h"
21 #include "chrome/browser/chromeos/gdata/gdata_operation_registry.h"
22 #include "chrome/browser/chromeos/gdata/gdata_operation_runner.h"
23 #include "chrome/browser/chromeos/gdata/gdata_operations.h" 21 #include "chrome/browser/chromeos/gdata/gdata_operations.h"
24 #include "chrome/browser/chromeos/gdata/gdata_util.h" 22 #include "chrome/browser/chromeos/gdata/gdata_util.h"
23 #include "chrome/browser/chromeos/gdata/operation_registry.h"
24 #include "chrome/browser/chromeos/gdata/operation_runner.h"
25 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
26 26
27 using content::BrowserThread; 27 using content::BrowserThread;
28 28
29 namespace gdata { 29 namespace gdata {
30 30
31 namespace { 31 namespace {
32 32
33 // Maximum number of profile photos that we'll download per second. 33 // Maximum number of profile photos that we'll download per second.
34 // At values above 10, Google starts returning 503 errors. 34 // At values above 10, Google starts returning 503 errors.
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 // Next, the contacts feed is downloaded via GetContactsOperation and parsed. 387 // Next, the contacts feed is downloaded via GetContactsOperation and parsed.
388 // Individual contacts::Contact objects are created using the data from the 388 // Individual contacts::Contact objects are created using the data from the
389 // feed. 389 // feed.
390 // 390 //
391 // Finally, GetContactPhotoOperations are created and used to start downloading 391 // Finally, GetContactPhotoOperations are created and used to start downloading
392 // contacts' photos in parallel. When all photos have been downloaded, the 392 // contacts' photos in parallel. When all photos have been downloaded, the
393 // contacts are passed to the passed-in callback. 393 // contacts are passed to the passed-in callback.
394 class GDataContactsService::DownloadContactsRequest { 394 class GDataContactsService::DownloadContactsRequest {
395 public: 395 public:
396 DownloadContactsRequest(GDataContactsService* service, 396 DownloadContactsRequest(GDataContactsService* service,
397 GDataOperationRunner* runner, 397 OperationRunner* runner,
398 SuccessCallback success_callback, 398 SuccessCallback success_callback,
399 FailureCallback failure_callback, 399 FailureCallback failure_callback,
400 const base::Time& min_update_time) 400 const base::Time& min_update_time)
401 : service_(service), 401 : service_(service),
402 runner_(runner), 402 runner_(runner),
403 success_callback_(success_callback), 403 success_callback_(success_callback),
404 failure_callback_(failure_callback), 404 failure_callback_(failure_callback),
405 min_update_time_(min_update_time), 405 min_update_time_(min_update_time),
406 contacts_(new ScopedVector<contacts::Contact>), 406 contacts_(new ScopedVector<contacts::Contact>),
407 my_contacts_group_id_(service->cached_my_contacts_group_id_), 407 my_contacts_group_id_(service->cached_my_contacts_group_id_),
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 return; 691 return;
692 } 692 }
693 693
694 contact->set_raw_untrusted_photo(*download_data); 694 contact->set_raw_untrusted_photo(*download_data);
695 CheckCompletion(); 695 CheckCompletion();
696 } 696 }
697 697
698 typedef std::map<contacts::Contact*, std::string> ContactPhotoUrls; 698 typedef std::map<contacts::Contact*, std::string> ContactPhotoUrls;
699 699
700 GDataContactsService* service_; // not owned 700 GDataContactsService* service_; // not owned
701 GDataOperationRunner* runner_; // not owned 701 OperationRunner* runner_; // not owned
702 702
703 SuccessCallback success_callback_; 703 SuccessCallback success_callback_;
704 FailureCallback failure_callback_; 704 FailureCallback failure_callback_;
705 705
706 base::Time min_update_time_; 706 base::Time min_update_time_;
707 707
708 scoped_ptr<ScopedVector<contacts::Contact> > contacts_; 708 scoped_ptr<ScopedVector<contacts::Contact> > contacts_;
709 709
710 // ID of the "My Contacts" contacts group. 710 // ID of the "My Contacts" contacts group.
711 std::string my_contacts_group_id_; 711 std::string my_contacts_group_id_;
(...skipping 22 matching lines...) Expand all
734 bool photo_download_failed_; 734 bool photo_download_failed_;
735 735
736 // Note: This should remain the last member so it'll be destroyed and 736 // Note: This should remain the last member so it'll be destroyed and
737 // invalidate its weak pointers before any other members are destroyed. 737 // invalidate its weak pointers before any other members are destroyed.
738 base::WeakPtrFactory<DownloadContactsRequest> weak_ptr_factory_; 738 base::WeakPtrFactory<DownloadContactsRequest> weak_ptr_factory_;
739 739
740 DISALLOW_COPY_AND_ASSIGN(DownloadContactsRequest); 740 DISALLOW_COPY_AND_ASSIGN(DownloadContactsRequest);
741 }; 741 };
742 742
743 GDataContactsService::GDataContactsService(Profile* profile) 743 GDataContactsService::GDataContactsService(Profile* profile)
744 : runner_(new GDataOperationRunner(profile)), 744 : runner_(new OperationRunner(profile)),
745 max_photo_downloads_per_second_(kMaxPhotoDownloadsPerSecond), 745 max_photo_downloads_per_second_(kMaxPhotoDownloadsPerSecond),
746 photo_download_timer_interval_(base::TimeDelta::FromSeconds(1)) { 746 photo_download_timer_interval_(base::TimeDelta::FromSeconds(1)) {
747 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 747 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
748 } 748 }
749 749
750 GDataContactsService::~GDataContactsService() { 750 GDataContactsService::~GDataContactsService() {
751 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 751 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
752 runner_->CancelAll(); 752 runner_->CancelAll();
753 STLDeleteContainerPointers(requests_.begin(), requests_.end()); 753 STLDeleteContainerPointers(requests_.begin(), requests_.end());
754 requests_.clear(); 754 requests_.clear();
755 } 755 }
756 756
757 GDataAuthService* GDataContactsService::auth_service_for_testing() { 757 AuthService* GDataContactsService::auth_service_for_testing() {
758 return runner_->auth_service(); 758 return runner_->auth_service();
759 } 759 }
760 760
761 void GDataContactsService::Initialize() { 761 void GDataContactsService::Initialize() {
762 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 762 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
763 runner_->Initialize(); 763 runner_->Initialize();
764 } 764 }
765 765
766 void GDataContactsService::DownloadContacts(SuccessCallback success_callback, 766 void GDataContactsService::DownloadContacts(SuccessCallback success_callback,
767 FailureCallback failure_callback, 767 FailureCallback failure_callback,
(...skipping 14 matching lines...) Expand all
782 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 782 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
783 DCHECK(request); 783 DCHECK(request);
784 VLOG(1) << "Download request " << request << " complete"; 784 VLOG(1) << "Download request " << request << " complete";
785 if (!request->my_contacts_group_id().empty()) 785 if (!request->my_contacts_group_id().empty())
786 cached_my_contacts_group_id_ = request->my_contacts_group_id(); 786 cached_my_contacts_group_id_ = request->my_contacts_group_id();
787 requests_.erase(request); 787 requests_.erase(request);
788 delete request; 788 delete request;
789 } 789 }
790 790
791 } // namespace contacts 791 } // namespace contacts
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698