| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_DRIVER_H_ | 5 #ifndef COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_DRIVER_H_ |
| 6 #define COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_DRIVER_H_ | 6 #define COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_DRIVER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 // implementation. | 23 // implementation. |
| 24 class InstanceIDDriver { | 24 class InstanceIDDriver { |
| 25 public: | 25 public: |
| 26 // Returns whether InstanceID is enabled. | 26 // Returns whether InstanceID is enabled. |
| 27 static bool IsInstanceIDEnabled(); | 27 static bool IsInstanceIDEnabled(); |
| 28 | 28 |
| 29 explicit InstanceIDDriver(gcm::GCMDriver* gcm_driver); | 29 explicit InstanceIDDriver(gcm::GCMDriver* gcm_driver); |
| 30 virtual ~InstanceIDDriver(); | 30 virtual ~InstanceIDDriver(); |
| 31 | 31 |
| 32 // Returns the InstanceID that provides the Instance ID service for the given | 32 // Returns the InstanceID that provides the Instance ID service for the given |
| 33 // application. The lifetime of InstanceID will be managed by this class. | 33 // application. The lifetime of the InstanceID will be managed by this class. |
| 34 InstanceID* GetInstanceID(const std::string& app_id); | 34 InstanceID* GetInstanceID(const std::string& app_id); |
| 35 | 35 |
| 36 // Like |GetInstanceID|, except that for historical reasons, Chrome Apps and |
| 37 // Extensions send the |app_id| to GCM as a "category" instead of a "subtype". |
| 38 // Not recommended for new code, since this does not (and cannot) support |
| 39 // Android, and switching between this and |GetInstanceID| is not supported (a |
| 40 // given |app_id| must either always use |GetInstanceID| or always use |
| 41 // |GetInstanceIDForExtensions|, even across Chrome versions). |
| 42 InstanceID* GetInstanceIDForExtensions(const std::string& app_id); |
| 43 |
| 36 // Removes the InstanceID when it is not longer needed, i.e. the app is being | 44 // Removes the InstanceID when it is not longer needed, i.e. the app is being |
| 37 // uninstalled. | 45 // uninstalled. |
| 38 void RemoveInstanceID(const std::string& app_id); | 46 void RemoveInstanceID(const std::string& app_id); |
| 39 | 47 |
| 40 // Returns true if the InstanceID for the given application has been created. | 48 // Returns true if the InstanceID for the given application has been created. |
| 41 // This is currently only used for testing purpose. | 49 // This is currently only used for testing purpose. |
| 42 bool ExistsInstanceID(const std::string& app_id) const; | 50 bool ExistsInstanceID(const std::string& app_id) const; |
| 43 | 51 |
| 44 private: | 52 private: |
| 53 InstanceID* GetInstanceID(const std::string& app_id, bool use_subtype); |
| 54 |
| 45 // Owned by GCMProfileServiceFactory, which is a dependency of | 55 // Owned by GCMProfileServiceFactory, which is a dependency of |
| 46 // InstanceIDProfileServiceFactory, which owns this. | 56 // InstanceIDProfileServiceFactory, which owns this. |
| 47 gcm::GCMDriver* gcm_driver_; | 57 gcm::GCMDriver* gcm_driver_; |
| 48 | 58 |
| 49 std::map<std::string, std::unique_ptr<InstanceID>> instance_id_map_; | 59 std::map<std::string, std::unique_ptr<InstanceID>> instance_id_map_; |
| 50 | 60 |
| 51 DISALLOW_COPY_AND_ASSIGN(InstanceIDDriver); | 61 DISALLOW_COPY_AND_ASSIGN(InstanceIDDriver); |
| 52 }; | 62 }; |
| 53 | 63 |
| 54 } // namespace instance_id | 64 } // namespace instance_id |
| 55 | 65 |
| 56 #endif // COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_DRIVER_H_ | 66 #endif // COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_DRIVER_H_ |
| OLD | NEW |