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

Unified 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: Adding RegistrationRequest::RequestInfo to the list of exports 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | google_apis/gcm/engine/registration_request.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: google_apis/gcm/engine/registration_request.h
diff --git a/google_apis/gcm/engine/registration_request.h b/google_apis/gcm/engine/registration_request.h
new file mode 100644
index 0000000000000000000000000000000000000000..4fffc070d0bd68cf31411104c04c1f1d9833458f
--- /dev/null
+++ b/google_apis/gcm/engine/registration_request.h
@@ -0,0 +1,86 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef GOOGLE_APIS_GCM_ENGINE_REGISTRATION_REQUEST_H_
+#define GOOGLE_APIS_GCM_ENGINE_REGISTRATION_REQUEST_H_
+
+#include <map>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/callback.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "google_apis/gcm/base/gcm_export.h"
+#include "net/url_request/url_fetcher_delegate.h"
+
+namespace net {
+class URLRequestContextGetter;
+}
+
+namespace gcm {
+
+// Registration request is used to obtain registration IDs for applications that
+// want to use GCM. It requires a set of parameters to be specified to identify
+// the Chrome instance, the user, the application and a set of senders that will
+// be authorized to address the application using it's assigned registration ID.
+class GCM_EXPORT RegistrationRequest : public net::URLFetcherDelegate {
+ public:
+ // Callback completing the registration request.
+ typedef base::Callback<void(const std::string& registration_id)>
+ RegistrationCallback;
+
+ // Details of the of the Registration Request. Only user's android ID and
+ // its serial number are optional and can be set to 0. All other parameters
+ // have to be specified to successfully complete the call.
+ struct GCM_EXPORT RequestInfo {
+ RequestInfo(uint64 android_id,
+ uint64 security_token,
+ uint64 user_android_id,
+ int64 user_serial_number,
+ const std::string& app_id,
+ const std::string& cert,
+ const std::vector<std::string>& sender_ids);
+ ~RequestInfo();
+
+ // Android ID of the device.
+ uint64 android_id;
+ // Security token of the device.
+ uint64 security_token;
+ // User's android ID. (Can be omitted in a single user scenario.)
+ uint64 user_android_id;
+ // User's serial number. (Can be omitted in a single user scenario.)
+ int64 user_serial_number;
+ // Application ID.
+ std::string app_id;
+ // Certificate of the application.
+ std::string cert;
+ // List of IDs of senders. Allowed up to 100.
+ std::vector<std::string> sender_ids;
+ };
+
+ RegistrationRequest(
+ const RequestInfo& request_info,
+ const RegistrationCallback& callback,
+ scoped_refptr<net::URLRequestContextGetter> request_context_getter);
+ virtual ~RegistrationRequest();
+
+ void Start();
+
+ // URLFetcherDelegate implementation.
+ virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
+
+ private:
+ RegistrationCallback callback_;
+ RequestInfo request_info_;
+
+ scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
+ scoped_ptr<net::URLFetcher> url_fetcher_;
+
+ DISALLOW_COPY_AND_ASSIGN(RegistrationRequest);
+};
+
+} // namespace gcm
+
+#endif // GOOGLE_APIS_GCM_ENGINE_REGISTRATION_REQUEST_H_
« no previous file with comments | « no previous file | google_apis/gcm/engine/registration_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698