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

Side by Side Diff: chrome/browser/services/gcm/gcm_profile_service.cc

Issue 176823009: Show device information in chrome://gcm-internals page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/services/gcm/gcm_profile_service.h" 5 #include "chrome/browser/services/gcm/gcm_profile_service.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 url_request_context_getter); 265 url_request_context_getter);
266 void Reset(); 266 void Reset();
267 void CheckOut(); 267 void CheckOut();
268 void Register(const std::string& app_id, 268 void Register(const std::string& app_id,
269 const std::vector<std::string>& sender_ids, 269 const std::vector<std::string>& sender_ids,
270 const std::string& cert); 270 const std::string& cert);
271 void Unregister(const std::string& app_id); 271 void Unregister(const std::string& app_id);
272 void Send(const std::string& app_id, 272 void Send(const std::string& app_id,
273 const std::string& receiver_id, 273 const std::string& receiver_id,
274 const GCMClient::OutgoingMessage& message); 274 const GCMClient::OutgoingMessage& message);
275 GCMClient* GetGCMClient();
275 276
276 private: 277 private:
277 friend class base::RefCountedThreadSafe<IOWorker>; 278 friend class base::RefCountedThreadSafe<IOWorker>;
278 virtual ~IOWorker(); 279 virtual ~IOWorker();
279 280
280 const base::WeakPtr<GCMProfileService> service_; 281 const base::WeakPtr<GCMProfileService> service_;
281 282
282 scoped_ptr<GCMClient> gcm_client_; 283 scoped_ptr<GCMClient> gcm_client_;
283 }; 284 };
284 285
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 448
448 void GCMProfileService::IOWorker::Send( 449 void GCMProfileService::IOWorker::Send(
449 const std::string& app_id, 450 const std::string& app_id,
450 const std::string& receiver_id, 451 const std::string& receiver_id,
451 const GCMClient::OutgoingMessage& message) { 452 const GCMClient::OutgoingMessage& message) {
452 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 453 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
453 454
454 gcm_client_->Send(app_id, receiver_id, message); 455 gcm_client_->Send(app_id, receiver_id, message);
455 } 456 }
456 457
458 GCMClient* GCMProfileService::IOWorker::GetGCMClient() {
459 return gcm_client_.get();
460 }
461
457 GCMProfileService::RegistrationInfo::RegistrationInfo() { 462 GCMProfileService::RegistrationInfo::RegistrationInfo() {
458 } 463 }
459 464
460 GCMProfileService::RegistrationInfo::~RegistrationInfo() { 465 GCMProfileService::RegistrationInfo::~RegistrationInfo() {
461 } 466 }
462 467
463 bool GCMProfileService::RegistrationInfo::IsValid() const { 468 bool GCMProfileService::RegistrationInfo::IsValid() const {
464 return !sender_ids.empty() && !registration_id.empty(); 469 return !sender_ids.empty() && !registration_id.empty();
465 } 470 }
466 471
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 content::BrowserThread::PostTask( 678 content::BrowserThread::PostTask(
674 content::BrowserThread::IO, 679 content::BrowserThread::IO,
675 FROM_HERE, 680 FROM_HERE,
676 base::Bind(&GCMProfileService::IOWorker::Send, 681 base::Bind(&GCMProfileService::IOWorker::Send,
677 io_worker_, 682 io_worker_,
678 app_id, 683 app_id,
679 receiver_id, 684 receiver_id,
680 message)); 685 message));
681 } 686 }
682 687
688 bool GCMProfileService::IsSignedIn() {
689 return !username_.empty();
690 }
691
692 GCMClient* GCMProfileService::GetGCMClient() {
693 return io_worker_->GetGCMClient();
694 }
695
683 void GCMProfileService::Observe(int type, 696 void GCMProfileService::Observe(int type,
684 const content::NotificationSource& source, 697 const content::NotificationSource& source,
685 const content::NotificationDetails& details) { 698 const content::NotificationDetails& details) {
686 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 699 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
687 700
688 switch (type) { 701 switch (type) {
689 case chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL: { 702 case chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL: {
690 const GoogleServiceSigninSuccessDetails* signin_details = 703 const GoogleServiceSigninSuccessDetails* signin_details =
691 content::Details<GoogleServiceSigninSuccessDetails>(details).ptr(); 704 content::Details<GoogleServiceSigninSuccessDetails>(details).ptr();
692 // This could be called multiple times when the password changed. 705 // This could be called multiple times when the password changed.
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 1055
1043 return true; 1056 return true;
1044 } 1057 }
1045 1058
1046 // static 1059 // static
1047 const char* GCMProfileService::GetPersistentRegisterKeyForTesting() { 1060 const char* GCMProfileService::GetPersistentRegisterKeyForTesting() {
1048 return kRegistrationKey; 1061 return kRegistrationKey;
1049 } 1062 }
1050 1063
1051 } // namespace gcm 1064 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698