Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_GCM_DRIVER_CRYPTO_GCM_ENCRYPTION_HANDLER_H_ | |
| 6 #define COMPONENTS_GCM_DRIVER_CRYPTO_GCM_ENCRYPTION_HANDLER_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/callback_forward.h" | |
| 13 #include "base/macros.h" | |
| 14 #include "base/memory/ref_counted.h" | |
| 15 #include "base/memory/weak_ptr.h" | |
| 16 | |
| 17 namespace base { | |
| 18 class FilePath; | |
| 19 class SequencedTaskRunner; | |
| 20 } | |
| 21 | |
| 22 namespace gcm { | |
| 23 | |
| 24 class GCMKeyStore; | |
| 25 class KeyPair; | |
| 26 | |
| 27 // Interface through which the GCM Driver deals with encryption. Responsible for | |
|
jianli
2015/07/17 20:55:21
"Interface" sounds a bit misleading. How about "br
Peter Beverloo
2015/07/20 17:55:53
I called it a provider per your next comment.
| |
| 28 // both key management and decryption of incoming messages. | |
| 29 class GCMEncryptionHandler { | |
|
jianli
2015/07/17 20:55:21
Handler suffix sounds not good enough to indicate
Peter Beverloo
2015/07/20 17:55:53
Done. (GCMEncryptionProvider)
| |
| 30 public: | |
| 31 // Callback to be invoked when the public encryption key is available. | |
| 32 using KeyCallback = base::Callback<void(const std::vector<uint8_t>&)>; | |
| 33 | |
| 34 GCMEncryptionHandler( | |
| 35 const base::FilePath& store_path, | |
| 36 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner); | |
|
jianli
2015/07/17 20:55:21
const scoped_refptr<>&
Peter Beverloo
2015/07/20 17:55:53
Done.
| |
| 37 ~GCMEncryptionHandler(); | |
| 38 | |
| 39 // Retrieves the public encryption key belonging to |app_id|. If no keys have | |
| 40 // been associated with |app_id| yet, they will be created. | |
| 41 void GetPublicEncryptionKey(const std::string& app_id, | |
|
jianli
2015/07/17 20:55:21
I think the shorter name GetPublicKey is simpler a
Peter Beverloo
2015/07/20 17:55:53
Done.
| |
| 42 const KeyCallback& callback); | |
| 43 | |
| 44 private: | |
| 45 void DidGetPublicEncryptionKey(const std::string& app_id, | |
| 46 const KeyCallback& callback, | |
| 47 const KeyPair& pair); | |
| 48 | |
| 49 void DidCreatePublicEncryptionKey(const KeyCallback& callback, | |
| 50 const KeyPair& pair); | |
| 51 | |
| 52 scoped_refptr<GCMKeyStore> key_store_; | |
| 53 | |
| 54 base::WeakPtrFactory<GCMEncryptionHandler> weak_ptr_factory_; | |
| 55 | |
| 56 DISALLOW_COPY_AND_ASSIGN(GCMEncryptionHandler); | |
| 57 }; | |
| 58 | |
| 59 } // namespace gcm | |
| 60 | |
| 61 #endif // COMPONENTS_GCM_DRIVER_CRYPTO_GCM_ENCRYPTION_HANDLER_H_ | |
| OLD | NEW |