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

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

Issue 1243563002: Teach the GCM Driver how to decrypt incoming messages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gcm-push-keys
Patch Set: Created 5 years, 4 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 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 void UnregisterFinished(const std::string& app_id, 258 void UnregisterFinished(const std::string& app_id,
259 GCMClient::Result result); 259 GCMClient::Result result);
260 260
261 // Runs the Send callback. 261 // Runs the Send callback.
262 void SendFinished(const std::string& app_id, 262 void SendFinished(const std::string& app_id,
263 const std::string& message_id, 263 const std::string& message_id,
264 GCMClient::Result result); 264 GCMClient::Result result);
265 265
266 bool HasRegisterCallback(const std::string& app_id); 266 bool HasRegisterCallback(const std::string& app_id);
267 267
268 // Dispatches the OnMessage event to the app handler associated with |app_id|.
269 // If the |message| has been encrypted, it will be asynchronously decrypted
270 // before being dispatched to the handler associated with |app_id|.
271 void DispatchMessage(const std::string& app_id,
272 const IncomingMessage& message);
273
268 void ClearCallbacks(); 274 void ClearCallbacks();
269 275
270 private: 276 private:
271 // Common code shared by Unregister and UnregisterWithSenderId. 277 // Common code shared by Unregister and UnregisterWithSenderId.
272 void UnregisterInternal(const std::string& app_id, 278 void UnregisterInternal(const std::string& app_id,
273 const std::string* sender_id, 279 const std::string* sender_id,
274 const UnregisterCallback& callback); 280 const UnregisterCallback& callback);
275 281
276 // Called after unregistration completes in order to trigger the pending 282 // Called after unregistration completes in order to trigger the pending
277 // registration. 283 // registration.
278 void RegisterAfterUnregister( 284 void RegisterAfterUnregister(
279 const std::string& app_id, 285 const std::string& app_id,
280 const std::vector<std::string>& normalized_sender_ids, 286 const std::vector<std::string>& normalized_sender_ids,
281 const UnregisterCallback& unregister_callback, 287 const UnregisterCallback& unregister_callback,
282 GCMClient::Result result); 288 GCMClient::Result result);
283 289
290 // Dispatches |message| to |app_id| if the decryption was successful.
291 void DispatchDecryptedMessage(const std::string& app_id,
jianli 2015/08/04 00:49:30 This method might also dispatch an error event in
Peter Beverloo 2015/09/25 16:37:35 This doesn't apply anymore due to re-using Dispatc
292 const IncomingMessage& message,
293 bool decryption_successful);
294
284 // Callback map (from app_id to callback) for Register. 295 // Callback map (from app_id to callback) for Register.
285 std::map<std::string, RegisterCallback> register_callbacks_; 296 std::map<std::string, RegisterCallback> register_callbacks_;
286 297
287 // Callback map (from app_id to callback) for Unregister. 298 // Callback map (from app_id to callback) for Unregister.
288 std::map<std::string, UnregisterCallback> unregister_callbacks_; 299 std::map<std::string, UnregisterCallback> unregister_callbacks_;
289 300
290 // Callback map (from <app_id, message_id> to callback) for Send. 301 // Callback map (from <app_id, message_id> to callback) for Send.
291 std::map<std::pair<std::string, std::string>, SendCallback> send_callbacks_; 302 std::map<std::pair<std::string, std::string>, SendCallback> send_callbacks_;
292 303
293 // The encryption provider, used for key management and decryption of 304 // The encryption provider, used for key management and decryption of
294 // encrypted, incoming messages. 305 // encrypted, incoming messages.
295 GCMEncryptionProvider encryption_provider_; 306 GCMEncryptionProvider encryption_provider_;
296 307
297 // App handler map (from app_id to handler pointer). 308 // App handler map (from app_id to handler pointer).
298 // The handler is not owned. 309 // The handler is not owned.
299 GCMAppHandlerMap app_handlers_; 310 GCMAppHandlerMap app_handlers_;
300 311
301 // The default handler when no app handler can be found in the map. 312 // The default handler when no app handler can be found in the map.
302 DefaultGCMAppHandler default_app_handler_; 313 DefaultGCMAppHandler default_app_handler_;
303 314
304 base::WeakPtrFactory<GCMDriver> weak_ptr_factory_; 315 base::WeakPtrFactory<GCMDriver> weak_ptr_factory_;
305 316
306 DISALLOW_COPY_AND_ASSIGN(GCMDriver); 317 DISALLOW_COPY_AND_ASSIGN(GCMDriver);
307 }; 318 };
308 319
309 } // namespace gcm 320 } // namespace gcm
310 321
311 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ 322 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698