Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/services/gcm/push_messaging_service_impl.h" | |
| 6 | |
| 7 #include <vector> | |
| 8 | |
| 9 #include "base/bind.h" | |
| 10 #include "chrome/browser/services/gcm/gcm_profile_service.h" | |
| 11 #include "components/gcm_driver/gcm_driver.h" | |
| 12 | |
| 13 namespace gcm { | |
| 14 | |
| 15 PushMessagingServiceImpl::PushMessagingServiceImpl( | |
| 16 GCMProfileService* gcm_profile_service) | |
| 17 : gcm_profile_service_(gcm_profile_service) {} | |
| 18 | |
| 19 PushMessagingServiceImpl::~PushMessagingServiceImpl() {} | |
| 20 | |
| 21 void PushMessagingServiceImpl::Register( | |
| 22 const std::string& app_id, | |
| 23 const std::string& sender_id, | |
| 24 const content::PushMessagingService::RegisterCallback& callback) { | |
| 25 if (!gcm_profile_service_->driver()) | |
|
jianli
2014/06/06 17:32:21
Please comment that GCMDriver could be NULL due to
johnme
2014/06/06 18:48:25
I added the comment, since in the current approach
| |
| 26 return; | |
| 27 std::vector<std::string> sender_ids(1, sender_id); | |
| 28 gcm_profile_service_->driver()->Register( | |
| 29 app_id, | |
| 30 sender_ids, | |
| 31 base::Bind(&PushMessagingServiceImpl::DidRegister, | |
| 32 base::Unretained(this), | |
| 33 callback)); | |
| 34 } | |
| 35 | |
| 36 void PushMessagingServiceImpl::DidRegister( | |
| 37 const content::PushMessagingService::RegisterCallback& callback, | |
| 38 const std::string& registration_id, | |
| 39 GCMClient::Result result) { | |
| 40 GURL endpoint = GURL("https://android.googleapis.com/gcm/send"); | |
| 41 bool error = (result != GCMClient::SUCCESS); | |
| 42 callback.Run(endpoint, registration_id, error); | |
| 43 } | |
| 44 | |
| 45 } // namespace gcm | |
| OLD | NEW |