| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_SERVICE_IMPL_H_ | 5 #ifndef CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_SERVICE_IMPL_H_ |
| 6 #define CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_SERVICE_IMPL_H_ | 6 #define CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_SERVICE_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "components/gcm_driver/gcm_app_handler.h" |
| 10 #include "components/gcm_driver/gcm_client.h" | 11 #include "components/gcm_driver/gcm_client.h" |
| 11 #include "content/public/browser/push_messaging_service.h" | 12 #include "content/public/browser/push_messaging_service.h" |
| 12 | 13 |
| 13 namespace gcm { | 14 namespace gcm { |
| 14 | 15 |
| 15 class GCMProfileService; | 16 class GCMProfileService; |
| 16 | 17 |
| 17 class PushMessagingServiceImpl : public content::PushMessagingService { | 18 class PushMessagingServiceImpl : public content::PushMessagingService, |
| 19 public GCMAppHandler { |
| 18 public: | 20 public: |
| 19 explicit PushMessagingServiceImpl(GCMProfileService* gcm_profile_service); | 21 explicit PushMessagingServiceImpl(GCMProfileService* gcm_profile_service); |
| 20 virtual ~PushMessagingServiceImpl(); | 22 virtual ~PushMessagingServiceImpl(); |
| 21 | 23 |
| 24 base::WeakPtr<PushMessagingServiceImpl> GetWeakPtr(); |
| 25 |
| 26 void LazyLoadAppHandlers(); |
| 27 |
| 28 // GCMAppHandler implementation. |
| 29 virtual void ShutdownHandler() OVERRIDE; |
| 30 virtual void OnMessage(const std::string& app_id, |
| 31 const GCMClient::IncomingMessage& message) OVERRIDE; |
| 32 virtual void OnMessagesDeleted(const std::string& app_id) OVERRIDE; |
| 33 virtual void OnSendError( |
| 34 const std::string& app_id, |
| 35 const GCMClient::SendErrorDetails& send_error_details) OVERRIDE; |
| 36 |
| 22 // content::PushMessagingService implementation: | 37 // content::PushMessagingService implementation: |
| 23 virtual void Register( | 38 virtual void Register( |
| 24 const std::string& app_id, | 39 const std::string& app_id, |
| 25 const std::string& sender_id, | 40 const std::string& sender_id, |
| 26 const content::PushMessagingService::RegisterCallback& callback) OVERRIDE; | 41 const content::PushMessagingService::RegisterCallback& callback) OVERRIDE; |
| 27 | 42 |
| 28 private: | 43 private: |
| 29 void DidRegister( | 44 void DidRegister( |
| 30 const content::PushMessagingService::RegisterCallback& callback, | 45 const content::PushMessagingService::RegisterCallback& callback, |
| 31 const std::string& registration_id, | 46 const std::string& registration_id, |
| 32 GCMClient::Result result); | 47 GCMClient::Result result); |
| 33 | 48 |
| 34 GCMProfileService* gcm_profile_service_; // It owns us. | 49 GCMProfileService* gcm_profile_service_; // It owns us. |
| 35 | 50 |
| 36 base::WeakPtrFactory<PushMessagingServiceImpl> weak_factory_; | 51 base::WeakPtrFactory<PushMessagingServiceImpl> weak_factory_; |
| 37 | 52 |
| 38 DISALLOW_COPY_AND_ASSIGN(PushMessagingServiceImpl); | 53 DISALLOW_COPY_AND_ASSIGN(PushMessagingServiceImpl); |
| 39 }; | 54 }; |
| 40 | 55 |
| 41 } // namespace gcm | 56 } // namespace gcm |
| 42 | 57 |
| 43 #endif // CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_SERVICE_IMPL_H_ | 58 #endif // CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_SERVICE_IMPL_H_ |
| OLD | NEW |