diff options
author | juyik@chromium.org <juyik@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-07 19:52:43 +0000 |
---|---|---|
committer | juyik@chromium.org <juyik@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-07 19:52:43 +0000 |
commit | 3560181b09d99d0c3dbe3c4c2f9a1c5346475dc5 (patch) | |
tree | 3a2efdc0c811570f6133b506d4076e3adaea7151 /google_apis | |
parent | fb4f5cd534a8b6ad217136f5ed57e5ceba806e38 (diff) | |
download | chromium_src-3560181b09d99d0c3dbe3c4c2f9a1c5346475dc5.zip chromium_src-3560181b09d99d0c3dbe3c4c2f9a1c5346475dc5.tar.gz chromium_src-3560181b09d99d0c3dbe3c4c2f9a1c5346475dc5.tar.bz2 |
Show device information in chrome://gcm-internals page.
OWNER reviewer: arv
BUG=341256
Review URL: https://codereview.chromium.org/176823009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255692 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'google_apis')
-rw-r--r-- | google_apis/gcm/engine/mcs_client.cc | 16 | ||||
-rw-r--r-- | google_apis/gcm/engine/mcs_client.h | 5 | ||||
-rw-r--r-- | google_apis/gcm/gcm_client.cc | 7 | ||||
-rw-r--r-- | google_apis/gcm/gcm_client.h | 16 | ||||
-rw-r--r-- | google_apis/gcm/gcm_client_impl.cc | 31 | ||||
-rw-r--r-- | google_apis/gcm/gcm_client_impl.h | 6 |
6 files changed, 81 insertions, 0 deletions
diff --git a/google_apis/gcm/engine/mcs_client.cc b/google_apis/gcm/engine/mcs_client.cc index 7cbd9ae..c203c2a 100644 --- a/google_apis/gcm/engine/mcs_client.cc +++ b/google_apis/gcm/engine/mcs_client.cc @@ -128,6 +128,22 @@ ReliablePacketInfo::ReliablePacketInfo() } ReliablePacketInfo::~ReliablePacketInfo() {} +std::string MCSClient::GetStateString() const { + switch(state_) { + case UNINITIALIZED: + return "UNINITIALIZED"; + case LOADED: + return "LOADED"; + case CONNECTING: + return "CONNECTING"; + case CONNECTED: + return "CONNECTED"; + default: + NOTREACHED(); + return std::string(); + } +} + MCSClient::MCSClient(const std::string& version_string, base::Clock* clock, ConnectionFactory* connection_factory, diff --git a/google_apis/gcm/engine/mcs_client.h b/google_apis/gcm/engine/mcs_client.h index f254566..c3009b8 100644 --- a/google_apis/gcm/engine/mcs_client.h +++ b/google_apis/gcm/engine/mcs_client.h @@ -45,6 +45,8 @@ struct ReliablePacketInfo; // network requests are performed on. class GCM_EXPORT MCSClient { public: + // Any change made to this enum should have corresponding change in the + // GetStateString(...) function. enum State { UNINITIALIZED, // Uninitialized. LOADED, // GCM Load finished, waiting to connect. @@ -125,6 +127,9 @@ class GCM_EXPORT MCSClient { // Returns the current state of the client. State state() const { return state_; } + // Returns text representation of the state enum. + std::string GetStateString() const; + protected: // Sets a |gcm_store| for testing. Does not take ownership. // TODO(fgorski): Remove this method. Create GCMEngineFactory that will create diff --git a/google_apis/gcm/gcm_client.cc b/google_apis/gcm/gcm_client.cc index 33098f8..78b4e08 100644 --- a/google_apis/gcm/gcm_client.cc +++ b/google_apis/gcm/gcm_client.cc @@ -19,6 +19,13 @@ GCMClient::IncomingMessage::IncomingMessage() { GCMClient::IncomingMessage::~IncomingMessage() { } +GCMClient::GCMStatistics::GCMStatistics() + : gcm_client_created(false), connection_client_created(false) { +} + +GCMClient::GCMStatistics::~GCMStatistics() { +} + GCMClient::GCMClient() { } diff --git a/google_apis/gcm/gcm_client.h b/google_apis/gcm/gcm_client.h index c879c56..7bffa4c 100644 --- a/google_apis/gcm/gcm_client.h +++ b/google_apis/gcm/gcm_client.h @@ -78,6 +78,19 @@ class GCM_EXPORT GCMClient { std::string sender_id; }; + // Internal states and activity statistics of a GCM client. + struct GCM_EXPORT GCMStatistics { + public: + GCMStatistics(); + ~GCMStatistics(); + + bool gcm_client_created; + std::string gcm_client_state; + bool connection_client_created; + std::string connection_state; + uint64 android_id; + }; + // A delegate interface that allows the GCMClient instance to interact with // its caller, i.e. notifying asynchronous event. class Delegate { @@ -185,6 +198,9 @@ class GCM_EXPORT GCMClient { virtual void Send(const std::string& app_id, const std::string& receiver_id, const OutgoingMessage& message) = 0; + + // Gets internal states and statistics. + virtual GCMStatistics GetStatistics() const = 0; }; } // namespace gcm diff --git a/google_apis/gcm/gcm_client_impl.cc b/google_apis/gcm/gcm_client_impl.cc index d7ae743..af20a5a 100644 --- a/google_apis/gcm/gcm_client_impl.cc +++ b/google_apis/gcm/gcm_client_impl.cc @@ -416,6 +416,37 @@ void GCMClientImpl::Send(const std::string& app_id, mcs_client_->SendMessage(mcs_message); } +std::string GCMClientImpl::GetStateString() const { + switch(state_) { + case GCMClientImpl::INITIALIZED: + return "INITIALIZED"; + case GCMClientImpl::UNINITIALIZED: + return "UNINITIALIZED"; + case GCMClientImpl::LOADING: + return "LOADING"; + case GCMClientImpl::INITIAL_DEVICE_CHECKIN: + return "INITIAL_DEVICE_CHECKIN"; + case GCMClientImpl::READY: + return "READY"; + default: + NOTREACHED(); + return std::string(); + } +} + +GCMClient::GCMStatistics GCMClientImpl::GetStatistics() const { + GCMClient::GCMStatistics stats; + stats.gcm_client_state = GCMClientImpl::GetStateString(); + stats.connection_client_created = mcs_client_.get() != NULL; + if (mcs_client_.get()) { + stats.connection_state = mcs_client_->GetStateString(); + // TODO(juyik): add more statistics such as message metadata list, etc. + } + if (device_checkin_info_.android_id > 0) + stats.android_id = device_checkin_info_.android_id; + return stats; +} + void GCMClientImpl::OnMessageReceivedFromMCS(const gcm::MCSMessage& message) { switch (message.tag()) { case kLoginResponseTag: diff --git a/google_apis/gcm/gcm_client_impl.h b/google_apis/gcm/gcm_client_impl.h index 4050b36..f7eafcb 100644 --- a/google_apis/gcm/gcm_client_impl.h +++ b/google_apis/gcm/gcm_client_impl.h @@ -64,9 +64,12 @@ class GCM_EXPORT GCMClientImpl : public GCMClient { virtual void Send(const std::string& app_id, const std::string& receiver_id, const OutgoingMessage& message) OVERRIDE; + virtual GCMStatistics GetStatistics() const OVERRIDE; private: // State representation of the GCMClient. + // Any change made to this enum should have corresponding change in the + // GetStateString(...) function. enum State { // Uninitialized. UNINITIALIZED, @@ -107,6 +110,9 @@ class GCM_EXPORT GCMClientImpl : public GCMClient { friend class GCMClientImplTest; + // Returns text representation of the enum State. + std::string GetStateString() const; + // Callbacks for the MCSClient. // Receives messages and dispatches them to relevant user delegates. void OnMessageReceivedFromMCS(const gcm::MCSMessage& message); |