summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorszym@chromium.org <szym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-01 18:12:27 +0000
committerszym@chromium.org <szym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-01 18:12:27 +0000
commit920d6ec39e2ea69095139d58a27b42302aaccd92 (patch)
tree0a755cc45c2601430adeb1ae9557c90f98d6c2df
parent61fbfef6aa82ad551f96a777870c103058a83823 (diff)
downloadchromium_src-920d6ec39e2ea69095139d58a27b42302aaccd92.zip
chromium_src-920d6ec39e2ea69095139d58a27b42302aaccd92.tar.gz
chromium_src-920d6ec39e2ea69095139d58a27b42302aaccd92.tar.bz2
Merge 179240
> Add NetworkChangeNotifier::ConnectionType to SystemProfile. > > SystemProfile::Network tracks the network environment. The flag > |is_ambiguous| indicates if there was a change to that data since the > time the previous log was closed. > > BUG=169161 > > > Review URL: https://chromiumcodereview.appspot.com/12086008 TBR=szym@chromium.org Review URL: https://codereview.chromium.org/12158006 git-svn-id: svn://svn.chromium.org/chrome/branches/1364/src@180158 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/metrics/metrics_log.cc69
-rw-r--r--chrome/browser/metrics/metrics_log.h6
-rw-r--r--chrome/common/metrics/proto/system_profile.proto20
3 files changed, 93 insertions, 2 deletions
diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc
index da44993..ad3be38 100644
--- a/chrome/browser/metrics/metrics_log.cc
+++ b/chrome/browser/metrics/metrics_log.cc
@@ -42,6 +42,7 @@
#include "content/public/common/content_client.h"
#include "content/public/common/gpu_info.h"
#include "googleurl/src/gurl.h"
+#include "net/base/network_change_notifier.h"
#include "ui/gfx/screen.h"
#include "webkit/plugins/webplugininfo.h"
@@ -265,6 +266,65 @@ void ProductDataToProto(const GoogleUpdateSettings::ProductData& product_data,
} // namespace
+class MetricsLog::NetworkObserver
+ : public net::NetworkChangeNotifier::ConnectionTypeObserver {
+ public:
+ NetworkObserver() : connection_type_is_ambiguous_(false) {
+ net::NetworkChangeNotifier::AddConnectionTypeObserver(this);
+ Reset();
+ }
+ virtual ~NetworkObserver() {
+ net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this);
+ }
+
+ void Reset() {
+ connection_type_is_ambiguous_ = false;
+ connection_type_ = net::NetworkChangeNotifier::GetConnectionType();
+ }
+
+ // ConnectionTypeObserver:
+ virtual void OnConnectionTypeChanged(
+ net::NetworkChangeNotifier::ConnectionType type) OVERRIDE {
+ if (type == net::NetworkChangeNotifier::CONNECTION_NONE)
+ return;
+ if (type != connection_type_ &&
+ connection_type_ != net::NetworkChangeNotifier::CONNECTION_NONE) {
+ connection_type_is_ambiguous_ = true;
+ }
+ connection_type_ = type;
+ }
+
+ bool connection_type_is_ambiguous() const {
+ return connection_type_is_ambiguous_;
+ }
+
+ SystemProfileProto::Network::ConnectionType connection_type() const {
+ switch (connection_type_) {
+ case net::NetworkChangeNotifier::CONNECTION_NONE:
+ case net::NetworkChangeNotifier::CONNECTION_UNKNOWN:
+ return SystemProfileProto::Network::CONNECTION_UNKNOWN;
+ case net::NetworkChangeNotifier::CONNECTION_ETHERNET:
+ return SystemProfileProto::Network::CONNECTION_ETHERNET;
+ case net::NetworkChangeNotifier::CONNECTION_WIFI:
+ return SystemProfileProto::Network::CONNECTION_WIFI;
+ case net::NetworkChangeNotifier::CONNECTION_2G:
+ return SystemProfileProto::Network::CONNECTION_2G;
+ case net::NetworkChangeNotifier::CONNECTION_3G:
+ return SystemProfileProto::Network::CONNECTION_3G;
+ case net::NetworkChangeNotifier::CONNECTION_4G:
+ return SystemProfileProto::Network::CONNECTION_4G;
+ }
+ NOTREACHED();
+ return SystemProfileProto::Network::CONNECTION_UNKNOWN;
+ }
+
+ private:
+ bool connection_type_is_ambiguous_;
+ net::NetworkChangeNotifier::ConnectionType connection_type_;
+
+ DISALLOW_COPY_AND_ASSIGN(NetworkObserver);
+};
+
GoogleUpdateMetrics::GoogleUpdateMetrics() : is_system_install(false) {}
GoogleUpdateMetrics::~GoogleUpdateMetrics() {}
@@ -273,7 +333,8 @@ static base::LazyInstance<std::string>::Leaky
g_version_extension = LAZY_INSTANCE_INITIALIZER;
MetricsLog::MetricsLog(const std::string& client_id, int session_id)
- : MetricsLogBase(client_id, session_id, MetricsLog::GetVersionString()) {}
+ : MetricsLogBase(client_id, session_id, MetricsLog::GetVersionString()),
+ network_observer_(new NetworkObserver()) {}
MetricsLog::~MetricsLog() {}
@@ -773,6 +834,12 @@ void MetricsLog::RecordEnvironmentProto(
hardware->set_dll_base(reinterpret_cast<uint64>(&__ImageBase));
#endif
+ SystemProfileProto::Network* network = system_profile->mutable_network();
+ network->set_connection_type_is_ambiguous(
+ network_observer_->connection_type_is_ambiguous());
+ network->set_connection_type(network_observer_->connection_type());
+ network_observer_->Reset();
+
SystemProfileProto::OS* os = system_profile->mutable_os();
std::string os_name = base::SysInfo::OperatingSystemName();
#if defined(OS_WIN)
diff --git a/chrome/browser/metrics/metrics_log.h b/chrome/browser/metrics/metrics_log.h
index 366fa29..bac872c 100644
--- a/chrome/browser/metrics/metrics_log.h
+++ b/chrome/browser/metrics/metrics_log.h
@@ -140,6 +140,8 @@ class MetricsLog : public MetricsLogBase {
private:
FRIEND_TEST_ALL_PREFIXES(MetricsLogTest, ChromeOSStabilityData);
+ class NetworkObserver;
+
// Writes application stability metrics (as part of the profile log).
// NOTE: Has the side-effect of clearing those counts.
void WriteStabilityElement(
@@ -183,6 +185,10 @@ class MetricsLog : public MetricsLogBase {
// This is a no-op if called on a non-Windows platform.
void WriteGoogleUpdateProto(const GoogleUpdateMetrics& google_update_metrics);
+ // Registers as observer with net::NetworkChangeNotifier and keeps track of
+ // the network environment.
+ scoped_ptr<NetworkObserver> network_observer_;
+
DISALLOW_COPY_AND_ASSIGN(MetricsLog);
};
diff --git a/chrome/common/metrics/proto/system_profile.proto b/chrome/common/metrics/proto/system_profile.proto
index 4e3f8f5..5f3e248 100644
--- a/chrome/common/metrics/proto/system_profile.proto
+++ b/chrome/common/metrics/proto/system_profile.proto
@@ -11,7 +11,7 @@ option optimize_for = LITE_RUNTIME;
package metrics;
-// Next tag: 13
+// Next tag: 14
message SystemProfileProto {
// The time when the client was compiled/linked, in seconds since the epoch.
optional int64 build_timestamp = 1;
@@ -142,6 +142,24 @@ message SystemProfileProto {
}
optional Hardware hardware = 6;
+ // Information about the network connection.
+ message Network {
+ // Set to true if there was a network change during the lifetime of the log.
+ optional bool connection_type_is_ambiguous = 1;
+
+ // See net::NetworkChangeNotifier::ConnectionType.
+ enum ConnectionType {
+ CONNECTION_UNKNOWN = 0;
+ CONNECTION_ETHERNET = 1;
+ CONNECTION_WIFI = 2;
+ CONNECTION_2G = 3;
+ CONNECTION_3G = 4;
+ CONNECTION_4G = 5;
+ }
+ optional ConnectionType connection_type = 2;
+ }
+ optional Network network = 13;
+
// Information on the Google Update install that is managing this client.
message GoogleUpdate {
// Whether the Google Update install is system-level or user-level.