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_PROVIDER_H_ |
| 6 #define COMPONENTS_GCM_DRIVER_CRYPTO_GCM_ENCRYPTION_PROVIDER_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 #include <string> |
| 10 |
| 11 #include "base/callback_forward.h" |
| 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/weak_ptr.h" |
| 15 |
| 16 namespace base { |
| 17 class FilePath; |
| 18 class SequencedTaskRunner; |
| 19 } |
| 20 |
| 21 namespace gcm { |
| 22 |
| 23 class GCMKeyStore; |
| 24 class KeyPair; |
| 25 |
| 26 // Provider that enables the GCM Driver to deal with encryption key management |
| 27 // and decryption of incoming messages. |
| 28 class GCMEncryptionProvider { |
| 29 public: |
| 30 // Callback to be invoked when the public encryption key is available. |
| 31 using PublicKeyCallback = base::Callback<void(const std::string&)>; |
| 32 |
| 33 GCMEncryptionProvider(); |
| 34 ~GCMEncryptionProvider(); |
| 35 |
| 36 // Initializes the encryption provider with the |store_path| and the |
| 37 // |blocking_task_runner|. Done separately from the constructor in order to |
| 38 // avoid needing a blocking task runner for anything using GCMDriver. |
| 39 void Init( |
| 40 const base::FilePath& store_path, |
| 41 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner); |
| 42 |
| 43 // Retrieves the public encryption key belonging to |app_id|. If no keys have |
| 44 // been associated with |app_id| yet, they will be created. |
| 45 void GetPublicKey(const std::string& app_id, |
| 46 const PublicKeyCallback& callback); |
| 47 |
| 48 private: |
| 49 void DidGetPublicKey(const std::string& app_id, |
| 50 const PublicKeyCallback& callback, |
| 51 const KeyPair& pair); |
| 52 |
| 53 void DidCreatePublicKey(const PublicKeyCallback& callback, |
| 54 const KeyPair& pair); |
| 55 |
| 56 scoped_refptr<GCMKeyStore> key_store_; |
| 57 |
| 58 base::WeakPtrFactory<GCMEncryptionProvider> weak_ptr_factory_; |
| 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(GCMEncryptionProvider); |
| 61 }; |
| 62 |
| 63 } // namespace gcm |
| 64 |
| 65 #endif // COMPONENTS_GCM_DRIVER_CRYPTO_GCM_ENCRYPTION_PROVIDER_H_ |
OLD | NEW |