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

Side by Side Diff: components/gcm_driver/instance_id/instance_id.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 nits 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_H_ 5 #ifndef COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_H_
6 #define COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_H_ 6 #define COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_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/time/time.h" 14 #include "base/time/time.h"
15 15
16 namespace gcm { 16 namespace gcm {
17 class GCMDriver; 17 class InstanceIDHandler;
18 } // namespace gcm 18 } // namespace gcm
19 19
20 namespace instance_id { 20 namespace instance_id {
21 21
22 // Encapsulates Instance ID functionalities that need to be implemented for 22 // Encapsulates Instance ID functionalities that need to be implemented for
23 // different platform. One instance is created per application. Life of 23 // different platform. One instance is created per application. Life of
24 // Instance ID is managed by the InstanceIdDriver. 24 // Instance ID is managed by the InstanceIdDriver.
25 class InstanceID { 25 class InstanceID {
26 public: 26 public:
27 enum Result { 27 enum Result {
(...skipping 21 matching lines...) Expand all
49 GetCreationTimeCallback; 49 GetCreationTimeCallback;
50 typedef base::Callback<void(const std::string& token, 50 typedef base::Callback<void(const std::string& token,
51 Result result)> GetTokenCallback; 51 Result result)> GetTokenCallback;
52 typedef base::Callback<void(Result result)> DeleteTokenCallback; 52 typedef base::Callback<void(Result result)> DeleteTokenCallback;
53 typedef base::Callback<void(Result result)> DeleteIDCallback; 53 typedef base::Callback<void(Result result)> DeleteIDCallback;
54 54
55 static const int kInstanceIDByteLength = 8; 55 static const int kInstanceIDByteLength = 8;
56 56
57 // Creator. 57 // Creator.
58 // |app_id|: identifies the application that uses the Instance ID. 58 // |app_id|: identifies the application that uses the Instance ID.
59 // |gcm_driver|: driver to access the GCM functionalities needed to support 59 // |handler|: provides the GCM functionality needed to support Instance ID.
60 // Instance ID. 60 // Must outlive this class.
61 static scoped_ptr<InstanceID> Create(const std::string& app_id, 61 static scoped_ptr<InstanceID> Create(const std::string& app_id,
62 gcm::GCMDriver* gcm_driver); 62 gcm::InstanceIDHandler* handler);
63 63
64 virtual ~InstanceID(); 64 virtual ~InstanceID();
65 65
66 // Sets the callback that will be invoked when the token refresh event needs 66 // Sets the callback that will be invoked when the token refresh event needs
67 // to be triggered. 67 // to be triggered.
68 void SetTokenRefreshCallback(const TokenRefreshCallback& callback); 68 void SetTokenRefreshCallback(const TokenRefreshCallback& callback);
69 69
70 // Returns the Instance ID. 70 // Returns the Instance ID.
71 virtual void GetID(const GetIDCallback& callback) = 0; 71 virtual void GetID(const GetIDCallback& callback) = 0;
72 72
(...skipping 26 matching lines...) Expand all
99 const DeleteTokenCallback& callback) = 0; 99 const DeleteTokenCallback& callback) = 0;
100 100
101 // Resets the app instance identifier and revokes all tokens associated with 101 // Resets the app instance identifier and revokes all tokens associated with
102 // it. 102 // it.
103 // |callback|: to be called once the asynchronous operation is done. 103 // |callback|: to be called once the asynchronous operation is done.
104 virtual void DeleteID(const DeleteIDCallback& callback) = 0; 104 virtual void DeleteID(const DeleteIDCallback& callback) = 0;
105 105
106 std::string app_id() const { return app_id_; } 106 std::string app_id() const { return app_id_; }
107 107
108 protected: 108 protected:
109 explicit InstanceID(const std::string& app_id); 109 InstanceID(const std::string& app_id, gcm::InstanceIDHandler* handler);
110 110
111 void NotifyTokenRefresh(bool update_id); 111 void NotifyTokenRefresh(bool update_id);
112 112
113 gcm::InstanceIDHandler* handler() const { return handler_; }
114
113 private: 115 private:
116 // Owned by GCMProfileServiceFactory, which is a dependency of
117 // InstanceIDProfileServiceFactory, which owns this.
118 gcm::InstanceIDHandler* handler_;
119
114 std::string app_id_; 120 std::string app_id_;
115 TokenRefreshCallback token_refresh_callback_; 121 TokenRefreshCallback token_refresh_callback_;
116 122
117 DISALLOW_COPY_AND_ASSIGN(InstanceID); 123 DISALLOW_COPY_AND_ASSIGN(InstanceID);
118 }; 124 };
119 125
120 } // namespace instance_id 126 } // namespace instance_id
121 127
122 #endif // COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_H_ 128 #endif // COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_H_
OLDNEW
« no previous file with comments | « components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.cc ('k') | components/gcm_driver/instance_id/instance_id.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698