OLD | NEW |
---|---|
(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 // Details of the of the Registration Request. Only user's android ID 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 RequestInfo { | |
38 RequestInfo(uint64 android_id, | |
39 uint64 security_token, | |
40 uint64 user_android_id, | |
41 int64 user_serial_number, | |
42 const std::string& app_id, | |
43 const std::string& cert, | |
44 const std::vector<std::string>& sender_ids); | |
45 ~RequestInfo(); | |
46 | |
47 // Android ID of the device. | |
48 uint64 android_id; | |
49 // Security token of the device. | |
50 uint64 security_token; | |
51 // User's android ID. (Can be omitted in a single user scenario.) | |
52 uint64 user_android_id; | |
53 // User's serial number. (Can be omitted in a single user scenario.) | |
54 int64 user_serial_number; | |
55 // Application ID. | |
56 std::string app_id; | |
57 // Certificate of the application. | |
58 std::string cert; | |
59 // List of IDs of senders. Allowed up to 100. | |
60 std::vector<std::string> sender_ids; | |
61 }; | |
62 | |
63 RegistrationRequest( | |
64 const RegistrationCallback& callback, | |
jianli
2014/01/11 00:33:39
nit: it might be better to put RequestInfo as 1st
fgorski
2014/01/11 01:07:29
Done.
| |
65 const RequestInfo& parameters, | |
jianli
2014/01/11 00:33:39
nit: request_info
fgorski
2014/01/11 01:07:29
Done.
| |
66 scoped_refptr<net::URLRequestContextGetter> request_context_getter); | |
67 virtual ~RegistrationRequest(); | |
68 | |
69 void Start(); | |
70 | |
71 // URLFetcherDelegate implementation. | |
72 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | |
73 | |
74 private: | |
75 RegistrationCallback callback_; | |
76 RequestInfo parameters_; | |
jianli
2014/01/11 00:33:39
nit: request_info_
fgorski
2014/01/11 01:07:29
Done.
| |
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_ | |
OLD | NEW |