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

Side by Side 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: More changes 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 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.
4
5 #include "google_apis/gcm/engine/instance_id_get_token_request_handler.h"
6
7 #include "base/strings/string_number_conversions.h"
8 #include "google_apis/gcm/base/gcm_util.h"
9 #include "net/url_request/url_request_context_getter.h"
10
11 namespace gcm {
12
13 namespace {
14
15 // Request constants.
16 const char kAuthorizedEntityKey[] = "sender";
17 const char kGMSVersionKey[] = "gmsv";
18 const char kInstanceIDKey[] = "appid";
19 const char kScopeKey[] = "scope";
20 // Prefix that needs to be added for each option key.
21 const char kOptionKeyPrefix[] = "X-";
22
23 } // namespace
24
25 InstanceIDGetTokenRequestHandler::InstanceIDGetTokenRequestHandler(
26 const std::string& instance_id,
27 const std::string& authorized_entity,
28 const std::string& scope,
29 int gcm_version,
30 const std::map<std::string, std::string>& options)
31 : instance_id_(instance_id),
32 authorized_entity_(authorized_entity),
33 scope_(scope),
34 gcm_version_(gcm_version),
35 options_(options) {
36 DCHECK(!instance_id.empty() && !authorized_entity.empty() && !scope.empty());
Nicolas Zea 2015/05/26 16:39:14 nit: I think it's cleaner to split this up into mu
jianli 2015/05/26 20:49:39 Done.
37 }
38
39 InstanceIDGetTokenRequestHandler::~InstanceIDGetTokenRequestHandler() {}
40
41 void InstanceIDGetTokenRequestHandler::BuildRequestBody(std::string* body){
42 BuildFormEncoding(kScopeKey, scope_, body);
43 for (auto iter = options_.begin(); iter != options_.end(); ++iter)
44 BuildFormEncoding(kOptionKeyPrefix + iter->first, iter->second, body);
45 BuildFormEncoding(kGMSVersionKey, base::IntToString(gcm_version_), body);
46 BuildFormEncoding(kInstanceIDKey, instance_id_, body);
47 BuildFormEncoding(kAuthorizedEntityKey, authorized_entity_, body);
48 }
49
50 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698