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

Side by Side Diff: google_apis/gcm/engine/instance_id_delete_token_request_handler.cc

Issue 2111973002: Add support for GCM subtypes to desktop Instance ID implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@iid9push
Patch Set: Remove channel from product_category_for_subtypes, and address nits Created 4 years, 4 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "google_apis/gcm/engine/instance_id_delete_token_request_handler.h" 5 #include "google_apis/gcm/engine/instance_id_delete_token_request_handler.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "google_apis/gcm/base/gcm_util.h" 10 #include "google_apis/gcm/base/gcm_util.h"
11 #include "net/url_request/url_fetcher.h" 11 #include "net/url_request/url_fetcher.h"
12 #include "net/url_request/url_request_context_getter.h" 12 #include "net/url_request/url_request_context_getter.h"
13 13
14 namespace gcm { 14 namespace gcm {
15 15
16 namespace { 16 namespace {
17 17
18 // Request constants. 18 // Request constants.
19 const char kGMSVersionKey[] = "gmsv"; 19 const char kGMSVersionKey[] = "gmsv";
20 const char kInstanceIDKey[] = "appid"; 20 const char kInstanceIDKey[] = "appid";
21 const char kSenderKey[] = "sender"; 21 const char kSenderKey[] = "sender";
22 const char kSubtypeKey[] = "X-subtype";
23 const char kScopeKey[] = "scope"; 22 const char kScopeKey[] = "scope";
24 const char kExtraScopeKey[] = "X-scope"; 23 const char kExtraScopeKey[] = "X-scope";
25 24
26 // Response constants. 25 // Response constants.
27 const char kTokenPrefix[] = "token="; 26 const char kTokenPrefix[] = "token=";
28 const char kErrorPrefix[] = "Error="; 27 const char kErrorPrefix[] = "Error=";
29 const char kInvalidParameters[] = "INVALID_PARAMETERS"; 28 const char kInvalidParameters[] = "INVALID_PARAMETERS";
30 29
31 } // namespace 30 } // namespace
32 31
(...skipping 12 matching lines...) Expand all
45 } 44 }
46 45
47 InstanceIDDeleteTokenRequestHandler::~InstanceIDDeleteTokenRequestHandler() {} 46 InstanceIDDeleteTokenRequestHandler::~InstanceIDDeleteTokenRequestHandler() {}
48 47
49 void InstanceIDDeleteTokenRequestHandler::BuildRequestBody(std::string* body){ 48 void InstanceIDDeleteTokenRequestHandler::BuildRequestBody(std::string* body){
50 BuildFormEncoding(kInstanceIDKey, instance_id_, body); 49 BuildFormEncoding(kInstanceIDKey, instance_id_, body);
51 BuildFormEncoding(kSenderKey, authorized_entity_, body); 50 BuildFormEncoding(kSenderKey, authorized_entity_, body);
52 BuildFormEncoding(kScopeKey, scope_, body); 51 BuildFormEncoding(kScopeKey, scope_, body);
53 BuildFormEncoding(kExtraScopeKey, scope_, body); 52 BuildFormEncoding(kExtraScopeKey, scope_, body);
54 BuildFormEncoding(kGMSVersionKey, base::IntToString(gcm_version_), body); 53 BuildFormEncoding(kGMSVersionKey, base::IntToString(gcm_version_), body);
55 // TODO(jianli): To work around server bug. To be removed when the server fix
56 // is deployed.
57 BuildFormEncoding(kSubtypeKey, authorized_entity_, body);
58 } 54 }
59 55
60 UnregistrationRequest::Status 56 UnregistrationRequest::Status
61 InstanceIDDeleteTokenRequestHandler::ParseResponse( 57 InstanceIDDeleteTokenRequestHandler::ParseResponse(
62 const net::URLFetcher* source) { 58 const net::URLFetcher* source) {
63 std::string response; 59 std::string response;
64 if (!source->GetResponseAsString(&response)) { 60 if (!source->GetResponseAsString(&response)) {
65 DVLOG(1) << "Failed to get response body."; 61 DVLOG(1) << "Failed to get response body.";
66 return UnregistrationRequest::NO_RESPONSE_BODY; 62 return UnregistrationRequest::NO_RESPONSE_BODY;
67 } 63 }
(...skipping 22 matching lines...) Expand all
90 86
91 // Other UMAs are only reported when the request succeeds. 87 // Other UMAs are only reported when the request succeeds.
92 if (status != UnregistrationRequest::SUCCESS) 88 if (status != UnregistrationRequest::SUCCESS)
93 return; 89 return;
94 90
95 UMA_HISTOGRAM_COUNTS("InstanceID.DeleteToken.RetryCount", retry_count); 91 UMA_HISTOGRAM_COUNTS("InstanceID.DeleteToken.RetryCount", retry_count);
96 UMA_HISTOGRAM_TIMES("InstanceID.DeleteToken.CompleteTime", complete_time); 92 UMA_HISTOGRAM_TIMES("InstanceID.DeleteToken.CompleteTime", complete_time);
97 } 93 }
98 94
99 } // namespace gcm 95 } // namespace gcm
OLDNEW
« no previous file with comments | « google_apis/gcm/engine/gcm_request_test_base.cc ('k') | google_apis/gcm/engine/instance_id_get_token_request_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698