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

Unified Diff: src/platform/metrics/metrics_library.h

Issue 2079007: Add metrics library tests. Some metrics daemon API cleanup. (Closed) Base URL: ssh://git@chromiumos-git/chromeos
Patch Set: A bit more cleanup. Created 10 years, 7 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
« no previous file with comments | « src/platform/metrics/metrics_daemon_test.cc ('k') | src/platform/metrics/metrics_library.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_ */
« no previous file with comments | « src/platform/metrics/metrics_daemon_test.cc ('k') | src/platform/metrics/metrics_library.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698