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

Unified Diff: components/gcm_driver/crypto/gcm_encryption_handler.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
Index: components/gcm_driver/crypto/gcm_encryption_handler.h
diff --git a/components/gcm_driver/crypto/gcm_encryption_handler.h b/components/gcm_driver/crypto/gcm_encryption_handler.h
new file mode 100644
index 0000000000000000000000000000000000000000..a1a9dcb784c7d9ce2956d2bb95477435a36107c4
--- /dev/null
+++ b/components/gcm_driver/crypto/gcm_encryption_handler.h
@@ -0,0 +1,61 @@
+// 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_HANDLER_H_
+#define COMPONENTS_GCM_DRIVER_CRYPTO_GCM_ENCRYPTION_HANDLER_H_
+
+#include <stdint.h>
+#include <string>
+#include <vector>
+
+#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;
+
+// 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.
+// both key management and decryption of incoming messages.
+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)
+ public:
+ // Callback to be invoked when the public encryption key is available.
+ using KeyCallback = base::Callback<void(const std::vector<uint8_t>&)>;
+
+ GCMEncryptionHandler(
+ const base::FilePath& store_path,
+ 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.
+ ~GCMEncryptionHandler();
+
+ // Retrieves the public encryption key belonging to |app_id|. If no keys have
+ // been associated with |app_id| yet, they will be created.
+ 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.
+ const KeyCallback& callback);
+
+ private:
+ void DidGetPublicEncryptionKey(const std::string& app_id,
+ const KeyCallback& callback,
+ const KeyPair& pair);
+
+ void DidCreatePublicEncryptionKey(const KeyCallback& callback,
+ const KeyPair& pair);
+
+ scoped_refptr<GCMKeyStore> key_store_;
+
+ base::WeakPtrFactory<GCMEncryptionHandler> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(GCMEncryptionHandler);
+};
+
+} // namespace gcm
+
+#endif // COMPONENTS_GCM_DRIVER_CRYPTO_GCM_ENCRYPTION_HANDLER_H_

Powered by Google App Engine
This is Rietveld 408576698