cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / components / gcm_driver / crypto / gcm_encryption_provider.h
bloba395118a1293d9367a2f949af8eab7a5f0f922d5
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_
8 #include <stdint.h>
9 #include <string>
11 #include "base/callback_forward.h"
12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h"
15 namespace base {
16 class FilePath;
17 class SequencedTaskRunner;
20 namespace gcm {
22 class GCMKeyStore;
23 class KeyPair;
25 // Provider that enables the GCM Driver to deal with encryption key management
26 // and decryption of incoming messages.
27 class GCMEncryptionProvider {
28 public:
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.
38 void Init(
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);
47 private:
48 void DidGetPublicKey(const std::string& app_id,
49 const PublicKeyCallback& callback,
50 const KeyPair& pair);
52 void DidCreatePublicKey(const PublicKeyCallback& callback,
53 const KeyPair& pair);
55 scoped_ptr<GCMKeyStore> key_store_;
57 base::WeakPtrFactory<GCMEncryptionProvider> weak_ptr_factory_;
59 DISALLOW_COPY_AND_ASSIGN(GCMEncryptionProvider);
62 } // namespace gcm
64 #endif // COMPONENTS_GCM_DRIVER_CRYPTO_GCM_ENCRYPTION_PROVIDER_H_