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

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

Issue 126513007: GCM Registration Request implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updates based on code reviews and adding documentation Created 6 years, 11 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 (c) 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 #ifndef GOOGLE_APIS_GCM_ENGINE_REGISTRATION_REQUEST_H_
6 #define GOOGLE_APIS_GCM_ENGINE_REGISTRATION_REQUEST_H_
7
8 #include <map>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "google_apis/gcm/base/gcm_export.h"
16 #include "net/url_request/url_fetcher_delegate.h"
17
18 namespace net {
19 class URLRequestContextGetter;
20 }
21
22 namespace gcm {
23
24 // Registration request is used to obtain registration IDs for applications that
25 // want to use GCM. It requires a set of parameters to be specified to identify
26 // the Chrome instance, the user, the application and a set of senders that will
27 // be authorized to address the application using it's assigned registration ID.
28 class GCM_EXPORT RegistrationRequest : public net::URLFetcherDelegate {
29 public:
30 // Callback completing the registration request.
31 typedef base::Callback<void(const std::string& registration_id)>
32 RegistrationCallback;
33
34 // Parameters of the Registration Request. Only Android ID of the user and
35 // its serial number are optional and can be set to 0. All other parameters
36 // have to be specified to successfully complete the call.
37 struct Parameters {
jianli 2014/01/10 23:23:47 RequestInfo?
fgorski 2014/01/11 00:10:36 Done.
38 Parameters(const RegistrationCallback& callback,
39 uint64 android_id,
40 uint64 security_token,
41 uint64 user_android_id,
42 int64 user_serial_number,
43 const std::string& app_id,
44 const std::string& cert,
45 const std::vector<std::string>& sender_ids);
46 ~Parameters();
47
48 RegistrationCallback callback;
jianli 2014/01/10 23:23:47 I think RegistrationCallback might be better to pa
fgorski 2014/01/11 00:10:36 Done.
49 // Android ID of the device.
50 uint64 android_id;
51 // Security token of the device.
52 uint64 security_token;
53 // Android ID the user. (Can be omitted in a single user scenario.)
54 uint64 user_android_id;
55 // Serial number of the user. (Can be omitted in a single user scenario.)
56 int64 user_serial_number;
57 // Application ID.
58 std::string app_id;
59 // Certificate of the application.
60 std::string cert;
61 // List of IDs of senders. Allowed up to 100.
62 std::vector<std::string> sender_ids;
63 };
64
65 RegistrationRequest(
66 const Parameters& parameters,
67 scoped_refptr<net::URLRequestContextGetter> request_context_getter);
68 virtual ~RegistrationRequest();
69
70 void Start();
71
72 // URLFetcherDelegate implementation.
73 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
74
75 private:
76 Parameters parameters_;
77
78 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
79 scoped_ptr<net::URLFetcher> url_fetcher_;
80
81 DISALLOW_COPY_AND_ASSIGN(RegistrationRequest);
82 };
83
84 } // namespace gcm
85
86 #endif // GOOGLE_APIS_GCM_ENGINE_REGISTRATION_REQUEST_H_
OLDNEW
« no previous file with comments | « no previous file | google_apis/gcm/engine/registration_request.cc » ('j') | google_apis/gcm/engine/registration_request.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698