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

Side by Side Diff: google_apis/gcm/engine/unregistration_request.h

Issue 1137463003: Support getting and deleting token for Instance ID. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add new files 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 #ifndef GOOGLE_APIS_GCM_ENGINE_UNREGISTRATION_REQUEST_H_ 5 #ifndef GOOGLE_APIS_GCM_ENGINE_UNREGISTRATION_REQUEST_H_
6 #define GOOGLE_APIS_GCM_ENGINE_UNREGISTRATION_REQUEST_H_ 6 #define GOOGLE_APIS_GCM_ENGINE_UNREGISTRATION_REQUEST_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 // immediately above this line. Make sure to update the corresponding 50 // immediately above this line. Make sure to update the corresponding
51 // histogram enum accordingly. 51 // histogram enum accordingly.
52 UNREGISTRATION_STATUS_COUNT, 52 UNREGISTRATION_STATUS_COUNT,
53 }; 53 };
54 54
55 // Callback completing the unregistration request. 55 // Callback completing the unregistration request.
56 typedef base::Callback<void(Status success)> UnregistrationCallback; 56 typedef base::Callback<void(Status success)> UnregistrationCallback;
57 57
58 // Details of the of the Unregistration Request. All parameters are mandatory. 58 // Details of the of the Unregistration Request. All parameters are mandatory.
59 struct GCM_EXPORT RequestInfo { 59 struct GCM_EXPORT RequestInfo {
60 RequestInfo(uint64 android_id, 60 RequestInfo();
61 uint64 security_token, 61 virtual ~RequestInfo();
62 const std::string& app_id);
63 ~RequestInfo();
64 62
63 virtual void BuildRequestHeaders(std::string* extra_headers);
64 virtual void BuildRequestBody(std::string* body);
65
66 // Version to pass.
67 std::string chrome_version;
65 // Android ID of the device. 68 // Android ID of the device.
66 uint64 android_id; 69 uint64 android_id;
67 // Security token of the device. 70 // Security token of the device.
68 uint64 security_token; 71 uint64 security_token;
69 // Application ID. 72 // Application ID.
70 std::string app_id; 73 std::string app_id;
71 }; 74 };
72 75
76 // GCM registration request.
77 struct GCM_EXPORT GCMRequestInfo : public RequestInfo {
78 GCMRequestInfo();
79 ~GCMRequestInfo() override;
80
81 // RequestInfo overrides:
82 void BuildRequestBody(std::string* body) override;
83 };
84
85 // GCM token request.
fgorski 2015/05/13 18:32:41 Instance ID token request
jianli 2015/05/13 22:42:57 Done.
86 struct GCM_EXPORT InstanceIDRequestInfo : public RequestInfo {
87 InstanceIDRequestInfo();
88 ~InstanceIDRequestInfo() override;
89
90 // RequestInfo overrides:
91 void BuildRequestBody(std::string* body) override;
92
93 std::string instance_id;
94 std::string authorized_entity;
95 std::string scope;
96 };
97
73 // Creates an instance of UnregistrationRequest. |callback| will be called 98 // Creates an instance of UnregistrationRequest. |callback| will be called
74 // once registration has been revoked or there has been an error that makes 99 // once registration has been revoked or there has been an error that makes
75 // further retries pointless. 100 // further retries pointless.
76 UnregistrationRequest( 101 UnregistrationRequest(
77 const GURL& registration_url, 102 const GURL& registration_url,
78 const RequestInfo& request_info, 103 scoped_ptr<RequestInfo> request_info,
79 const net::BackoffEntry::Policy& backoff_policy, 104 const net::BackoffEntry::Policy& backoff_policy,
80 const UnregistrationCallback& callback, 105 const UnregistrationCallback& callback,
81 scoped_refptr<net::URLRequestContextGetter> request_context_getter, 106 scoped_refptr<net::URLRequestContextGetter> request_context_getter,
82 GCMStatsRecorder* recorder); 107 GCMStatsRecorder* recorder);
83 ~UnregistrationRequest() override; 108 ~UnregistrationRequest() override;
84 109
85 // Starts an unregistration request. 110 // Starts an unregistration request.
86 void Start(); 111 void Start();
87 112
88 // URLFetcherDelegate implementation. 113 // URLFetcherDelegate implementation.
89 void OnURLFetchComplete(const net::URLFetcher* source) override; 114 void OnURLFetchComplete(const net::URLFetcher* source) override;
90 115
91 private: 116 private:
92 // Schedules a retry attempt and informs the backoff of previous request's 117 // Schedules a retry attempt and informs the backoff of previous request's
93 // failure, when |update_backoff| is true. 118 // failure, when |update_backoff| is true.
94 void RetryWithBackoff(bool update_backoff); 119 void RetryWithBackoff(bool update_backoff);
95 120
96 UnregistrationCallback callback_; 121 UnregistrationCallback callback_;
97 RequestInfo request_info_; 122 scoped_ptr<RequestInfo> request_info_;
98 GURL registration_url_; 123 GURL registration_url_;
99 124
100 net::BackoffEntry backoff_entry_; 125 net::BackoffEntry backoff_entry_;
101 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; 126 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
102 scoped_ptr<net::URLFetcher> url_fetcher_; 127 scoped_ptr<net::URLFetcher> url_fetcher_;
103 base::TimeTicks request_start_time_; 128 base::TimeTicks request_start_time_;
104 129
105 // Recorder that records GCM activities for debugging purpose. Not owned. 130 // Recorder that records GCM activities for debugging purpose. Not owned.
106 GCMStatsRecorder* recorder_; 131 GCMStatsRecorder* recorder_;
107 132
108 base::WeakPtrFactory<UnregistrationRequest> weak_ptr_factory_; 133 base::WeakPtrFactory<UnregistrationRequest> weak_ptr_factory_;
109 134
110 DISALLOW_COPY_AND_ASSIGN(UnregistrationRequest); 135 DISALLOW_COPY_AND_ASSIGN(UnregistrationRequest);
111 }; 136 };
112 137
113 } // namespace gcm 138 } // namespace gcm
114 139
115 #endif // GOOGLE_APIS_GCM_ENGINE_UNREGISTRATION_REQUEST_H_ 140 #endif // GOOGLE_APIS_GCM_ENGINE_UNREGISTRATION_REQUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698