| Index: google_apis/gcm/gcm_stats_recorder.h
|
| diff --git a/google_apis/gcm/gcm_stats_recorder.h b/google_apis/gcm/gcm_stats_recorder.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..0357254a48c260992839c9003f781dd4ec635273
|
| --- /dev/null
|
| +++ b/google_apis/gcm/gcm_stats_recorder.h
|
| @@ -0,0 +1,99 @@
|
| +// 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_H_
|
| +#define GOOGLE_APIS_GCM_GCM_STATS_RECORDER_H_
|
| +
|
| +#include <deque>
|
| +#include <string>
|
| +#include <vector>
|
| +
|
| +#include "base/compiler_specific.h"
|
| +#include "base/time/time.h"
|
| +#include "google_apis/gcm/base/gcm_export.h"
|
| +#include "google_apis/gcm/engine/mcs_client.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 GCMStatsRecorder {
|
| + public:
|
| + // Contains data that are common to all activity kinds below.
|
| + struct GCM_EXPORT Activity {
|
| + Activity();
|
| + virtual ~Activity();
|
| +
|
| + base::Time time;
|
| + std::string event; // A short description of the event.
|
| + std::string details; // Any additional detail about the event.
|
| + };
|
| +
|
| + // Contains relevant data of a send-message step.
|
| + struct GCM_EXPORT SendingActivity : Activity {
|
| + SendingActivity();
|
| + virtual ~SendingActivity() OVERRIDE;
|
| +
|
| + std::string app_id;
|
| + std::string receiver_id;
|
| + std::string message_id;
|
| + };
|
| +
|
| + 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);
|
| +
|
| + // Clear all recorded activities.
|
| + void Clear();
|
| +
|
| + // Records when the outgoing message is sent to wire.
|
| + void RecordSentToWire(const std::string& app_id,
|
| + const std::string& receiver_id,
|
| + const std::string& message_id,
|
| + int queued);
|
| + // Records when the MCS client sends 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);
|
| + // Records when a 'send error' message is received.
|
| + void RecordIncomingSendError(const std::string& app_id,
|
| + const std::string& receiver_id,
|
| + const std::string& message_id,
|
| + int byte_size,
|
| + int ttl);
|
| +
|
| + const std::deque<SendingActivity>& sending_activities() const {
|
| + return sending_activities_;
|
| + }
|
| +
|
| + protected:
|
| + 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_;
|
| +
|
| + std::deque<SendingActivity> sending_activities_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(GCMStatsRecorder);
|
| +};
|
| +
|
| +} // namespace gcm
|
| +
|
| +#endif // GOOGLE_APIS_GCM_GCM_STATS_RECORDER_H_
|
|
|