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.
5 #ifndef GOOGLE_APIS_GCM_ENGINE_REGISTRATION_REQUEST_H_
6 #define GOOGLE_APIS_GCM_ENGINE_REGISTRATION_REQUEST_H_
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"
19 class URLRequestContextGetter
;
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
{
30 // Callback completing the registration request.
31 typedef base::Callback
<void(const std::string
& registration_id
)>
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 GCM_EXPORT 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
);
47 // Android ID of the device.
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
;
57 // Certificate of the application.
59 // List of IDs of senders. Allowed up to 100.
60 std::vector
<std::string
> sender_ids
;
64 const RequestInfo
& request_info
,
65 const RegistrationCallback
& callback
,
66 scoped_refptr
<net::URLRequestContextGetter
> request_context_getter
);
67 virtual ~RegistrationRequest();
71 // URLFetcherDelegate implementation.
72 virtual void OnURLFetchComplete(const net::URLFetcher
* source
) OVERRIDE
;
75 RegistrationCallback callback_
;
76 RequestInfo request_info_
;
78 scoped_refptr
<net::URLRequestContextGetter
> request_context_getter_
;
79 scoped_ptr
<net::URLFetcher
> url_fetcher_
;
81 DISALLOW_COPY_AND_ASSIGN(RegistrationRequest
);
86 #endif // GOOGLE_APIS_GCM_ENGINE_REGISTRATION_REQUEST_H_