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

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

Issue 338363003: Push API: register PushMessagingServiceImpl as GCMAppHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add as AppHandler before calling Register. Other review issues. Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_GCM_DRIVER_H_ 5 #ifndef COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_
6 #define COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ 6 #define COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 // This method must be called before destroying the GCMDriver. Once it has 66 // This method must be called before destroying the GCMDriver. Once it has
67 // been called, no other GCMDriver methods may be used. 67 // been called, no other GCMDriver methods may be used.
68 virtual void Shutdown(); 68 virtual void Shutdown();
69 69
70 // Adds a handler for a given app. 70 // Adds a handler for a given app.
71 virtual void AddAppHandler(const std::string& app_id, GCMAppHandler* handler); 71 virtual void AddAppHandler(const std::string& app_id, GCMAppHandler* handler);
72 72
73 // Remove the handler for a given app. 73 // Remove the handler for a given app.
74 virtual void RemoveAppHandler(const std::string& app_id); 74 virtual void RemoveAppHandler(const std::string& app_id);
75 75
76 // Returns the handler for the given app.
77 GCMAppHandler* GetAppHandler(const std::string& app_id);
78
76 // Enables/disables GCM service. 79 // Enables/disables GCM service.
77 virtual void Enable() = 0; 80 virtual void Enable() = 0;
78 virtual void Disable() = 0; 81 virtual void Disable() = 0;
79 82
80 // For testing purpose. Always NULL on Android. 83 // For testing purpose. Always NULL on Android.
81 virtual GCMClient* GetGCMClientForTesting() const = 0; 84 virtual GCMClient* GetGCMClientForTesting() const = 0;
82 85
83 // Returns true if the service was started. 86 // Returns true if the service was started.
84 virtual bool IsStarted() const = 0; 87 virtual bool IsStarted() const = 0;
85 88
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 132
130 // Runs the Send callback. 133 // Runs the Send callback.
131 void SendFinished(const std::string& app_id, 134 void SendFinished(const std::string& app_id,
132 const std::string& message_id, 135 const std::string& message_id,
133 GCMClient::Result result); 136 GCMClient::Result result);
134 137
135 bool HasRegisterCallback(const std::string& app_id); 138 bool HasRegisterCallback(const std::string& app_id);
136 139
137 void ClearCallbacks(); 140 void ClearCallbacks();
138 141
139 // Returns the handler for the given app.
140 GCMAppHandler* GetAppHandler(const std::string& app_id);
141
142 private: 142 private:
143 // Should be called when an app with |app_id| is trying to un/register. 143 // Should be called when an app with |app_id| is trying to un/register.
144 // Checks whether another un/registration is in progress. 144 // Checks whether another un/registration is in progress.
145 bool IsAsyncOperationPending(const std::string& app_id) const; 145 bool IsAsyncOperationPending(const std::string& app_id) const;
146 146
147 // Callback map (from app_id to callback) for Register. 147 // Callback map (from app_id to callback) for Register.
148 std::map<std::string, RegisterCallback> register_callbacks_; 148 std::map<std::string, RegisterCallback> register_callbacks_;
149 149
150 // Callback map (from app_id to callback) for Unregister. 150 // Callback map (from app_id to callback) for Unregister.
151 std::map<std::string, UnregisterCallback> unregister_callbacks_; 151 std::map<std::string, UnregisterCallback> unregister_callbacks_;
152 152
153 // Callback map (from <app_id, message_id> to callback) for Send. 153 // Callback map (from <app_id, message_id> to callback) for Send.
154 std::map<std::pair<std::string, std::string>, SendCallback> send_callbacks_; 154 std::map<std::pair<std::string, std::string>, SendCallback> send_callbacks_;
155 155
156 // App handler map (from app_id to handler pointer). 156 // App handler map (from app_id to handler pointer).
157 // The handler is not owned. 157 // The handler is not owned.
158 GCMAppHandlerMap app_handlers_; 158 GCMAppHandlerMap app_handlers_;
159 159
160 // The default handler when no app handler can be found in the map. 160 // The default handler when no app handler can be found in the map.
161 DefaultGCMAppHandler default_app_handler_; 161 DefaultGCMAppHandler default_app_handler_;
162 162
163 DISALLOW_COPY_AND_ASSIGN(GCMDriver); 163 DISALLOW_COPY_AND_ASSIGN(GCMDriver);
164 }; 164 };
165 165
166 } // namespace gcm 166 } // namespace gcm
167 167
168 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ 168 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698