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

Unified Diff: components/gcm_driver/crypto/gcm_encryption_provider.h

Issue 1231613005: Hook up the Push API with GCM's new ability to own encryption keys. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gcm-encryption
Patch Set: Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/gcm_driver/crypto/BUILD.gn ('k') | components/gcm_driver/crypto/gcm_encryption_provider.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/gcm_driver/crypto/gcm_encryption_provider.h
diff --git a/components/gcm_driver/crypto/gcm_encryption_provider.h b/components/gcm_driver/crypto/gcm_encryption_provider.h
new file mode 100644
index 0000000000000000000000000000000000000000..fce5732b0c64bd9c5f57c6fa5587b546a9d9b212
--- /dev/null
+++ b/components/gcm_driver/crypto/gcm_encryption_provider.h
@@ -0,0 +1,65 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_GCM_DRIVER_CRYPTO_GCM_ENCRYPTION_PROVIDER_H_
+#define COMPONENTS_GCM_DRIVER_CRYPTO_GCM_ENCRYPTION_PROVIDER_H_
+
+#include <stdint.h>
+#include <string>
+
+#include "base/callback_forward.h"
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+
+namespace base {
+class FilePath;
+class SequencedTaskRunner;
+}
+
+namespace gcm {
+
+class GCMKeyStore;
+class KeyPair;
+
+// Provider that enables the GCM Driver to deal with encryption key management
+// and decryption of incoming messages.
+class GCMEncryptionProvider {
+ public:
+ // Callback to be invoked when the public encryption key is available.
+ using PublicKeyCallback = base::Callback<void(const std::string&)>;
+
+ GCMEncryptionProvider();
+ ~GCMEncryptionProvider();
+
+ // Initializes the encryption provider with the |store_path| and the
+ // |blocking_task_runner|. Done separately from the constructor in order to
+ // avoid needing a blocking task runner for anything using GCMDriver.
+ void Init(
+ const base::FilePath& store_path,
+ const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner);
+
+ // Retrieves the public encryption key belonging to |app_id|. If no keys have
+ // been associated with |app_id| yet, they will be created.
+ void GetPublicKey(const std::string& app_id,
+ const PublicKeyCallback& callback);
+
+ private:
+ void DidGetPublicKey(const std::string& app_id,
+ const PublicKeyCallback& callback,
+ const KeyPair& pair);
+
+ void DidCreatePublicKey(const PublicKeyCallback& callback,
+ const KeyPair& pair);
+
+ scoped_refptr<GCMKeyStore> key_store_;
+
+ base::WeakPtrFactory<GCMEncryptionProvider> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(GCMEncryptionProvider);
+};
+
+} // namespace gcm
+
+#endif // COMPONENTS_GCM_DRIVER_CRYPTO_GCM_ENCRYPTION_PROVIDER_H_
« no previous file with comments | « components/gcm_driver/crypto/BUILD.gn ('k') | components/gcm_driver/crypto/gcm_encryption_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698