summaryrefslogtreecommitdiffstats
path: root/net
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
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')
-rw-r--r--net/ftp/ftp_server_type_histograms.cc43
-rw-r--r--net/ftp/ftp_server_type_histograms.h38
-rw-r--r--net/net.gyp2
-rw-r--r--net/url_request/url_request_new_ftp_job.cc37
-rw-r--r--net/url_request/url_request_new_ftp_job.h6
5 files changed, 125 insertions, 1 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_
diff --git a/net/net.gyp b/net/net.gyp
index 0d6d598..642489c 100644
--- a/net/net.gyp
+++ b/net/net.gyp
@@ -206,6 +206,8 @@
'ftp/ftp_network_transaction.h',
'ftp/ftp_request_info.h',
'ftp/ftp_response_info.h',
+ 'ftp/ftp_server_type_histograms.cc',
+ 'ftp/ftp_server_type_histograms.h',
'ftp/ftp_transaction.h',
'ftp/ftp_transaction_factory.h',
'http/des.cc',
diff --git a/net/url_request/url_request_new_ftp_job.cc b/net/url_request/url_request_new_ftp_job.cc
index 16865a1..251602c 100644
--- a/net/url_request/url_request_new_ftp_job.cc
+++ b/net/url_request/url_request_new_ftp_job.cc
@@ -14,6 +14,7 @@
#include "net/base/net_util.h"
#include "net/ftp/ftp_directory_parser.h"
#include "net/ftp/ftp_response_info.h"
+#include "net/ftp/ftp_server_type_histograms.h"
#include "net/ftp/ftp_transaction_factory.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_context.h"
@@ -243,8 +244,9 @@ int URLRequestNewFtpJob::ProcessFtpDir(net::IOBuffer *buf,
int64 file_size;
std::istringstream iss(std::string(buf->data(), bytes_read));
+ struct net::ListState state;
+ memset(&state, 0, sizeof(state));
while (getline(iss, line)) {
- struct net::ListState state;
struct net::ListResult result;
std::replace(line.begin(), line.end(), '\r', '\0');
net::LineType line_type = ParseFTPLine(line.c_str(), &state, &result);
@@ -270,6 +272,7 @@ int URLRequestNewFtpJob::ProcessFtpDir(net::IOBuffer *buf,
break;
}
}
+ LogFtpServerType(state);
directory_html_.append(file_entry);
size_t bytes_to_copy = std::min(static_cast<size_t>(buf_size),
directory_html_.length());
@@ -280,6 +283,38 @@ int URLRequestNewFtpJob::ProcessFtpDir(net::IOBuffer *buf,
return bytes_to_copy;
}
+void URLRequestNewFtpJob::LogFtpServerType(const net::ListState& list_state) {
+ switch (list_state.lstyle) {
+ case 'E':
+ net::UpdateFtpServerTypeHistograms(net::SERVER_EPLF);
+ break;
+ case 'V':
+ net::UpdateFtpServerTypeHistograms(net::SERVER_VMS);
+ break;
+ case 'C':
+ net::UpdateFtpServerTypeHistograms(net::SERVER_CMS);
+ break;
+ case 'W':
+ net::UpdateFtpServerTypeHistograms(net::SERVER_DOS);
+ break;
+ case 'O':
+ net::UpdateFtpServerTypeHistograms(net::SERVER_OS2);
+ break;
+ case 'U':
+ net::UpdateFtpServerTypeHistograms(net::SERVER_LSL);
+ break;
+ case 'w':
+ net::UpdateFtpServerTypeHistograms(net::SERVER_W16);
+ break;
+ case 'D':
+ net::UpdateFtpServerTypeHistograms(net::SERVER_DLS);
+ break;
+ default:
+ net::UpdateFtpServerTypeHistograms(net::SERVER_UNKNOWN);
+ break;
+ }
+}
+
void URLRequestNewFtpJob::OnStartCompleted(int result) {
// If the request was destroyed, then there is no more work to do.
if (!request_ || !request_->delegate())
diff --git a/net/url_request/url_request_new_ftp_job.h b/net/url_request/url_request_new_ftp_job.h
index d7a9b25..2a66098 100644
--- a/net/url_request/url_request_new_ftp_job.h
+++ b/net/url_request/url_request_new_ftp_job.h
@@ -15,6 +15,10 @@
class URLRequestContext;
+namespace net {
+struct ListState;
+}
+
// A URLRequestJob subclass that is built on top of FtpTransaction. It
// provides an implementation for FTP.
class URLRequestNewFtpJob : public URLRequestJob {
@@ -52,6 +56,8 @@ class URLRequestNewFtpJob : public URLRequestJob {
int ProcessFtpDir(net::IOBuffer *buf, int buf_size, int bytes_read);
+ void LogFtpServerType(const net::ListState& list_state);
+
net::FtpRequestInfo request_info_;
scoped_ptr<net::FtpTransaction> transaction_;
const net::FtpResponseInfo* response_info_;