diff options
author | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-03 21:51:12 +0000 |
---|---|---|
committer | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-03 21:51:12 +0000 |
commit | 025adfa494d92b8860ff9307eefabe09553657b8 (patch) | |
tree | 85f12ac3024cdbccf61c0f2b81b6dfc8fa82df81 /google_apis | |
parent | 7fd6959f1d0dfae4ecb0cd8ab7894700db68a1fd (diff) | |
download | chromium_src-025adfa494d92b8860ff9307eefabe09553657b8.zip chromium_src-025adfa494d92b8860ff9307eefabe09553657b8.tar.gz chromium_src-025adfa494d92b8860ff9307eefabe09553657b8.tar.bz2 |
Rename GCMStatsRecorder to GCMStatsRecorderImpl
We also add the interface using the old name GCMStatsRecorder.
This is in preparation to move GCMClient to gcm_driver component.
We're going to move GCMActivity, GCMClient, GCMClientImpl, and
GCMStatsRecorderImpl to gcm_driver component while keeping
GCMStatsRecorder interface in google_apis/gcm.
BUG=356716
TEST=existing tests due to no functionality changes
R=juyik@chromium.org, zea@chromium.org
Review URL: https://codereview.chromium.org/312553002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274641 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'google_apis')
-rw-r--r-- | google_apis/gcm/engine/checkin_request_unittest.cc | 4 | ||||
-rw-r--r-- | google_apis/gcm/engine/connection_factory_impl_unittest.cc | 4 | ||||
-rw-r--r-- | google_apis/gcm/engine/mcs_client_unittest.cc | 4 | ||||
-rw-r--r-- | google_apis/gcm/engine/registration_request_unittest.cc | 4 | ||||
-rw-r--r-- | google_apis/gcm/engine/unregistration_request_unittest.cc | 4 | ||||
-rw-r--r-- | google_apis/gcm/gcm.gyp | 47 | ||||
-rw-r--r-- | google_apis/gcm/gcm_client_impl.h | 4 | ||||
-rw-r--r-- | google_apis/gcm/monitoring/fake_gcm_stats_recorder.cc | 107 | ||||
-rw-r--r-- | google_apis/gcm/monitoring/fake_gcm_stats_recorder.h | 71 | ||||
-rw-r--r-- | google_apis/gcm/monitoring/gcm_stats_recorder.h | 185 | ||||
-rw-r--r-- | google_apis/gcm/monitoring/gcm_stats_recorder_impl.cc (renamed from google_apis/gcm/monitoring/gcm_stats_recorder.cc) | 79 | ||||
-rw-r--r-- | google_apis/gcm/monitoring/gcm_stats_recorder_impl.h | 156 | ||||
-rw-r--r-- | google_apis/gcm/monitoring/gcm_stats_recorder_impl_unittest.cc (renamed from google_apis/gcm/monitoring/gcm_stats_recorder_unittest.cc) | 30 | ||||
-rw-r--r-- | google_apis/gcm/tools/mcs_probe.cc | 4 |
14 files changed, 492 insertions, 211 deletions
diff --git a/google_apis/gcm/engine/checkin_request_unittest.cc b/google_apis/gcm/engine/checkin_request_unittest.cc index 306563e8..4fea361 100644 --- a/google_apis/gcm/engine/checkin_request_unittest.cc +++ b/google_apis/gcm/engine/checkin_request_unittest.cc @@ -6,7 +6,7 @@ #include <vector> #include "google_apis/gcm/engine/checkin_request.h" -#include "google_apis/gcm/monitoring/gcm_stats_recorder.h" +#include "google_apis/gcm/monitoring/fake_gcm_stats_recorder.h" #include "google_apis/gcm/protocol/checkin.pb.h" #include "net/base/backoff_entry.h" #include "net/url_request/test_url_fetcher_factory.h" @@ -92,7 +92,7 @@ class CheckinRequestTest : public testing::Test { checkin_proto::ChromeBuildProto chrome_build_proto_; std::vector<std::string> account_ids_; scoped_ptr<CheckinRequest> request_; - GCMStatsRecorder recorder_; + FakeGCMStatsRecorder recorder_; }; CheckinRequestTest::CheckinRequestTest() diff --git a/google_apis/gcm/engine/connection_factory_impl_unittest.cc b/google_apis/gcm/engine/connection_factory_impl_unittest.cc index ae120fe..1d21943 100644 --- a/google_apis/gcm/engine/connection_factory_impl_unittest.cc +++ b/google_apis/gcm/engine/connection_factory_impl_unittest.cc @@ -11,7 +11,7 @@ #include "base/test/simple_test_tick_clock.h" #include "google_apis/gcm/base/mcs_util.h" #include "google_apis/gcm/engine/fake_connection_handler.h" -#include "google_apis/gcm/monitoring/gcm_stats_recorder.h" +#include "google_apis/gcm/monitoring/fake_gcm_stats_recorder.h" #include "net/base/backoff_entry.h" #include "net/http/http_network_session.h" #include "testing/gtest/include/gtest/gtest.h" @@ -150,7 +150,7 @@ class TestConnectionFactoryImpl : public ConnectionFactoryImpl { base::Closure finished_callback_; // The current fake connection handler.. FakeConnectionHandler* fake_handler_; - GCMStatsRecorder dummy_recorder_; + FakeGCMStatsRecorder dummy_recorder_; }; TestConnectionFactoryImpl::TestConnectionFactoryImpl( diff --git a/google_apis/gcm/engine/mcs_client_unittest.cc b/google_apis/gcm/engine/mcs_client_unittest.cc index 3e94532..915b25d 100644 --- a/google_apis/gcm/engine/mcs_client_unittest.cc +++ b/google_apis/gcm/engine/mcs_client_unittest.cc @@ -15,7 +15,7 @@ #include "google_apis/gcm/engine/fake_connection_factory.h" #include "google_apis/gcm/engine/fake_connection_handler.h" #include "google_apis/gcm/engine/gcm_store_impl.h" -#include "google_apis/gcm/monitoring/gcm_stats_recorder.h" +#include "google_apis/gcm/monitoring/fake_gcm_stats_recorder.h" #include "testing/gtest/include/gtest/gtest.h" namespace gcm { @@ -139,7 +139,7 @@ class MCSClientTest : public testing::Test { std::string sent_message_id_; MCSClient::MessageSendStatus message_send_status_; - gcm::GCMStatsRecorder recorder_; + gcm::FakeGCMStatsRecorder recorder_; }; MCSClientTest::MCSClientTest() diff --git a/google_apis/gcm/engine/registration_request_unittest.cc b/google_apis/gcm/engine/registration_request_unittest.cc index 37f2575..c5b8c76 100644 --- a/google_apis/gcm/engine/registration_request_unittest.cc +++ b/google_apis/gcm/engine/registration_request_unittest.cc @@ -9,7 +9,7 @@ #include "base/strings/string_number_conversions.h" #include "base/strings/string_tokenizer.h" #include "google_apis/gcm/engine/registration_request.h" -#include "google_apis/gcm/monitoring/gcm_stats_recorder.h" +#include "google_apis/gcm/monitoring/fake_gcm_stats_recorder.h" #include "net/url_request/test_url_fetcher_factory.h" #include "net/url_request/url_request_status.h" #include "net/url_request/url_request_test_util.h" @@ -82,7 +82,7 @@ class RegistrationRequestTest : public testing::Test { base::MessageLoop message_loop_; net::TestURLFetcherFactory url_fetcher_factory_; scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_; - GCMStatsRecorder recorder_; + FakeGCMStatsRecorder recorder_; }; RegistrationRequestTest::RegistrationRequestTest() diff --git a/google_apis/gcm/engine/unregistration_request_unittest.cc b/google_apis/gcm/engine/unregistration_request_unittest.cc index 02f4968..2471503 100644 --- a/google_apis/gcm/engine/unregistration_request_unittest.cc +++ b/google_apis/gcm/engine/unregistration_request_unittest.cc @@ -9,7 +9,7 @@ #include "base/strings/string_number_conversions.h" #include "base/strings/string_tokenizer.h" #include "google_apis/gcm/engine/unregistration_request.h" -#include "google_apis/gcm/monitoring/gcm_stats_recorder.h" +#include "google_apis/gcm/monitoring/fake_gcm_stats_recorder.h" #include "net/url_request/test_url_fetcher_factory.h" #include "net/url_request/url_request_test_util.h" #include "testing/gtest/include/gtest/gtest.h" @@ -73,7 +73,7 @@ class UnregistrationRequestTest : public testing::Test { base::MessageLoop message_loop_; net::TestURLFetcherFactory url_fetcher_factory_; scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_; - GCMStatsRecorder recorder_; + FakeGCMStatsRecorder recorder_; }; UnregistrationRequestTest::UnregistrationRequestTest() diff --git a/google_apis/gcm/gcm.gyp b/google_apis/gcm/gcm.gyp index 33365f0..b496281 100644 --- a/google_apis/gcm/gcm.gyp +++ b/google_apis/gcm/gcm.gyp @@ -75,8 +75,9 @@ 'gcm_client.h', 'gcm_client_impl.cc', 'gcm_client_impl.h', - 'monitoring/gcm_stats_recorder.cc', 'monitoring/gcm_stats_recorder.h', + 'monitoring/gcm_stats_recorder_impl.cc', + 'monitoring/gcm_stats_recorder_impl.h', 'protocol/android_checkin.proto', 'protocol/checkin.proto', 'protocol/mcs.proto', @@ -86,6 +87,34 @@ ], }, + # The test support library that is needed to test gcm. + { + 'target_name': 'gcm_test_support', + 'type': 'static_library', + 'include_dirs': [ + '..', + ], + 'export_dependent_settings': [ + '../../third_party/protobuf/protobuf.gyp:protobuf_lite' + ], + 'dependencies': [ + '../../base/base.gyp:base', + '../../testing/gtest.gyp:gtest', + '../../third_party/protobuf/protobuf.gyp:protobuf_lite', + 'gcm', + ], + 'sources': [ + 'base/fake_encryptor.cc', + 'base/fake_encryptor.h', + 'engine/fake_connection_factory.cc', + 'engine/fake_connection_factory.h', + 'engine/fake_connection_handler.cc', + 'engine/fake_connection_handler.h', + 'monitoring/fake_gcm_stats_recorder.cc', + 'monitoring/fake_gcm_stats_recorder.h', + ], + }, + # A standalone MCS (mobile connection server) client. { 'target_name': 'mcs_probe', @@ -99,11 +128,10 @@ '../../net/net.gyp:net', '../../net/net.gyp:net_test_support', '../../third_party/protobuf/protobuf.gyp:protobuf_lite', - 'gcm' + 'gcm', + 'gcm_test_support' ], 'sources': [ - 'base/fake_encryptor.cc', - 'base/fake_encryptor.h', 'tools/mcs_probe.cc', ], }, @@ -127,21 +155,16 @@ '../../testing/gtest.gyp:gtest', '../../third_party/protobuf/protobuf.gyp:protobuf_lite', 'mcs_probe', - 'gcm' + 'gcm', + 'gcm_test_support' ], 'sources': [ - 'base/fake_encryptor.cc', - 'base/fake_encryptor.h', 'base/mcs_message_unittest.cc', 'base/mcs_util_unittest.cc', 'base/socket_stream_unittest.cc', 'engine/checkin_request_unittest.cc', 'engine/connection_factory_impl_unittest.cc', 'engine/connection_handler_impl_unittest.cc', - 'engine/fake_connection_factory.cc', - 'engine/fake_connection_factory.h', - 'engine/fake_connection_handler.cc', - 'engine/fake_connection_handler.h', 'engine/gcm_store_impl_unittest.cc', 'engine/gservices_settings_unittest.cc', 'engine/heartbeat_manager_unittest.cc', @@ -149,7 +172,7 @@ 'engine/registration_request_unittest.cc', 'engine/unregistration_request_unittest.cc', 'gcm_client_impl_unittest.cc', - 'monitoring/gcm_stats_recorder_unittest.cc' + 'monitoring/gcm_stats_recorder_impl_unittest.cc' ] }, ], diff --git a/google_apis/gcm/gcm_client_impl.h b/google_apis/gcm/gcm_client_impl.h index e2f1b02..e543d73 100644 --- a/google_apis/gcm/gcm_client_impl.h +++ b/google_apis/gcm/gcm_client_impl.h @@ -20,7 +20,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/monitoring/gcm_stats_recorder.h" +#include "google_apis/gcm/monitoring/gcm_stats_recorder_impl.h" #include "google_apis/gcm/protocol/android_checkin.pb.h" #include "google_apis/gcm/protocol/checkin.pb.h" #include "net/base/net_log.h" @@ -233,7 +233,7 @@ class GCM_EXPORT GCMClientImpl scoped_ptr<GCMInternalsBuilder> internals_builder_; // Recorder that logs GCM activities. - GCMStatsRecorder recorder_; + GCMStatsRecorderImpl recorder_; // State of the GCM Client Implementation. State state_; diff --git a/google_apis/gcm/monitoring/fake_gcm_stats_recorder.cc b/google_apis/gcm/monitoring/fake_gcm_stats_recorder.cc new file mode 100644 index 0000000..5ed8a1d --- /dev/null +++ b/google_apis/gcm/monitoring/fake_gcm_stats_recorder.cc @@ -0,0 +1,107 @@ +// Copyright 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.
+
+#include "google_apis/gcm/monitoring/fake_gcm_stats_recorder.h"
+
+namespace gcm {
+
+FakeGCMStatsRecorder::FakeGCMStatsRecorder() {
+}
+
+FakeGCMStatsRecorder::~FakeGCMStatsRecorder() {
+}
+
+void FakeGCMStatsRecorder::RecordCheckinInitiated(uint64 android_id) {
+}
+
+void FakeGCMStatsRecorder::RecordCheckinDelayedDueToBackoff(int64 delay_msec) {
+}
+
+void FakeGCMStatsRecorder::RecordCheckinSuccess() {
+}
+
+void FakeGCMStatsRecorder::RecordCheckinFailure(std::string status,
+ bool will_retry) {
+}
+
+void FakeGCMStatsRecorder::RecordConnectionInitiated(const std::string& host) {
+}
+
+void FakeGCMStatsRecorder::RecordConnectionDelayedDueToBackoff(
+ int64 delay_msec) {
+}
+
+void FakeGCMStatsRecorder::RecordConnectionSuccess() {
+}
+
+void FakeGCMStatsRecorder::RecordConnectionFailure(int network_error) {
+}
+
+void FakeGCMStatsRecorder::RecordConnectionResetSignaled(
+ ConnectionFactory::ConnectionResetReason reason) {
+}
+
+void FakeGCMStatsRecorder::RecordRegistrationSent(
+ const std::string& app_id,
+ const std::string& sender_ids) {
+}
+
+void FakeGCMStatsRecorder::RecordRegistrationResponse(
+ const std::string& app_id,
+ const std::vector<std::string>& sender_ids,
+ RegistrationRequest::Status status) {
+}
+
+void FakeGCMStatsRecorder::RecordRegistrationRetryRequested(
+ const std::string& app_id,
+ const std::vector<std::string>& sender_ids,
+ int retries_left) {
+}
+
+void FakeGCMStatsRecorder::RecordUnregistrationSent(
+ const std::string& app_id) {
+}
+
+void FakeGCMStatsRecorder::RecordUnregistrationResponse(
+ const std::string& app_id,
+ UnregistrationRequest::Status status) {
+}
+
+void FakeGCMStatsRecorder::RecordUnregistrationRetryDelayed(
+ const std::string& app_id,
+ int64 delay_msec) {
+}
+
+void FakeGCMStatsRecorder::RecordDataMessageReceived(
+ const std::string& app_id,
+ const std::string& from,
+ int message_byte_size,
+ bool to_registered_app,
+ ReceivedMessageType message_type) {
+}
+
+void FakeGCMStatsRecorder::RecordDataSentToWire(
+ const std::string& app_id,
+ const std::string& receiver_id,
+ const std::string& message_id,
+ int queued) {
+}
+
+void FakeGCMStatsRecorder::RecordNotifySendStatus(
+ const std::string& app_id,
+ const std::string& receiver_id,
+ const std::string& message_id,
+ gcm::MCSClient::MessageSendStatus status,
+ int byte_size,
+ int ttl) {
+}
+
+void FakeGCMStatsRecorder::RecordIncomingSendError(
+ const std::string& app_id,
+ const std::string& receiver_id,
+ const std::string& message_id) {
+}
+
+
+} // namespace gcm
diff --git a/google_apis/gcm/monitoring/fake_gcm_stats_recorder.h b/google_apis/gcm/monitoring/fake_gcm_stats_recorder.h new file mode 100644 index 0000000..1ada611 --- /dev/null +++ b/google_apis/gcm/monitoring/fake_gcm_stats_recorder.h @@ -0,0 +1,71 @@ +// Copyright 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_MONITORING_FAKE_GCM_STATS_RECODER_H_
+#define GOOGLE_APIS_GCM_MONITORING_FAKE_GCM_STATS_RECODER_H_
+
+#include "google_apis/gcm/monitoring/gcm_stats_recorder.h"
+
+namespace gcm {
+
+// The fake version of GCMStatsRecorder that does nothing.
+class FakeGCMStatsRecorder : public GCMStatsRecorder {
+ public:
+ FakeGCMStatsRecorder();
+ virtual ~FakeGCMStatsRecorder();
+
+ virtual void RecordCheckinInitiated(uint64 android_id) OVERRIDE;
+ virtual void RecordCheckinDelayedDueToBackoff(int64 delay_msec) OVERRIDE;
+ virtual void RecordCheckinSuccess() OVERRIDE;
+ virtual void RecordCheckinFailure(std::string status,
+ bool will_retry) OVERRIDE;
+ virtual void RecordConnectionInitiated(const std::string& host) OVERRIDE;
+ virtual void RecordConnectionDelayedDueToBackoff(int64 delay_msec) OVERRIDE;
+ virtual void RecordConnectionSuccess() OVERRIDE;
+ virtual void RecordConnectionFailure(int network_error) OVERRIDE;
+ virtual void RecordConnectionResetSignaled(
+ ConnectionFactory::ConnectionResetReason reason) OVERRIDE;
+ virtual void RecordRegistrationSent(const std::string& app_id,
+ const std::string& sender_ids) OVERRIDE;
+ virtual void RecordRegistrationResponse(
+ const std::string& app_id,
+ const std::vector<std::string>& sender_ids,
+ RegistrationRequest::Status status) OVERRIDE;
+ virtual void RecordRegistrationRetryRequested(
+ const std::string& app_id,
+ const std::vector<std::string>& sender_ids,
+ int retries_left) OVERRIDE;
+ virtual void RecordUnregistrationSent(const std::string& app_id) OVERRIDE;
+ virtual void RecordUnregistrationResponse(
+ const std::string& app_id,
+ UnregistrationRequest::Status status) OVERRIDE;
+ virtual void RecordUnregistrationRetryDelayed(const std::string& app_id,
+ int64 delay_msec) OVERRIDE;
+ virtual void RecordDataMessageReceived(
+ const std::string& app_id,
+ const std::string& from,
+ int message_byte_size,
+ bool to_registered_app,
+ ReceivedMessageType message_type) OVERRIDE;
+ virtual void RecordDataSentToWire(const std::string& app_id,
+ const std::string& receiver_id,
+ const std::string& message_id,
+ int queued) OVERRIDE;
+ virtual void RecordNotifySendStatus(const std::string& app_id,
+ const std::string& receiver_id,
+ const std::string& message_id,
+ MCSClient::MessageSendStatus status,
+ int byte_size,
+ int ttl) OVERRIDE;
+ virtual void RecordIncomingSendError(const std::string& app_id,
+ const std::string& receiver_id,
+ const std::string& message_id) OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(FakeGCMStatsRecorder);
+};
+
+} // namespace gcm
+
+#endif // GOOGLE_APIS_GCM_MONITORING_FAKE_GCM_STATS_RECODER_H_
diff --git a/google_apis/gcm/monitoring/gcm_stats_recorder.h b/google_apis/gcm/monitoring/gcm_stats_recorder.h index 45cf5fc..7191569 100644 --- a/google_apis/gcm/monitoring/gcm_stats_recorder.h +++ b/google_apis/gcm/monitoring/gcm_stats_recorder.h @@ -2,10 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef GOOGLE_APIS_GCM_GCM_STATS_RECORDER_H_ -#define GOOGLE_APIS_GCM_GCM_STATS_RECORDER_H_ +#ifndef GOOGLE_APIS_GCM_MONITORING_GCM_STATS_RECORDER_H_ +#define GOOGLE_APIS_GCM_MONITORING_GCM_STATS_RECORDER_H_ -#include <deque> #include <string> #include <vector> @@ -15,15 +14,11 @@ #include "google_apis/gcm/engine/mcs_client.h" #include "google_apis/gcm/engine/registration_request.h" #include "google_apis/gcm/engine/unregistration_request.h" -#include "google_apis/gcm/gcm_activity.h" namespace gcm { -// Records GCM internal stats and activities for debugging purpose. Recording -// can be turned on/off by calling SetRecording(...) function. It is turned off -// by default. -// This class is not thread safe. It is meant to be owned by a gcm client -// instance. +// Defines the interface to record GCM internal stats and activities for +// debugging purpose. class GCM_EXPORT GCMStatsRecorder { public: // Type of a received message @@ -34,181 +29,107 @@ class GCM_EXPORT GCMStatsRecorder { DELETED_MESSAGES, }; - // A delegate interface that allows the GCMStatsRecorder instance to interact - // with its container. + // A delegate interface that allows the GCMStatsRecorderImpl instance to + // interact with its container. class Delegate { - public: - // Called when the GCMStatsRecorder is recording activities and a new + public: + // Called when the GCMStatsRecorderImpl is recording activities and a new // activity has just been recorded. virtual void OnActivityRecorded() = 0; }; - GCMStatsRecorder(); - virtual ~GCMStatsRecorder(); - - // Indicates whether the recorder is currently recording activities or not. - bool is_recording() const { - return is_recording_; - } - - // Turns recording on/off. - void SetRecording(bool recording); - - // Set a delegate to receive callback from the recorder. - void SetDelegate(Delegate* delegate); - - // Clear all recorded activities. - void Clear(); - - // All RecordXXXX methods below will record one activity. It will be inserted - // to the front of a queue so that entries in the queue had reverse - // chronological order. + GCMStatsRecorder() {} + virtual ~GCMStatsRecorder() {} // Records that a check-in has been initiated. - void RecordCheckinInitiated(uint64 android_id); + virtual void RecordCheckinInitiated(uint64 android_id) = 0; // Records that a check-in has been delayed due to backoff. - void RecordCheckinDelayedDueToBackoff(int64 delay_msec); + virtual void RecordCheckinDelayedDueToBackoff(int64 delay_msec) = 0; // Records that a check-in request has succeeded. - void RecordCheckinSuccess(); + virtual void RecordCheckinSuccess() = 0; // Records that a check-in request has failed. If a retry will be tempted then // will_retry should be true. - void RecordCheckinFailure(std::string status, bool will_retry); + virtual void RecordCheckinFailure(std::string status, bool will_retry) = 0; // Records that a connection to MCS has been initiated. - void RecordConnectionInitiated(const std::string& host); + virtual void RecordConnectionInitiated(const std::string& host) = 0; // Records that a connection has been delayed due to backoff. - void RecordConnectionDelayedDueToBackoff(int64 delay_msec); + virtual void RecordConnectionDelayedDueToBackoff(int64 delay_msec) = 0; // Records that connection has been successfully established. - void RecordConnectionSuccess(); + virtual void RecordConnectionSuccess() = 0; // Records that connection has failed with a network error code. - void RecordConnectionFailure(int network_error); + virtual void RecordConnectionFailure(int network_error) = 0; // Records that connection reset has been signaled. - void RecordConnectionResetSignaled( - ConnectionFactory::ConnectionResetReason reason); + virtual void RecordConnectionResetSignaled( + ConnectionFactory::ConnectionResetReason reason) = 0; // Records that a registration request has been sent. This could be initiated // directly from API, or from retry logic. - void RecordRegistrationSent(const std::string& app_id, - const std::string& sender_ids); + virtual void RecordRegistrationSent(const std::string& app_id, + const std::string& sender_ids) = 0; // Records that a registration response has been received from server. - void RecordRegistrationResponse(const std::string& app_id, - const std::vector<std::string>& sender_ids, - RegistrationRequest::Status status); + virtual void RecordRegistrationResponse( + const std::string& app_id, + const std::vector<std::string>& sender_ids, + RegistrationRequest::Status status) = 0; // Records that a registration retry has been requested. The actual retry // action may not occur until some time later according to backoff logic. - void RecordRegistrationRetryRequested( + virtual void RecordRegistrationRetryRequested( const std::string& app_id, const std::vector<std::string>& sender_ids, - int retries_left); + int retries_left) = 0; // Records that an unregistration request has been sent. This could be // initiated directly from API, or from retry logic. - void RecordUnregistrationSent(const std::string& app_id); + virtual void RecordUnregistrationSent(const std::string& app_id) = 0; // Records that an unregistration response has been received from server. - void RecordUnregistrationResponse(const std::string& app_id, - UnregistrationRequest::Status status); + virtual void RecordUnregistrationResponse( + const std::string& app_id, + UnregistrationRequest::Status status) = 0; // Records that an unregistration retry has been requested and delayed due to // backoff logic. - void RecordUnregistrationRetryDelayed(const std::string& app_id, - int64 delay_msec); + virtual void RecordUnregistrationRetryDelayed(const std::string& app_id, + int64 delay_msec) = 0; // Records that a data message has been received. If this message is not // sent to a registered app, to_registered_app shoudl be false. If it // indicates that a message has been dropped on the server, is_message_dropped // should be true. - void RecordDataMessageReceived(const std::string& app_id, - const std::string& from, - int message_byte_size, - bool to_registered_app, - ReceivedMessageType message_type); + virtual void RecordDataMessageReceived(const std::string& app_id, + const std::string& from, + int message_byte_size, + bool to_registered_app, + ReceivedMessageType message_type) = 0; // Records that an outgoing data message was sent over the wire. - void RecordDataSentToWire(const std::string& app_id, - const std::string& receiver_id, - const std::string& message_id, - int queued); + virtual void RecordDataSentToWire(const std::string& app_id, + const std::string& receiver_id, + const std::string& message_id, + int queued) = 0; // Records that the MCS client sent a 'send status' notification to callback. - void RecordNotifySendStatus(const std::string& app_id, - const std::string& receiver_id, - const std::string& message_id, - MCSClient::MessageSendStatus status, - int byte_size, - int ttl); + virtual void RecordNotifySendStatus(const std::string& app_id, + const std::string& receiver_id, + const std::string& message_id, + MCSClient::MessageSendStatus status, + int byte_size, + int ttl) = 0; // Records that a 'send error' message was received. - void RecordIncomingSendError(const std::string& app_id, - const std::string& receiver_id, - const std::string& message_id); - - // Collect all recorded activities into the struct. - void CollectActivities(RecordedActivities* recorder_activities) const; - - const std::deque<CheckinActivity>& checkin_activities() const { - return checkin_activities_; - } - const std::deque<ConnectionActivity>& connection_activities() const { - return connection_activities_; - } - const std::deque<RegistrationActivity>& registration_activities() const { - return registration_activities_; - } - const std::deque<ReceivingActivity>& receiving_activities() const { - return receiving_activities_; - } - const std::deque<SendingActivity>& sending_activities() const { - return sending_activities_; - } - - protected: - // Notify the recorder delegate, if it exists, that an activity has been - // recorded. - void NotifyActivityRecorded(); - - void RecordCheckin(const std::string& event, - const std::string& details); - - void RecordConnection(const std::string& event, - const std::string& details); - - void RecordRegistration(const std::string& app_id, - const std::string& sender_id, - const std::string& event, - const std::string& details); - - void RecordReceiving(const std::string& app_id, - const std::string& from, - int message_byte_size, - const std::string& event, - const std::string& details); - - void RecordSending(const std::string& app_id, - const std::string& receiver_id, - const std::string& message_id, - const std::string& event, - const std::string& details); - - bool is_recording_; - Delegate* delegate_; - - std::deque<CheckinActivity> checkin_activities_; - std::deque<ConnectionActivity> connection_activities_; - std::deque<RegistrationActivity> registration_activities_; - std::deque<ReceivingActivity> receiving_activities_; - std::deque<SendingActivity> sending_activities_; - - DISALLOW_COPY_AND_ASSIGN(GCMStatsRecorder); + virtual void RecordIncomingSendError(const std::string& app_id, + const std::string& receiver_id, + const std::string& message_id) = 0; }; } // namespace gcm -#endif // GOOGLE_APIS_GCM_GCM_STATS_RECORDER_H_ +#endif // GOOGLE_APIS_GCM_MONITORING_GCM_STATS_RECORDER_H_ diff --git a/google_apis/gcm/monitoring/gcm_stats_recorder.cc b/google_apis/gcm/monitoring/gcm_stats_recorder_impl.cc index f6c3e0f..8786d51 100644 --- a/google_apis/gcm/monitoring/gcm_stats_recorder.cc +++ b/google_apis/gcm/monitoring/gcm_stats_recorder_impl.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "google_apis/gcm/monitoring/gcm_stats_recorder.h" +#include "google_apis/gcm/monitoring/gcm_stats_recorder_impl.h" #include <deque> #include <vector> @@ -140,21 +140,23 @@ std::string GetUnregistrationStatusString( } // namespace -GCMStatsRecorder::GCMStatsRecorder() : is_recording_(false), delegate_(NULL) { +GCMStatsRecorderImpl::GCMStatsRecorderImpl() + : is_recording_(false), + delegate_(NULL) { } -GCMStatsRecorder::~GCMStatsRecorder() { +GCMStatsRecorderImpl::~GCMStatsRecorderImpl() { } -void GCMStatsRecorder::SetRecording(bool recording) { +void GCMStatsRecorderImpl::SetRecording(bool recording) { is_recording_ = recording; } -void GCMStatsRecorder::SetDelegate(Delegate* delegate) { +void GCMStatsRecorderImpl::SetDelegate(Delegate* delegate) { delegate_ = delegate; } -void GCMStatsRecorder::Clear() { +void GCMStatsRecorderImpl::Clear() { checkin_activities_.clear(); connection_activities_.clear(); registration_activities_.clear(); @@ -162,12 +164,12 @@ void GCMStatsRecorder::Clear() { sending_activities_.clear(); } -void GCMStatsRecorder::NotifyActivityRecorded() { +void GCMStatsRecorderImpl::NotifyActivityRecorded() { if (delegate_) delegate_->OnActivityRecorded(); } -void GCMStatsRecorder::RecordCheckin( +void GCMStatsRecorderImpl::RecordCheckin( const std::string& event, const std::string& details) { CheckinActivity data; @@ -178,14 +180,14 @@ void GCMStatsRecorder::RecordCheckin( NotifyActivityRecorded(); } -void GCMStatsRecorder::RecordCheckinInitiated(uint64 android_id) { +void GCMStatsRecorderImpl::RecordCheckinInitiated(uint64 android_id) { if (!is_recording_) return; RecordCheckin("Checkin initiated", base::StringPrintf("Android Id: %" PRIu64, android_id)); } -void GCMStatsRecorder::RecordCheckinDelayedDueToBackoff(int64 delay_msec) { +void GCMStatsRecorderImpl::RecordCheckinDelayedDueToBackoff(int64 delay_msec) { if (!is_recording_) return; RecordCheckin("Checkin backoff", @@ -193,13 +195,13 @@ void GCMStatsRecorder::RecordCheckinDelayedDueToBackoff(int64 delay_msec) { delay_msec)); } -void GCMStatsRecorder::RecordCheckinSuccess() { +void GCMStatsRecorderImpl::RecordCheckinSuccess() { if (!is_recording_) return; RecordCheckin("Checkin succeeded", std::string()); } -void GCMStatsRecorder::RecordCheckinFailure(std::string status, +void GCMStatsRecorderImpl::RecordCheckinFailure(std::string status, bool will_retry) { if (!is_recording_) return; @@ -209,7 +211,7 @@ void GCMStatsRecorder::RecordCheckinFailure(std::string status, will_retry ? " Will retry." : "Will not retry.")); } -void GCMStatsRecorder::RecordConnection( +void GCMStatsRecorderImpl::RecordConnection( const std::string& event, const std::string& details) { ConnectionActivity data; @@ -220,13 +222,14 @@ void GCMStatsRecorder::RecordConnection( NotifyActivityRecorded(); } -void GCMStatsRecorder::RecordConnectionInitiated(const std::string& host) { +void GCMStatsRecorderImpl::RecordConnectionInitiated(const std::string& host) { if (!is_recording_) return; RecordConnection("Connection initiated", host); } -void GCMStatsRecorder::RecordConnectionDelayedDueToBackoff(int64 delay_msec) { +void GCMStatsRecorderImpl::RecordConnectionDelayedDueToBackoff( + int64 delay_msec) { if (!is_recording_) return; RecordConnection("Connection backoff", @@ -234,20 +237,20 @@ void GCMStatsRecorder::RecordConnectionDelayedDueToBackoff(int64 delay_msec) { delay_msec)); } -void GCMStatsRecorder::RecordConnectionSuccess() { +void GCMStatsRecorderImpl::RecordConnectionSuccess() { if (!is_recording_) return; RecordConnection("Connection succeeded", std::string()); } -void GCMStatsRecorder::RecordConnectionFailure(int network_error) { +void GCMStatsRecorderImpl::RecordConnectionFailure(int network_error) { if (!is_recording_) return; RecordConnection("Connection failed", base::StringPrintf("With network error %d", network_error)); } -void GCMStatsRecorder::RecordConnectionResetSignaled( +void GCMStatsRecorderImpl::RecordConnectionResetSignaled( ConnectionFactory::ConnectionResetReason reason) { if (!is_recording_) return; @@ -255,7 +258,7 @@ void GCMStatsRecorder::RecordConnectionResetSignaled( GetConnectionResetReasonString(reason)); } -void GCMStatsRecorder::RecordRegistration( +void GCMStatsRecorderImpl::RecordRegistration( const std::string& app_id, const std::string& sender_ids, const std::string& event, @@ -270,7 +273,7 @@ void GCMStatsRecorder::RecordRegistration( NotifyActivityRecorded(); } -void GCMStatsRecorder::RecordRegistrationSent( +void GCMStatsRecorderImpl::RecordRegistrationSent( const std::string& app_id, const std::string& sender_ids) { UMA_HISTOGRAM_COUNTS("GCM.RegistrationRequest", 1); @@ -280,7 +283,7 @@ void GCMStatsRecorder::RecordRegistrationSent( "Registration request sent", std::string()); } -void GCMStatsRecorder::RecordRegistrationResponse( +void GCMStatsRecorderImpl::RecordRegistrationResponse( const std::string& app_id, const std::vector<std::string>& sender_ids, RegistrationRequest::Status status) { @@ -291,7 +294,7 @@ void GCMStatsRecorder::RecordRegistrationResponse( GetRegistrationStatusString(status)); } -void GCMStatsRecorder::RecordRegistrationRetryRequested( +void GCMStatsRecorderImpl::RecordRegistrationRetryRequested( const std::string& app_id, const std::vector<std::string>& sender_ids, int retries_left) { @@ -302,7 +305,7 @@ void GCMStatsRecorder::RecordRegistrationRetryRequested( base::StringPrintf("Retries left: %d", retries_left)); } -void GCMStatsRecorder::RecordUnregistrationSent( +void GCMStatsRecorderImpl::RecordUnregistrationSent( const std::string& app_id) { UMA_HISTOGRAM_COUNTS("GCM.UnregistrationRequest", 1); if (!is_recording_) @@ -311,7 +314,7 @@ void GCMStatsRecorder::RecordUnregistrationSent( std::string()); } -void GCMStatsRecorder::RecordUnregistrationResponse( +void GCMStatsRecorderImpl::RecordUnregistrationResponse( const std::string& app_id, UnregistrationRequest::Status status) { if (!is_recording_) @@ -322,7 +325,7 @@ void GCMStatsRecorder::RecordUnregistrationResponse( GetUnregistrationStatusString(status)); } -void GCMStatsRecorder::RecordUnregistrationRetryDelayed( +void GCMStatsRecorderImpl::RecordUnregistrationRetryDelayed( const std::string& app_id, int64 delay_msec) { if (!is_recording_) @@ -334,7 +337,7 @@ void GCMStatsRecorder::RecordUnregistrationRetryDelayed( delay_msec)); } -void GCMStatsRecorder::RecordReceiving( +void GCMStatsRecorderImpl::RecordReceiving( const std::string& app_id, const std::string& from, int message_byte_size, @@ -351,7 +354,7 @@ void GCMStatsRecorder::RecordReceiving( NotifyActivityRecorded(); } -void GCMStatsRecorder::RecordDataMessageReceived( +void GCMStatsRecorderImpl::RecordDataMessageReceived( const std::string& app_id, const std::string& from, int message_byte_size, @@ -367,11 +370,11 @@ void GCMStatsRecorder::RecordDataMessageReceived( "No such registered app found"); } else { switch(message_type) { - case GCMStatsRecorder::DATA_MESSAGE: + case GCMStatsRecorderImpl::DATA_MESSAGE: RecordReceiving(app_id, from, message_byte_size, "Data msg received", std::string()); break; - case GCMStatsRecorder::DELETED_MESSAGES: + case GCMStatsRecorderImpl::DELETED_MESSAGES: RecordReceiving(app_id, from, message_byte_size, "Data msg received", "Message has been deleted on server"); break; @@ -381,7 +384,7 @@ void GCMStatsRecorder::RecordDataMessageReceived( } } -void GCMStatsRecorder::CollectActivities( +void GCMStatsRecorderImpl::CollectActivities( RecordedActivities* recorder_activities) const { recorder_activities->checkin_activities.insert( recorder_activities->checkin_activities.begin(), @@ -405,11 +408,11 @@ void GCMStatsRecorder::CollectActivities( sending_activities_.end()); } -void GCMStatsRecorder::RecordSending(const std::string& app_id, - const std::string& receiver_id, - const std::string& message_id, - const std::string& event, - const std::string& details) { +void GCMStatsRecorderImpl::RecordSending(const std::string& app_id, + const std::string& receiver_id, + const std::string& message_id, + const std::string& event, + const std::string& details) { SendingActivity data; SendingActivity* inserted_data = InsertCircularBuffer( &sending_activities_, data); @@ -421,7 +424,7 @@ void GCMStatsRecorder::RecordSending(const std::string& app_id, NotifyActivityRecorded(); } -void GCMStatsRecorder::RecordDataSentToWire( +void GCMStatsRecorderImpl::RecordDataSentToWire( const std::string& app_id, const std::string& receiver_id, const std::string& message_id, @@ -432,7 +435,7 @@ void GCMStatsRecorder::RecordDataSentToWire( base::StringPrintf("Msg queued for %d seconds", queued)); } -void GCMStatsRecorder::RecordNotifySendStatus( +void GCMStatsRecorderImpl::RecordNotifySendStatus( const std::string& app_id, const std::string& receiver_id, const std::string& message_id, @@ -452,7 +455,7 @@ void GCMStatsRecorder::RecordNotifySendStatus( base::StringPrintf("Msg size: %d bytes, TTL: %d", byte_size, ttl)); } -void GCMStatsRecorder::RecordIncomingSendError( +void GCMStatsRecorderImpl::RecordIncomingSendError( const std::string& app_id, const std::string& receiver_id, const std::string& message_id) { diff --git a/google_apis/gcm/monitoring/gcm_stats_recorder_impl.h b/google_apis/gcm/monitoring/gcm_stats_recorder_impl.h new file mode 100644 index 0000000..434cb67 --- /dev/null +++ b/google_apis/gcm/monitoring/gcm_stats_recorder_impl.h @@ -0,0 +1,156 @@ +// Copyright 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_GCM_STATS_RECORDER_IMPL_H_ +#define GOOGLE_APIS_GCM_GCM_STATS_RECORDER_IMPL_H_ + +#include <deque> +#include <string> +#include <vector> + +#include "base/time/time.h" +#include "google_apis/gcm/base/gcm_export.h" +#include "google_apis/gcm/engine/connection_factory.h" +#include "google_apis/gcm/engine/mcs_client.h" +#include "google_apis/gcm/engine/registration_request.h" +#include "google_apis/gcm/engine/unregistration_request.h" +#include "google_apis/gcm/gcm_activity.h" +#include "google_apis/gcm/monitoring/gcm_stats_recorder.h" + +namespace gcm { + +// Records GCM internal stats and activities for debugging purpose. Recording +// can be turned on/off by calling SetRecording(...) function. It is turned off +// by default. +// This class is not thread safe. It is meant to be owned by a gcm client +// instance. +class GCM_EXPORT GCMStatsRecorderImpl : public GCMStatsRecorder { + public: + GCMStatsRecorderImpl(); + virtual ~GCMStatsRecorderImpl(); + + // Indicates whether the recorder is currently recording activities or not. + bool is_recording() const { + return is_recording_; + } + + // Turns recording on/off. + void SetRecording(bool recording); + + // Set a delegate to receive callback from the recorder. + void SetDelegate(Delegate* delegate); + + // Clear all recorded activities. + void Clear(); + + // GCMStatsRecorder implementation: + virtual void RecordCheckinInitiated(uint64 android_id) OVERRIDE; + virtual void RecordCheckinDelayedDueToBackoff(int64 delay_msec) OVERRIDE; + virtual void RecordCheckinSuccess() OVERRIDE; + virtual void RecordCheckinFailure(std::string status, + bool will_retry) OVERRIDE; + virtual void RecordConnectionInitiated(const std::string& host) OVERRIDE; + virtual void RecordConnectionDelayedDueToBackoff(int64 delay_msec) OVERRIDE; + virtual void RecordConnectionSuccess() OVERRIDE; + virtual void RecordConnectionFailure(int network_error) OVERRIDE; + virtual void RecordConnectionResetSignaled( + ConnectionFactory::ConnectionResetReason reason) OVERRIDE; + virtual void RecordRegistrationSent(const std::string& app_id, + const std::string& sender_ids) OVERRIDE; + virtual void RecordRegistrationResponse( + const std::string& app_id, + const std::vector<std::string>& sender_ids, + RegistrationRequest::Status status) OVERRIDE; + virtual void RecordRegistrationRetryRequested( + const std::string& app_id, + const std::vector<std::string>& sender_ids, + int retries_left) OVERRIDE; + virtual void RecordUnregistrationSent(const std::string& app_id) OVERRIDE; + virtual void RecordUnregistrationResponse( + const std::string& app_id, + UnregistrationRequest::Status status) OVERRIDE; + virtual void RecordUnregistrationRetryDelayed(const std::string& app_id, + int64 delay_msec) OVERRIDE; + virtual void RecordDataMessageReceived( + const std::string& app_id, + const std::string& from, + int message_byte_size, + bool to_registered_app, + ReceivedMessageType message_type) OVERRIDE; + virtual void RecordDataSentToWire(const std::string& app_id, + const std::string& receiver_id, + const std::string& message_id, + int queued) OVERRIDE; + virtual void RecordNotifySendStatus(const std::string& app_id, + const std::string& receiver_id, + const std::string& message_id, + MCSClient::MessageSendStatus status, + int byte_size, + int ttl) OVERRIDE; + virtual void RecordIncomingSendError(const std::string& app_id, + const std::string& receiver_id, + const std::string& message_id) OVERRIDE; + + // Collect all recorded activities into the struct. + void CollectActivities(RecordedActivities* recorder_activities) const; + + const std::deque<CheckinActivity>& checkin_activities() const { + return checkin_activities_; + } + const std::deque<ConnectionActivity>& connection_activities() const { + return connection_activities_; + } + const std::deque<RegistrationActivity>& registration_activities() const { + return registration_activities_; + } + const std::deque<ReceivingActivity>& receiving_activities() const { + return receiving_activities_; + } + const std::deque<SendingActivity>& sending_activities() const { + return sending_activities_; + } + + protected: + // Notify the recorder delegate, if it exists, that an activity has been + // recorded. + void NotifyActivityRecorded(); + + void RecordCheckin(const std::string& event, + const std::string& details); + + void RecordConnection(const std::string& event, + const std::string& details); + + void RecordRegistration(const std::string& app_id, + const std::string& sender_id, + const std::string& event, + const std::string& details); + + void RecordReceiving(const std::string& app_id, + const std::string& from, + int message_byte_size, + const std::string& event, + const std::string& details); + + void RecordSending(const std::string& app_id, + const std::string& receiver_id, + const std::string& message_id, + const std::string& event, + const std::string& details); + + bool is_recording_; + Delegate* delegate_; + + std::deque<CheckinActivity> checkin_activities_; + std::deque<ConnectionActivity> connection_activities_; + std::deque<RegistrationActivity> registration_activities_; + std::deque<ReceivingActivity> receiving_activities_; + std::deque<SendingActivity> sending_activities_; + + DISALLOW_COPY_AND_ASSIGN(GCMStatsRecorderImpl); +}; + +} // namespace gcm + +#endif // GOOGLE_APIS_GCM_GCM_STATS_RECORDER_IMPL_H_ diff --git a/google_apis/gcm/monitoring/gcm_stats_recorder_unittest.cc b/google_apis/gcm/monitoring/gcm_stats_recorder_impl_unittest.cc index c8756ec..e870a60c 100644 --- a/google_apis/gcm/monitoring/gcm_stats_recorder_unittest.cc +++ b/google_apis/gcm/monitoring/gcm_stats_recorder_impl_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "google_apis/gcm/monitoring/gcm_stats_recorder.h" +#include "google_apis/gcm/monitoring/gcm_stats_recorder_impl.h" #include <deque> #include <string> @@ -97,10 +97,10 @@ static const char kIncomingSendErrorDetails[] = ""; } // namespace -class GCMStatsRecorderTest : public testing::Test { +class GCMStatsRecorderImplTest : public testing::Test { public: - GCMStatsRecorderTest(); - virtual ~GCMStatsRecorderTest(); + GCMStatsRecorderImplTest(); + virtual ~GCMStatsRecorderImplTest(); virtual void SetUp() OVERRIDE; void VerifyRecordedCheckinCount(int expected_count) { @@ -339,21 +339,21 @@ class GCMStatsRecorderTest : public testing::Test { } std::vector<std::string> sender_ids_; - GCMStatsRecorder recorder_; + GCMStatsRecorderImpl recorder_; }; -GCMStatsRecorderTest::GCMStatsRecorderTest(){ +GCMStatsRecorderImplTest::GCMStatsRecorderImplTest(){ } -GCMStatsRecorderTest::~GCMStatsRecorderTest() {} +GCMStatsRecorderImplTest::~GCMStatsRecorderImplTest() {} -void GCMStatsRecorderTest::SetUp(){ +void GCMStatsRecorderImplTest::SetUp(){ sender_ids_.push_back("s1"); sender_ids_.push_back("s2"); recorder_.SetRecording(true); } -TEST_F(GCMStatsRecorderTest, StartStopRecordingTest) { +TEST_F(GCMStatsRecorderImplTest, StartStopRecordingTest) { EXPECT_TRUE(recorder_.is_recording()); recorder_.RecordDataSentToWire(kAppId, kReceiverId, kMessageId, kQueuedSec); VerifyRecordedSendingCount(1); @@ -403,7 +403,7 @@ TEST_F(GCMStatsRecorderTest, StartStopRecordingTest) { VerifyAllActivityQueueEmpty("no sending"); } -TEST_F(GCMStatsRecorderTest, ClearLogTest) { +TEST_F(GCMStatsRecorderImplTest, ClearLogTest) { recorder_.RecordDataSentToWire(kAppId, kReceiverId, kMessageId, kQueuedSec); VerifyRecordedSendingCount(1); VerifyDataSentToWire("1st call"); @@ -417,7 +417,7 @@ TEST_F(GCMStatsRecorderTest, ClearLogTest) { VerifyRecordedSendingCount(0); } -TEST_F(GCMStatsRecorderTest, CheckinTest) { +TEST_F(GCMStatsRecorderImplTest, CheckinTest) { recorder_.RecordCheckinInitiated(kAndroidId); VerifyRecordedCheckinCount(1); VerifyCheckinInitiated("1st call"); @@ -435,7 +435,7 @@ TEST_F(GCMStatsRecorderTest, CheckinTest) { VerifyCheckinFailure("4th call"); } -TEST_F(GCMStatsRecorderTest, ConnectionTest) { +TEST_F(GCMStatsRecorderImplTest, ConnectionTest) { recorder_.RecordConnectionInitiated(kHost); VerifyRecordedConnectionCount(1); VerifyConnectionInitiated("1st call"); @@ -457,7 +457,7 @@ TEST_F(GCMStatsRecorderTest, ConnectionTest) { VerifyConnectionResetSignaled("5th call"); } -TEST_F(GCMStatsRecorderTest, RegistrationTest) { +TEST_F(GCMStatsRecorderImplTest, RegistrationTest) { recorder_.RecordRegistrationSent(kAppId, kSenderIds); VerifyRecordedRegistrationCount(1); VerifyRegistrationSent("1st call"); @@ -484,7 +484,7 @@ TEST_F(GCMStatsRecorderTest, RegistrationTest) { VerifyUnregistrationRetryDelayed("6th call"); } -TEST_F(GCMStatsRecorderTest, RecordReceivingTest) { +TEST_F(GCMStatsRecorderImplTest, RecordReceivingTest) { recorder_.RecordDataMessageReceived(kAppId, kFrom, kByteSize, true, GCMStatsRecorder::DATA_MESSAGE); VerifyRecordedReceivingCount(1); @@ -501,7 +501,7 @@ TEST_F(GCMStatsRecorderTest, RecordReceivingTest) { VerifyDataMessageReceivedNotRegistered("3rd call"); } -TEST_F(GCMStatsRecorderTest, RecordSendingTest) { +TEST_F(GCMStatsRecorderImplTest, RecordSendingTest) { recorder_.RecordDataSentToWire(kAppId, kReceiverId, kMessageId, kQueuedSec); VerifyRecordedSendingCount(1); VerifyDataSentToWire("1st call"); diff --git a/google_apis/gcm/tools/mcs_probe.cc b/google_apis/gcm/tools/mcs_probe.cc index 36ee999..9bac74c 100644 --- a/google_apis/gcm/tools/mcs_probe.cc +++ b/google_apis/gcm/tools/mcs_probe.cc @@ -31,7 +31,7 @@ #include "google_apis/gcm/engine/gcm_store_impl.h" #include "google_apis/gcm/engine/gservices_settings.h" #include "google_apis/gcm/engine/mcs_client.h" -#include "google_apis/gcm/monitoring/gcm_stats_recorder.h" +#include "google_apis/gcm/monitoring/fake_gcm_stats_recorder.h" #include "net/base/host_mapping_rules.h" #include "net/base/net_log_logger.h" #include "net/cert/cert_verifier.h" @@ -243,7 +243,7 @@ class MCSProbe { scoped_refptr<net::HttpNetworkSession> network_session_; scoped_ptr<net::ProxyService> proxy_service_; - GCMStatsRecorder recorder_; + FakeGCMStatsRecorder recorder_; scoped_ptr<GCMStore> gcm_store_; scoped_ptr<MCSClient> mcs_client_; scoped_ptr<CheckinRequest> checkin_request_; |