summaryrefslogtreecommitdiffstats
path: root/net/ftp
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-28 22:40:55 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-28 22:40:55 +0000
commit139dd55c937dbad1224571ddca0d13d9e723af0f (patch)
tree5b3057870d7cddfca0f22a24bb8a706056ee3787 /net/ftp
parentc8451d1a68c5897298b1327f100dae13431bc4fa (diff)
downloadchromium_src-139dd55c937dbad1224571ddca0d13d9e723af0f.zip
chromium_src-139dd55c937dbad1224571ddca0d13d9e723af0f.tar.gz
chromium_src-139dd55c937dbad1224571ddca0d13d9e723af0f.tar.bz2
Add histograms for FTP server types encountered by users.
This should help with decision which FTP server types we can safely stop supporting. TEST=none BUG=none Review URL: http://codereview.chromium.org/176020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24824 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/ftp')
-rw-r--r--net/ftp/ftp_server_type_histograms.cc43
-rw-r--r--net/ftp/ftp_server_type_histograms.h38
2 files changed, 81 insertions, 0 deletions
diff --git a/net/ftp/ftp_server_type_histograms.cc b/net/ftp/ftp_server_type_histograms.cc
new file mode 100644
index 0000000..3f419a8
--- /dev/null
+++ b/net/ftp/ftp_server_type_histograms.cc
@@ -0,0 +1,43 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/ftp/ftp_server_type_histograms.h"
+
+#include "base/histogram.h"
+
+namespace net {
+
+// 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 FTP server
+// of that type during that session. In the second group (counter2), each
+// counter is the number of transactions with FTP server of that type the user
+// has made during that session.
+//
+// Each histogram has an unused bucket at the end to allow seamless future
+// expansion.
+void UpdateFtpServerTypeHistograms(FtpServerType type) {
+ static bool had_server_type[NUM_OF_SERVER_TYPES];
+ static LinearHistogram counter1("Net.HadFtpServerType",
+ 1, NUM_OF_SERVER_TYPES,
+ NUM_OF_SERVER_TYPES + 1);
+ static LinearHistogram counter2("Net.FtpServerTypeCount",
+ 1, NUM_OF_SERVER_TYPES,
+ NUM_OF_SERVER_TYPES + 1);
+
+ if (type >= 0 && type < NUM_OF_SERVER_TYPES) {
+ if (!had_server_type[type]) {
+ had_server_type[type] = true;
+ counter1.SetFlags(kUmaTargetedHistogramFlag);
+ counter1.Add(type);
+ }
+ }
+ counter2.SetFlags(kUmaTargetedHistogramFlag);
+ counter2.Add(type);
+}
+
+} // namespace net
diff --git a/net/ftp/ftp_server_type_histograms.h b/net/ftp/ftp_server_type_histograms.h
new file mode 100644
index 0000000..08ca424
--- /dev/null
+++ b/net/ftp/ftp_server_type_histograms.h
@@ -0,0 +1,38 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_FTP_FTP_SERVER_TYPE_HISTOGRAMS_H_
+#define NET_FTP_FTP_SERVER_TYPE_HISTOGRAMS_H_
+
+// The UpdateFtpServerTypeHistograms function collects statistics related
+// to the types of FTP servers that our users are encountering. The
+// information will help us decide for what servers we can safely drop support.
+// The parsing code for each type of server is very complex, which poses a
+// security risk. In fact, in current shape it's a disaster waiting to happen.
+
+namespace net {
+
+enum FtpServerType {
+ // Record cases in which we couldn't parse the server's response. That means
+ // a server type we don't recognize, a security attack (when what we're
+ // connecting to isn't an FTP server), or a broken server.
+ SERVER_UNKNOWN = 0,
+
+ SERVER_LSL = 1, // Server using /bin/ls -l and variants.
+ SERVER_DLS = 2, // Server using /bin/dls.
+ SERVER_EPLF = 3, // Server using EPLF format.
+ SERVER_DOS = 4, // WinNT server configured for old style listing.
+ SERVER_VMS = 5, // VMS (including variants).
+ SERVER_CMS = 6, // IBM VM/CMS, VM/ESA, z/VM formats.
+ SERVER_OS2 = 7, // OS/2 FTP Server.
+ SERVER_W16 = 8, // win16 hosts: SuperTCP or NetManage Chameleon.
+
+ NUM_OF_SERVER_TYPES
+};
+
+void UpdateFtpServerTypeHistograms(FtpServerType type);
+
+} // namespace net
+
+#endif // NET_FTP_FTP_SERVER_TYPE_HISTOGRAMS_H_