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_IMPL_H_ | 5 #ifndef COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_IMPL_H_ |
6 #define COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_IMPL_H_ | 6 #define COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "components/gcm_driver/gcm_client.h" | 16 #include "components/gcm_driver/gcm_client.h" |
17 #include "components/gcm_driver/gcm_delayed_task_controller.h" | 17 #include "components/gcm_driver/gcm_delayed_task_controller.h" |
18 #include "components/gcm_driver/instance_id/instance_id.h" | 18 #include "components/gcm_driver/instance_id/instance_id.h" |
19 | 19 |
20 namespace gcm { | 20 namespace gcm { |
21 class GCMDriver; | 21 class GCMDriver; |
22 class InstanceIDHandler; | 22 class InstanceIDHandler; |
23 } // namespace gcm | 23 } // namespace gcm |
24 | 24 |
25 namespace instance_id { | 25 namespace instance_id { |
26 | 26 |
27 // InstanceID implementation for desktop and iOS. | 27 // InstanceID implementation for desktop and iOS. |
28 class InstanceIDImpl : public InstanceID { | 28 class InstanceIDImpl : public InstanceID { |
29 public: | 29 public: |
30 InstanceIDImpl(const std::string& app_id, gcm::GCMDriver* gcm_driver); | 30 InstanceIDImpl(const std::string& app_id, |
| 31 bool use_subtype, |
| 32 gcm::GCMDriver* gcm_driver); |
31 ~InstanceIDImpl() override; | 33 ~InstanceIDImpl() override; |
32 | 34 |
33 // InstanceID: | 35 // InstanceID: |
34 void GetID(const GetIDCallback& callback) override; | 36 void GetID(const GetIDCallback& callback) override; |
35 void GetCreationTime(const GetCreationTimeCallback& callback) override; | 37 void GetCreationTime(const GetCreationTimeCallback& callback) override; |
36 void GetToken(const std::string& authorized_entity, | 38 void GetToken(const std::string& authorized_entity, |
37 const std::string& scope, | 39 const std::string& scope, |
38 const std::map<std::string, std::string>& options, | 40 const std::map<std::string, std::string>& options, |
39 const GetTokenCallback& callback) override; | 41 const GetTokenCallback& callback) override; |
40 void DeleteTokenImpl(const std::string& authorized_entity, | 42 void DeleteTokenImpl(const std::string& authorized_entity, |
(...skipping 21 matching lines...) Expand all Loading... |
62 const std::string& scope, | 64 const std::string& scope, |
63 const std::map<std::string, std::string>& options, | 65 const std::map<std::string, std::string>& options, |
64 const GetTokenCallback& callback); | 66 const GetTokenCallback& callback); |
65 void DoDeleteToken(const std::string& authorized_entity, | 67 void DoDeleteToken(const std::string& authorized_entity, |
66 const std::string& scope, | 68 const std::string& scope, |
67 const DeleteTokenCallback& callback); | 69 const DeleteTokenCallback& callback); |
68 void DoDeleteID(const DeleteIDCallback& callback); | 70 void DoDeleteID(const DeleteIDCallback& callback); |
69 | 71 |
70 gcm::InstanceIDHandler* Handler(); | 72 gcm::InstanceIDHandler* Handler(); |
71 | 73 |
| 74 // Whether to send |app_id| to GCM as a "subtype" instead of a "category". |
| 75 bool use_subtype_; |
| 76 |
72 gcm::GCMDelayedTaskController delayed_task_controller_; | 77 gcm::GCMDelayedTaskController delayed_task_controller_; |
73 | 78 |
74 // The generated Instance ID. | 79 // The generated Instance ID. |
75 std::string id_; | 80 std::string id_; |
76 | 81 |
77 // The time when the Instance ID has been generated. | 82 // The time when the Instance ID has been generated. |
78 base::Time creation_time_; | 83 base::Time creation_time_; |
79 | 84 |
80 base::WeakPtrFactory<InstanceIDImpl> weak_ptr_factory_; | 85 base::WeakPtrFactory<InstanceIDImpl> weak_ptr_factory_; |
81 | 86 |
82 DISALLOW_COPY_AND_ASSIGN(InstanceIDImpl); | 87 DISALLOW_COPY_AND_ASSIGN(InstanceIDImpl); |
83 }; | 88 }; |
84 | 89 |
85 } // namespace instance_id | 90 } // namespace instance_id |
86 | 91 |
87 #endif // COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_IMPL_H_ | 92 #endif // COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_IMPL_H_ |
OLD | NEW |