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

Unified Diff: google_apis/gcm/gcm_client_impl.h

Issue 215363007: [GCM] Adding basic G-services handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding unit tests and addressing CR feedback Created 6 years, 9 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
Index: google_apis/gcm/gcm_client_impl.h
diff --git a/google_apis/gcm/gcm_client_impl.h b/google_apis/gcm/gcm_client_impl.h
index 4aa38ba3a8102a8bf21567b62760f1dc41d460c3..a5ce4df6f0be41f76623f0ed24d994ed3dde8f3c 100644
--- a/google_apis/gcm/gcm_client_impl.h
+++ b/google_apis/gcm/gcm_client_impl.h
@@ -19,7 +19,7 @@
#include "google_apis/gcm/engine/registration_request.h"
#include "google_apis/gcm/engine/unregistration_request.h"
#include "google_apis/gcm/gcm_client.h"
-#include "google_apis/gcm/protocol/android_checkin.pb.h"
+#include "google_apis/gcm/protocol/checkin.pb.h"
#include "net/base/net_log.h"
#include "net/url_request/url_request_context_getter.h"
@@ -39,6 +39,9 @@ class CheckinRequest;
class ConnectionFactory;
class GCMClientImplTest;
+// Map with GServices settings.
+typedef std::map<std::string, std::string> GServicesSettingsMap;
+
// Helper class for building GCM internals. Allows tests to inject fake versions
// as necessary.
class GCM_EXPORT GCMInternalsBuilder {
@@ -162,12 +165,14 @@ class GCM_EXPORT GCMClientImpl : public GCMClient {
void OnReady();
// Starts a first time device checkin.
- void StartCheckin(const CheckinInfo& checkin_info);
- // Completes the device checkin request.
- // |android_id| and |security_token| are expected to be non-zero or an error
- // is triggered. Function also cleans up the pending checkin.
- void OnCheckinCompleted(uint64 android_id,
- uint64 security_token);
+ void StartCheckin();
+ // Completes the device checkin request by parsing the |checkin_response|.
+ // Function also cleans up the pending checkin.
+ void OnCheckinCompleted(
+ const checkin_proto::AndroidCheckinResponse& checkin_response);
+ // Schedules next device checkin, based on |last_checkin_time| and
+ // checkin_interval specified in GServices settings.
+ void SchedulePeriodicCheckin(const base::Time& last_checkin_time);
// Callback for persisting device credentials in the |gcm_store_|.
void SetDeviceCredentialsCallback(bool success);
@@ -203,6 +208,16 @@ class GCM_EXPORT GCMClientImpl : public GCMClient {
const mcs_proto::DataMessageStanza& data_message_stanza,
MessageData& message_data);
+ // Updates the GServicesSettings based on the |checkin_response|.
+ void UpdateGServicesSettings(
+ const checkin_proto::AndroidCheckinResponse& checkin_response);
+ // Completes the GServicesSettings update request.
+ void UpdateGServicesSettingsCallback(bool success);
+
+ // Calculates the Checkin interval based on the services settings or defaults
+ // to a sensible value. Virtual for testing.
+ virtual base::TimeDelta GetCheckinInterval();
jianli 2014/03/31 17:45:35 nit: add const
fgorski 2014/03/31 21:50:08 Done.
+
// Builder for the GCM internals (mcs client, etc.).
scoped_ptr<GCMInternalsBuilder> internals_builder_;
@@ -231,6 +246,9 @@ class GCM_EXPORT GCMClientImpl : public GCMClient {
scoped_ptr<ConnectionFactory> connection_factory_;
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
+ // Map with GServices settings, such us checkin_interval, checkin_url, etc.
+ GServicesSettingsMap gservices_settings_;
+
// Controls receiving and sending of packets and reliable message queueing.
scoped_ptr<MCSClient> mcs_client_;

Powered by Google App Engine
This is Rietveld 408576698