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.
5 #ifndef COMPONENTS_GCM_DRIVER_CRYPTO_GCM_ENCRYPTION_PROVIDER_H_
6 #define COMPONENTS_GCM_DRIVER_CRYPTO_GCM_ENCRYPTION_PROVIDER_H_
11 #include "base/callback_forward.h"
12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h"
17 class SequencedTaskRunner
;
25 // Provider that enables the GCM Driver to deal with encryption key management
26 // and decryption of incoming messages.
27 class GCMEncryptionProvider
{
29 // Callback to be invoked when the public encryption key is available.
30 using PublicKeyCallback
= base::Callback
<void(const std::string
&)>;
32 GCMEncryptionProvider();
33 ~GCMEncryptionProvider();
35 // Initializes the encryption provider with the |store_path| and the
36 // |blocking_task_runner|. Done separately from the constructor in order to
37 // avoid needing a blocking task runner for anything using GCMDriver.
39 const base::FilePath
& store_path
,
40 const scoped_refptr
<base::SequencedTaskRunner
>& blocking_task_runner
);
42 // Retrieves the public encryption key belonging to |app_id|. If no keys have
43 // been associated with |app_id| yet, they will be created.
44 void GetPublicKey(const std::string
& app_id
,
45 const PublicKeyCallback
& callback
);
48 void DidGetPublicKey(const std::string
& app_id
,
49 const PublicKeyCallback
& callback
,
52 void DidCreatePublicKey(const PublicKeyCallback
& callback
,
55 scoped_ptr
<GCMKeyStore
> key_store_
;
57 base::WeakPtrFactory
<GCMEncryptionProvider
> weak_ptr_factory_
;
59 DISALLOW_COPY_AND_ASSIGN(GCMEncryptionProvider
);
64 #endif // COMPONENTS_GCM_DRIVER_CRYPTO_GCM_ENCRYPTION_PROVIDER_H_