Index: src/platform/metrics/metrics_library.h |
diff --git a/src/platform/metrics/metrics_library.h b/src/platform/metrics/metrics_library.h |
index 2a6412cb4cc0c8aca2bc5916230aede75b0730aa..8ae3f5b8c912f5a9c66e2dd775a2375195fdcf4b 100644 |
--- a/src/platform/metrics/metrics_library.h |
+++ b/src/platform/metrics/metrics_library.h |
@@ -5,9 +5,10 @@ |
#ifndef METRICS_LIBRARY_H_ |
#define METRICS_LIBRARY_H_ |
+#include <sys/types.h> |
#include <string> |
-// TODO(sosa@chromium.org): Add testing for send methods |
+#include <gtest/gtest_prod.h> // for FRIEND_TEST |
class MetricsLibraryInterface { |
public: |
@@ -21,6 +22,8 @@ class MetricsLibraryInterface { |
// Library used to send metrics to both Autotest and Chrome/UMA. |
class MetricsLibrary : public MetricsLibraryInterface { |
public: |
+ MetricsLibrary(); |
+ |
// Initializes the library. |
void Init(); |
@@ -51,6 +54,30 @@ class MetricsLibrary : public MetricsLibraryInterface { |
// Sends to Autotest and returns true on success. |
static bool SendToAutotest(const std::string& name, int value); |
+ |
+ private: |
+ friend class MetricsLibraryTest; |
+ FRIEND_TEST(MetricsLibraryTest, FormatChromeMessage); |
+ FRIEND_TEST(MetricsLibraryTest, FormatChromeMessageTooLong); |
+ FRIEND_TEST(MetricsLibraryTest, SendMessageToChrome); |
+ FRIEND_TEST(MetricsLibraryTest, SendMessageToChromeUMAEventsBadFileLocation); |
+ |
+ // Sends message of size |length| to Chrome for transport to UMA and |
+ // returns true on success. |
+ bool SendMessageToChrome(int32_t length, const char* message); |
+ |
+ // Formats a name/value message for Chrome in |buffer| and returns the |
+ // length of the message or a negative value on error. |
+ // |
+ // Message format is: | LENGTH(binary) | NAME | \0 | VALUE | \0 | |
+ // |
+ // The arbitrary |format| argument covers the non-LENGTH portion of the |
+ // message. The caller is responsible to store the \0 character |
+ // between NAME and VALUE (e.g. "%s%c%d", name, '\0', value). |
+ int32_t FormatChromeMessage(int32_t buffer_size, char* buffer, |
+ const char *format, ...); |
+ |
+ const char* uma_events_file_; |
}; |
#endif /* METRICS_LIBRARY_H_ */ |