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 // The GCMDriver could be NULL if GCMProfileService has been shut down. | |
| 26 if (!gcm_profile_service_->driver()) | |
| 27 return; | |
| 28 std::vector<std::string> sender_ids(1, sender_id); | |
| 29 gcm_profile_service_->driver()->Register( | |
| 30 app_id, | |
| 31 sender_ids, | |
| 32 base::Bind(&PushMessagingServiceImpl::DidRegister, | |
| 33 base::Unretained(this), | |
|
fgorski
2014/06/09 17:43:49
This does not look safe, as you don't have any add
johnme
2014/06/09 19:04:45
I think it probably was safe, as this is a member
| |
| 34 callback)); | |
| 35 } | |
| 36 | |
| 37 void PushMessagingServiceImpl::DidRegister( | |
| 38 const content::PushMessagingService::RegisterCallback& callback, | |
| 39 const std::string& registration_id, | |
| 40 GCMClient::Result result) { | |
| 41 GURL endpoint = GURL("https://android.googleapis.com/gcm/send"); | |
| 42 bool error = (result != GCMClient::SUCCESS); | |
| 43 callback.Run(endpoint, registration_id, error); | |
| 44 } | |
| 45 | |
| 46 } // namespace gcm | |
| OLD | NEW |