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

Unified Diff: chrome/browser/metrics/metrics_log.h

Issue 2744003: Preparation CL for adding crash metrics UMA counters to ChromeFrame. Basicall... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 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 | « no previous file | chrome/browser/metrics/metrics_log.cc » ('j') | chrome/browser/metrics/metrics_log.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/metrics_log.h
===================================================================
--- chrome/browser/metrics/metrics_log.h (revision 49302)
+++ chrome/browser/metrics/metrics_log.h (working copy)
@@ -8,14 +8,8 @@
#ifndef CHROME_BROWSER_METRICS_METRICS_LOG_H_
#define CHROME_BROWSER_METRICS_METRICS_LOG_H_
-#include <libxml/xmlwriter.h>
-
-#include <string>
-#include <vector>
-
#include "base/basictypes.h"
-#include "base/histogram.h"
-#include "base/time.h"
+#include "chrome/common/metrics_helpers.h"
#include "chrome/common/page_transition_types.h"
#include "webkit/glue/plugins/webplugininfo.h"
@@ -24,7 +18,7 @@
class GURL;
class PrefService;
-class MetricsLog {
+class MetricsLog : public MetricsLogBase {
public:
// Creates a new metrics log
// client_id is the identifier for this profile on this installation
@@ -34,29 +28,6 @@
static void RegisterPrefs(PrefService* prefs);
- // Records a user-initiated action.
- void RecordUserAction(const char* key);
-
- enum WindowEventType {
- WINDOW_CREATE = 0,
- WINDOW_OPEN,
- WINDOW_CLOSE,
- WINDOW_DESTROY
- };
-
- void RecordWindowEvent(WindowEventType type, int window_id, int parent_id);
-
- // Records a page load.
- // window_id - the index of the tab in which the load took place
- // url - which URL was loaded
- // origin - what kind of action initiated the load
- // load_time - how long it took to load the page
- void RecordLoadEvent(int window_id,
- const GURL& url,
- PageTransition::Type origin,
- int session_index,
- base::TimeDelta load_time);
-
// Records the current operating environment. Takes the list of installed
// plugins as a parameter because that can't be obtained synchronously
// from the UI thread.
@@ -70,113 +41,33 @@
// user uses the Omnibox to open a URL.
void RecordOmniboxOpenedURL(const AutocompleteLog& log);
- // Record any changes in a given histogram for transmission.
- void RecordHistogramDelta(const Histogram& histogram,
- const Histogram::SampleSet& snapshot);
-
// Record recent delta for critical stability metrics. We can't wait for a
// restart to gather these, as that delay biases our observation away from
// users that run happily for a looooong time. We send increments with each
// uma log upload, just as we send histogram data.
void RecordIncrementalStabilityElements();
- // Stop writing to this record and generate the encoded representation.
- // None of the Record* methods can be called after this is called.
- void CloseLog();
-
- // These methods allow retrieval of the encoded representation of the
- // record. They can only be called after CloseLog() has been called.
- // GetEncodedLog returns false if buffer_size is less than
- // GetEncodedLogSize();
- int GetEncodedLogSize();
- bool GetEncodedLog(char* buffer, int buffer_size);
-
- // Returns the amount of time in seconds that this log has been in use.
- int GetElapsedSeconds();
-
- int num_events() { return num_events_; }
void set_hardware_class(const std::string& hardware_class) {
hardware_class_ = hardware_class;
}
- // Creates an MD5 hash of the given value, and returns hash as a byte
- // buffer encoded as a std::string.
- static std::string CreateHash(const std::string& value);
-
- // Return a base64-encoded MD5 hash of the given string.
- static std::string CreateBase64Hash(const std::string& string);
-
- // Get the current version of the application as a string.
- static std::string GetVersionString();
-
- // Get the GMT buildtime for the current binary, expressed in seconds since
- // January 1, 1970 GMT.
- // The value is used to identify when a new build is run, so that previous
- // reliability stats, from other builds, can be abandoned.
- static int64 GetBuildTime();
-
// Get the amount of uptime in seconds since this function was last called.
// This updates the cumulative uptime metric for uninstall as a side effect.
static int64 GetIncrementalUptime(PrefService* pref);
- // Use |extension| in all uploaded appversions in addition to the standard
- // version string.
- static void set_version_extension(const std::string& extension) {
- version_extension_ = extension;
+ // Get the current version of the application as a string.
+ static std::string GetVersionString();
+
+ virtual MetricsLog* AsMetricsLog() {
+ return this;
}
- protected:
- // Returns a string containing the current time.
- // Virtual so that it can be overridden for testing.
- virtual std::string GetCurrentTimeString();
-
private:
- // Helper class that invokes StartElement from constructor, and EndElement
- // from destructor.
- //
- // Use the macro OPEN_ELEMENT_FOR_SCOPE to help avoid usage problems.
- class ScopedElement {
- public:
- ScopedElement(MetricsLog* log, const std::string& name) : log_(log) {
- DCHECK(log);
- log->StartElement(name.c_str());
- }
-
- ScopedElement(MetricsLog* log, const char* name) : log_(log) {
- DCHECK(log);
- log->StartElement(name);
- }
-
- ~ScopedElement() {
- log_->EndElement();
- }
-
- private:
- MetricsLog* log_;
- };
- friend class ScopedElement;
-
- static const char* WindowEventTypeToString(WindowEventType type);
-
- // Frees the resources allocated by the XML document writer: the
- // main writer object as well as the XML tree structure, if
- // applicable.
- void FreeDocWriter();
-
- // Convenience versions of xmlWriter functions
- void StartElement(const char* name);
- void EndElement();
- void WriteAttribute(const std::string& name, const std::string& value);
- void WriteIntAttribute(const std::string& name, int value);
- void WriteInt64Attribute(const std::string& name, int64 value);
-
- // Write the attributes that are common to every metrics event type.
- void WriteCommonEventAttributes();
-
// Returns the date at which the current metrics client ID was created as
// a string containing milliseconds since the epoch, or "0" if none was found.
std::string GetInstallDate() const;
+
// Writes application stability metrics (as part of the profile log).
// NOTE: Has the side-effect of clearing those counts.
void WriteStabilityElement();
@@ -208,26 +99,8 @@
void WriteProfileMetrics(const std::wstring& key,
const DictionaryValue& profile_metrics);
- // An extension that is appended to the appversion in each log.
- static std::string version_extension_;
-
- base::Time start_time_;
- base::Time end_time_;
-
- std::string client_id_;
- std::string session_id_;
std::string hardware_class_;
- // locked_ is true when record has been packed up for sending, and should
- // no longer be written to. It is only used for sanity checking and is
- // not a real lock.
- bool locked_;
-
- xmlDocPtr doc_;
- xmlBufferPtr buffer_;
- xmlTextWriterPtr writer_;
- int num_events_; // the number of events recorded in this log
-
DISALLOW_COPY_AND_ASSIGN(MetricsLog);
};
« no previous file with comments | « no previous file | chrome/browser/metrics/metrics_log.cc » ('j') | chrome/browser/metrics/metrics_log.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698