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

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

Issue 683913005: [GCM] Support registration before unregistration finishes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add more comments Created 6 years, 1 month 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
« no previous file with comments | « no previous file | components/gcm_driver/gcm_driver.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
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/threading/thread_checker.h" 15 #include "base/threading/thread_checker.h"
15 #include "components/gcm_driver/default_gcm_app_handler.h" 16 #include "components/gcm_driver/default_gcm_app_handler.h"
16 #include "components/gcm_driver/gcm_client.h" 17 #include "components/gcm_driver/gcm_client.h"
17 18
18 namespace gcm { 19 namespace gcm {
19 20
20 class GCMAppHandler; 21 class GCMAppHandler;
21 class GCMConnectionObserver; 22 class GCMConnectionObserver;
22 struct AccountMapping; 23 struct AccountMapping;
23 24
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // Runs the Send callback. 166 // Runs the Send callback.
166 void SendFinished(const std::string& app_id, 167 void SendFinished(const std::string& app_id,
167 const std::string& message_id, 168 const std::string& message_id,
168 GCMClient::Result result); 169 GCMClient::Result result);
169 170
170 bool HasRegisterCallback(const std::string& app_id); 171 bool HasRegisterCallback(const std::string& app_id);
171 172
172 void ClearCallbacks(); 173 void ClearCallbacks();
173 174
174 private: 175 private:
175 // Should be called when an app with |app_id| is trying to un/register. 176 // Called after unregistration completes in order to trigger the pending
176 // Checks whether another un/registration is in progress. 177 // registration.
177 bool IsAsyncOperationPending(const std::string& app_id) const; 178 void RegisterAfterUnregister(
179 const std::string& app_id,
180 const std::vector<std::string>& normalized_sender_ids,
181 const UnregisterCallback& unregister_callback,
182 GCMClient::Result result);
178 183
179 // Callback map (from app_id to callback) for Register. 184 // Callback map (from app_id to callback) for Register.
180 std::map<std::string, RegisterCallback> register_callbacks_; 185 std::map<std::string, RegisterCallback> register_callbacks_;
181 186
182 // Callback map (from app_id to callback) for Unregister. 187 // Callback map (from app_id to callback) for Unregister.
183 std::map<std::string, UnregisterCallback> unregister_callbacks_; 188 std::map<std::string, UnregisterCallback> unregister_callbacks_;
184 189
185 // Callback map (from <app_id, message_id> to callback) for Send. 190 // Callback map (from <app_id, message_id> to callback) for Send.
186 std::map<std::pair<std::string, std::string>, SendCallback> send_callbacks_; 191 std::map<std::pair<std::string, std::string>, SendCallback> send_callbacks_;
187 192
188 // App handler map (from app_id to handler pointer). 193 // App handler map (from app_id to handler pointer).
189 // The handler is not owned. 194 // The handler is not owned.
190 GCMAppHandlerMap app_handlers_; 195 GCMAppHandlerMap app_handlers_;
191 196
192 // The default handler when no app handler can be found in the map. 197 // The default handler when no app handler can be found in the map.
193 DefaultGCMAppHandler default_app_handler_; 198 DefaultGCMAppHandler default_app_handler_;
194 199
200 base::WeakPtrFactory<GCMDriver> weak_ptr_factory_;
201
195 DISALLOW_COPY_AND_ASSIGN(GCMDriver); 202 DISALLOW_COPY_AND_ASSIGN(GCMDriver);
196 }; 203 };
197 204
198 } // namespace gcm 205 } // namespace gcm
199 206
200 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ 207 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_
OLDNEW
« no previous file with comments | « no previous file | components/gcm_driver/gcm_driver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698