Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(736)

Side by Side Diff: components/gcm_driver/instance_id/instance_id_impl.h

Issue 1923953002: Integrate InstanceID with GCM crypto provider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@iid5default
Patch Set: RunUntilIdle after deleting GCMDriver Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 InstanceIDHandler; 22 class InstanceIDHandler;
22 } // namespace gcm 23 } // namespace gcm
23 24
24 namespace instance_id { 25 namespace instance_id {
25 26
26 // InstanceID implementation for desktop and iOS. 27 // InstanceID implementation for desktop and iOS.
27 class InstanceIDImpl : public InstanceID { 28 class InstanceIDImpl : public InstanceID {
28 public: 29 public:
29 InstanceIDImpl(const std::string& app_id, gcm::InstanceIDHandler* handler); 30 InstanceIDImpl(const std::string& app_id, gcm::GCMDriver* gcm_driver);
30 ~InstanceIDImpl() override; 31 ~InstanceIDImpl() override;
31 32
32 // InstanceID: 33 // InstanceID:
33 void GetID(const GetIDCallback& callback) override; 34 void GetID(const GetIDCallback& callback) override;
34 void GetCreationTime(const GetCreationTimeCallback& callback) override; 35 void GetCreationTime(const GetCreationTimeCallback& callback) override;
35 void GetToken(const std::string& authorized_entity, 36 void GetToken(const std::string& authorized_entity,
36 const std::string& scope, 37 const std::string& scope,
37 const std::map<std::string, std::string>& options, 38 const std::map<std::string, std::string>& options,
38 const GetTokenCallback& callback) override; 39 const GetTokenCallback& callback) override;
39 void DeleteToken(const std::string& authorized_entity, 40 void DeleteTokenImpl(const std::string& authorized_entity,
40 const std::string& scope, 41 const std::string& scope,
41 const DeleteTokenCallback& callback) override; 42 const DeleteTokenCallback& callback) override;
42 void DeleteID(const DeleteIDCallback& callback) override; 43 void DeleteIDImpl(const DeleteIDCallback& callback) override;
43 44
44 private: 45 private:
45 void EnsureIDGenerated(); 46 void EnsureIDGenerated();
46 47
47 void OnGetTokenCompleted(const GetTokenCallback& callback, 48 void OnGetTokenCompleted(const GetTokenCallback& callback,
48 const std::string& token, 49 const std::string& token,
49 gcm::GCMClient::Result result); 50 gcm::GCMClient::Result result);
50 void OnDeleteTokenCompleted(const DeleteTokenCallback& callback, 51 void OnDeleteTokenCompleted(const DeleteTokenCallback& callback,
51 gcm::GCMClient::Result result); 52 gcm::GCMClient::Result result);
52 void OnDeleteIDCompleted(const DeleteIDCallback& callback, 53 void OnDeleteIDCompleted(const DeleteIDCallback& callback,
53 gcm::GCMClient::Result result); 54 gcm::GCMClient::Result result);
54 void GetInstanceIDDataCompleted(const std::string& instance_id, 55 void GetInstanceIDDataCompleted(const std::string& instance_id,
55 const std::string& extra_data); 56 const std::string& extra_data);
56 57
57 void DoGetID(const GetIDCallback& callback); 58 void DoGetID(const GetIDCallback& callback);
58 void DoGetCreationTime(const GetCreationTimeCallback& callback); 59 void DoGetCreationTime(const GetCreationTimeCallback& callback);
59 void DoGetToken( 60 void DoGetToken(
60 const std::string& authorized_entity, 61 const std::string& authorized_entity,
61 const std::string& scope, 62 const std::string& scope,
62 const std::map<std::string, std::string>& options, 63 const std::map<std::string, std::string>& options,
63 const GetTokenCallback& callback); 64 const GetTokenCallback& callback);
64 void DoDeleteToken(const std::string& authorized_entity, 65 void DoDeleteToken(const std::string& authorized_entity,
65 const std::string& scope, 66 const std::string& scope,
66 const DeleteTokenCallback& callback); 67 const DeleteTokenCallback& callback);
67 void DoDeleteID(const DeleteIDCallback& callback); 68 void DoDeleteID(const DeleteIDCallback& callback);
68 69
69 // Owned by GCMProfileServiceFactory, which is a dependency of 70 gcm::InstanceIDHandler* Handler();
70 // InstanceIDProfileServiceFactory, which owns this.
71 gcm::InstanceIDHandler* handler_;
72 71
73 gcm::GCMDelayedTaskController delayed_task_controller_; 72 gcm::GCMDelayedTaskController delayed_task_controller_;
74 73
75 // The generated Instance ID. 74 // The generated Instance ID.
76 std::string id_; 75 std::string id_;
77 76
78 // The time when the Instance ID has been generated. 77 // The time when the Instance ID has been generated.
79 base::Time creation_time_; 78 base::Time creation_time_;
80 79
81 base::WeakPtrFactory<InstanceIDImpl> weak_ptr_factory_; 80 base::WeakPtrFactory<InstanceIDImpl> weak_ptr_factory_;
82 81
83 DISALLOW_COPY_AND_ASSIGN(InstanceIDImpl); 82 DISALLOW_COPY_AND_ASSIGN(InstanceIDImpl);
84 }; 83 };
85 84
86 } // namespace instance_id 85 } // namespace instance_id
87 86
88 #endif // COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_IMPL_H_ 87 #endif // COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698