summaryrefslogtreecommitdiffstats
path: root/net/ftp/ftp_network_transaction.cc
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-17 17:00:45 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-17 17:00:45 +0000
commit8b6d757916ca414520e3e1746669a818e43ff249 (patch)
tree2e42bcdfa5d86ce3091203c7fe0a6b2f37332d8f /net/ftp/ftp_network_transaction.cc
parent82f32d26c456bea4bf23eb56eff48073dc487feb (diff)
downloadchromium_src-8b6d757916ca414520e3e1746669a818e43ff249.zip
chromium_src-8b6d757916ca414520e3e1746669a818e43ff249.tar.gz
chromium_src-8b6d757916ca414520e3e1746669a818e43ff249.tar.bz2
Add histograms for data connection error types.
The plan is to see how many of them are possibly caused by the passive FTP mode being blocked in the network. TEST=none BUG=3073 Review URL: http://codereview.chromium.org/389023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32175 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/ftp/ftp_network_transaction.cc')
-rw-r--r--net/ftp/ftp_network_transaction.cc78
1 files changed, 78 insertions, 0 deletions
diff --git a/net/ftp/ftp_network_transaction.cc b/net/ftp/ftp_network_transaction.cc
index 1898310..bfb526e 100644
--- a/net/ftp/ftp_network_transaction.cc
+++ b/net/ftp/ftp_network_transaction.cc
@@ -5,6 +5,7 @@
#include "net/ftp/ftp_network_transaction.h"
#include "base/compiler_specific.h"
+#include "base/histogram.h"
#include "base/string_util.h"
#include "net/base/connection_type_histograms.h"
#include "net/base/escape.h"
@@ -1066,6 +1067,7 @@ int FtpNetworkTransaction::DoDataConnect() {
}
int FtpNetworkTransaction::DoDataConnectComplete(int result) {
+ RecordDataConnectionError(result);
if (retr_failed_) {
next_state_ = STATE_CTRL_WRITE_CWD;
} else {
@@ -1098,4 +1100,80 @@ int FtpNetworkTransaction::DoDataReadComplete(int result) {
return result;
}
+// We're using a histogram as a group of counters. We're only interested in
+// the values of the counters. Ignore the shape, average, and standard
+// deviation of the histograms because they are meaningless.
+//
+// We use two groups of counters. In the first group (counter1), each counter
+// is a boolean (0 or 1) that indicates whether the user has seen an error
+// of that type during that session. In the second group (counter2), each
+// counter is the number of errors of that type the user has seen during
+// that session.
+//
+// Each histogram has an unused bucket at the end to allow seamless future
+// expansion.
+void FtpNetworkTransaction::RecordDataConnectionError(int result) {
+ // Gather data for http://crbug.com/3073. See how many users have trouble
+ // establishing FTP data connection in passive FTP mode.
+ enum {
+ // Data connection successful.
+ NET_ERROR_OK = 0,
+
+ // Local firewall blocked the connection.
+ NET_ERROR_ACCESS_DENIED = 1,
+
+ // Connection timed out.
+ NET_ERROR_TIMED_OUT = 2,
+
+ // Connection has been estabilished, but then got broken (either reset
+ // or aborted).
+ NET_ERROR_CONNECTION_BROKEN = 3,
+
+ // Connection has been refused.
+ NET_ERROR_CONNECTION_REFUSED = 4,
+
+ // Other kind of error.
+ NET_ERROR_OTHER = 20,
+
+ NUM_OF_NET_ERROR_TYPES
+ } type;
+ switch (result) {
+ case OK:
+ type = NET_ERROR_OK;
+ break;
+ case ERR_ACCESS_DENIED:
+ type = NET_ERROR_ACCESS_DENIED;
+ break;
+ case ERR_TIMED_OUT:
+ type = NET_ERROR_TIMED_OUT;
+ break;
+ case ERR_CONNECTION_RESET:
+ case ERR_CONNECTION_ABORTED:
+ type = NET_ERROR_CONNECTION_BROKEN;
+ break;
+ case ERR_CONNECTION_REFUSED:
+ type = NET_ERROR_CONNECTION_REFUSED;
+ break;
+ default:
+ type = NET_ERROR_OTHER;
+ break;
+ };
+ static bool had_error_type[NUM_OF_NET_ERROR_TYPES];
+ static LinearHistogram error_flagged("Net.FtpDataConnectionErrorHappened",
+ 1, NUM_OF_NET_ERROR_TYPES,
+ NUM_OF_NET_ERROR_TYPES + 1);
+ static LinearHistogram error_counter("Net.FtpDataConnectionErrorCount",
+ 1, NUM_OF_NET_ERROR_TYPES,
+ NUM_OF_NET_ERROR_TYPES + 1);
+
+ DCHECK(type >= 0 && type < NUM_OF_NET_ERROR_TYPES);
+ if (!had_error_type[type]) {
+ had_error_type[type] = true;
+ error_flagged.SetFlags(kUmaTargetedHistogramFlag);
+ error_flagged.Add(type);
+ }
+ error_counter.SetFlags(kUmaTargetedHistogramFlag);
+ error_counter.Add(type);
+}
+
} // namespace net