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

Unified Diff: google_apis/gcm/engine/instance_id_get_token_request_handler.cc

Issue 1137463003: Support getting and deleting token for Instance ID. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Patch to land Created 5 years, 7 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: google_apis/gcm/engine/instance_id_get_token_request_handler.cc
diff --git a/google_apis/gcm/engine/instance_id_get_token_request_handler.cc b/google_apis/gcm/engine/instance_id_get_token_request_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2e1c170a14ea96fe7cc8cf8272591886658abf2d
--- /dev/null
+++ b/google_apis/gcm/engine/instance_id_get_token_request_handler.cc
@@ -0,0 +1,52 @@
+// Copyright 2014 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.
+
+#include "google_apis/gcm/engine/instance_id_get_token_request_handler.h"
+
+#include "base/strings/string_number_conversions.h"
+#include "google_apis/gcm/base/gcm_util.h"
+#include "net/url_request/url_request_context_getter.h"
+
+namespace gcm {
+
+namespace {
+
+// Request constants.
+const char kAuthorizedEntityKey[] = "sender";
+const char kGMSVersionKey[] = "gmsv";
+const char kInstanceIDKey[] = "appid";
+const char kScopeKey[] = "scope";
+// Prefix that needs to be added for each option key.
+const char kOptionKeyPrefix[] = "X-";
+
+} // namespace
+
+InstanceIDGetTokenRequestHandler::InstanceIDGetTokenRequestHandler(
+ const std::string& instance_id,
+ const std::string& authorized_entity,
+ const std::string& scope,
+ int gcm_version,
+ const std::map<std::string, std::string>& options)
+ : instance_id_(instance_id),
+ authorized_entity_(authorized_entity),
+ scope_(scope),
+ gcm_version_(gcm_version),
+ options_(options) {
+ DCHECK(!instance_id.empty());
+ DCHECK(!authorized_entity.empty());
+ DCHECK(!scope.empty());
+}
+
+InstanceIDGetTokenRequestHandler::~InstanceIDGetTokenRequestHandler() {}
+
+void InstanceIDGetTokenRequestHandler::BuildRequestBody(std::string* body){
+ BuildFormEncoding(kScopeKey, scope_, body);
+ for (auto iter = options_.begin(); iter != options_.end(); ++iter)
+ BuildFormEncoding(kOptionKeyPrefix + iter->first, iter->second, body);
+ BuildFormEncoding(kGMSVersionKey, base::IntToString(gcm_version_), body);
+ BuildFormEncoding(kInstanceIDKey, instance_id_, body);
+ BuildFormEncoding(kAuthorizedEntityKey, authorized_entity_, body);
+}
+
+} // namespace gcm
« no previous file with comments | « google_apis/gcm/engine/instance_id_get_token_request_handler.h ('k') | google_apis/gcm/engine/registration_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698