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

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

Issue 1785613006: Make GCMDriver::GetInstanceIDHandler protected, to avoid misuse (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address peter's review comments Created 4 years, 9 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 <string> 9 #include <string>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.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 {
21 class GCMDriver;
22 class InstanceIDHandler;
Peter Beverloo 2016/03/11 16:10:19 We should continue forward-declaring InstanceIDHan
johnme 2016/03/11 17:53:23 Done.
23 } // namespace gcm
24
25 namespace instance_id { 20 namespace instance_id {
26 21
27 // InstanceID implementation for desktop and iOS. 22 // InstanceID implementation for desktop and iOS.
28 class InstanceIDImpl : public InstanceID { 23 class InstanceIDImpl : public InstanceID {
29 public: 24 public:
30 InstanceIDImpl(const std::string& app_id, gcm::GCMDriver* gcm_driver); 25 InstanceIDImpl(const std::string& app_id, gcm::InstanceIDHandler* handler);
31 ~InstanceIDImpl() override; 26 ~InstanceIDImpl() override;
32 27
33 // InstanceID: 28 // InstanceID:
34 void GetID(const GetIDCallback& callback) override; 29 void GetID(const GetIDCallback& callback) override;
35 void GetCreationTime(const GetCreationTimeCallback& callback) override; 30 void GetCreationTime(const GetCreationTimeCallback& callback) override;
36 void GetToken(const std::string& authorized_entity, 31 void GetToken(const std::string& authorized_entity,
37 const std::string& scope, 32 const std::string& scope,
38 const std::map<std::string, std::string>& options, 33 const std::map<std::string, std::string>& options,
39 const GetTokenCallback& callback) override; 34 const GetTokenCallback& callback) override;
40 void DeleteToken(const std::string& authorized_entity, 35 void DeleteToken(const std::string& authorized_entity,
41 const std::string& scope, 36 const std::string& scope,
42 const DeleteTokenCallback& callback) override; 37 const DeleteTokenCallback& callback) override;
43 void DeleteID(const DeleteIDCallback& callback) override; 38 void DeleteID(const DeleteIDCallback& callback) override;
44 39
45 private: 40 private:
46 gcm::InstanceIDHandler* GetInstanceIDHandler() const;
47
48 void EnsureIDGenerated(); 41 void EnsureIDGenerated();
49 42
50 void OnGetTokenCompleted(const GetTokenCallback& callback, 43 void OnGetTokenCompleted(const GetTokenCallback& callback,
51 const std::string& token, 44 const std::string& token,
52 gcm::GCMClient::Result result); 45 gcm::GCMClient::Result result);
53 void OnDeleteTokenCompleted(const DeleteTokenCallback& callback, 46 void OnDeleteTokenCompleted(const DeleteTokenCallback& callback,
54 gcm::GCMClient::Result result); 47 gcm::GCMClient::Result result);
55 void OnDeleteIDCompleted(const DeleteIDCallback& callback, 48 void OnDeleteIDCompleted(const DeleteIDCallback& callback,
56 gcm::GCMClient::Result result); 49 gcm::GCMClient::Result result);
57 void GetInstanceIDDataCompleted(const std::string& instance_id, 50 void GetInstanceIDDataCompleted(const std::string& instance_id,
58 const std::string& extra_data); 51 const std::string& extra_data);
59 52
60 void DoGetID(const GetIDCallback& callback); 53 void DoGetID(const GetIDCallback& callback);
61 void DoGetCreationTime(const GetCreationTimeCallback& callback); 54 void DoGetCreationTime(const GetCreationTimeCallback& callback);
62 void DoGetToken( 55 void DoGetToken(
63 const std::string& authorized_entity, 56 const std::string& authorized_entity,
64 const std::string& scope, 57 const std::string& scope,
65 const std::map<std::string, std::string>& options, 58 const std::map<std::string, std::string>& options,
66 const GetTokenCallback& callback); 59 const GetTokenCallback& callback);
67 void DoDeleteToken(const std::string& authorized_entity, 60 void DoDeleteToken(const std::string& authorized_entity,
68 const std::string& scope, 61 const std::string& scope,
69 const DeleteTokenCallback& callback); 62 const DeleteTokenCallback& callback);
70 void DoDeleteID(const DeleteIDCallback& callback); 63 void DoDeleteID(const DeleteIDCallback& callback);
71 64
72 gcm::GCMDriver* gcm_driver_; // Not owned.
73
74 gcm::GCMDelayedTaskController delayed_task_controller_; 65 gcm::GCMDelayedTaskController delayed_task_controller_;
75 66
76 // The generated Instance ID. 67 // The generated Instance ID.
77 std::string id_; 68 std::string id_;
78 69
79 // The time when the Instance ID has been generated. 70 // The time when the Instance ID has been generated.
80 base::Time creation_time_; 71 base::Time creation_time_;
81 72
82 base::WeakPtrFactory<InstanceIDImpl> weak_ptr_factory_; 73 base::WeakPtrFactory<InstanceIDImpl> weak_ptr_factory_;
83 74
84 DISALLOW_COPY_AND_ASSIGN(InstanceIDImpl); 75 DISALLOW_COPY_AND_ASSIGN(InstanceIDImpl);
85 }; 76 };
86 77
87 } // namespace instance_id 78 } // namespace instance_id
88 79
89 #endif // COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_IMPL_H_ 80 #endif // COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698