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> |
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/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
17 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
18 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 19 #include "base/threading/sequenced_worker_pool.h" |
19 #include "base/time/time.h" | 20 #include "base/time/time.h" |
20 #include "base/timer/timer.h" | 21 #include "base/timer/timer.h" |
21 #include "base/values.h" | 22 #include "base/values.h" |
22 #include "chrome/browser/chromeos/contacts/contact.pb.h" | 23 #include "chrome/browser/chromeos/contacts/contact.pb.h" |
23 #include "chrome/browser/google_apis/gdata_contacts_requests.h" | 24 #include "chrome/browser/google_apis/gdata_contacts_requests.h" |
24 #include "chrome/browser/google_apis/gdata_errorcode.h" | 25 #include "chrome/browser/google_apis/gdata_errorcode.h" |
25 #include "chrome/browser/google_apis/request_sender.h" | 26 #include "chrome/browser/google_apis/request_sender.h" |
26 #include "chrome/browser/google_apis/time_util.h" | 27 #include "chrome/browser/google_apis/time_util.h" |
27 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
28 | 29 |
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 }; | 850 }; |
850 | 851 |
851 GDataContactsService::GDataContactsService( | 852 GDataContactsService::GDataContactsService( |
852 net::URLRequestContextGetter* url_request_context_getter, | 853 net::URLRequestContextGetter* url_request_context_getter, |
853 Profile* profile) | 854 Profile* profile) |
854 : max_photo_downloads_per_second_(kMaxPhotoDownloadsPerSecond), | 855 : max_photo_downloads_per_second_(kMaxPhotoDownloadsPerSecond), |
855 photo_download_timer_interval_(base::TimeDelta::FromSeconds(1)) { | 856 photo_download_timer_interval_(base::TimeDelta::FromSeconds(1)) { |
856 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 857 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
857 std::vector<std::string> scopes; | 858 std::vector<std::string> scopes; |
858 scopes.push_back(kContactsScope); | 859 scopes.push_back(kContactsScope); |
859 sender_.reset(new google_apis::RequestSender(profile, | 860 sender_.reset(new google_apis::RequestSender( |
860 url_request_context_getter, | 861 profile, |
861 scopes, | 862 url_request_context_getter, |
862 "" /* custom_user_agent */)); | 863 content::BrowserThread::GetBlockingPool(), |
| 864 scopes, |
| 865 "" /* custom_user_agent */)); |
863 } | 866 } |
864 | 867 |
865 GDataContactsService::~GDataContactsService() { | 868 GDataContactsService::~GDataContactsService() { |
866 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 869 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
867 STLDeleteContainerPointers(requests_.begin(), requests_.end()); | 870 STLDeleteContainerPointers(requests_.begin(), requests_.end()); |
868 requests_.clear(); | 871 requests_.clear(); |
869 } | 872 } |
870 | 873 |
871 google_apis::AuthService* GDataContactsService::auth_service_for_testing() { | 874 google_apis::AuthService* GDataContactsService::auth_service_for_testing() { |
872 return sender_->auth_service(); | 875 return sender_->auth_service(); |
(...skipping 23 matching lines...) Expand all Loading... |
896 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 899 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
897 DCHECK(request); | 900 DCHECK(request); |
898 VLOG(1) << "Download request " << request << " complete"; | 901 VLOG(1) << "Download request " << request << " complete"; |
899 if (!request->my_contacts_group_id().empty()) | 902 if (!request->my_contacts_group_id().empty()) |
900 cached_my_contacts_group_id_ = request->my_contacts_group_id(); | 903 cached_my_contacts_group_id_ = request->my_contacts_group_id(); |
901 requests_.erase(request); | 904 requests_.erase(request); |
902 delete request; | 905 delete request; |
903 } | 906 } |
904 | 907 |
905 } // namespace contacts | 908 } // namespace contacts |
OLD | NEW |