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

Unified Diff: net/base/lookup_string_in_fixed_set.h

Issue 1412343008: Factor out the string lookup code from registry_controlled_domains (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 1 month 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 | net/base/lookup_string_in_fixed_set.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/lookup_string_in_fixed_set.h
diff --git a/net/base/socket_performance_watcher.h b/net/base/lookup_string_in_fixed_set.h
similarity index 14%
copy from net/base/socket_performance_watcher.h
copy to net/base/lookup_string_in_fixed_set.h
index e0e76327ce63541e8d0dc2ba23215d34f953df41..793a782ed148d5c3641709cec9bc204c1eee23f6 100644
--- a/net/base/socket_performance_watcher.h
+++ b/net/base/lookup_string_in_fixed_set.h
@@ -2,48 +2,39 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef NET_BASE_SOCKET_PERFORMANCE_WATCHER_H_
-#define NET_BASE_SOCKET_PERFORMANCE_WATCHER_H_
+#ifndef NET_BASE_LOOKUP_STRING_IN_FIXED_SET_H_
+#define NET_BASE_LOOKUP_STRING_IN_FIXED_SET_H_
-#include "base/macros.h"
-#include "net/base/net_export.h"
-#include "net/base/socket_performance_watcher_factory.h"
+#include <stddef.h>
-namespace base {
-class TimeDelta;
-} // namespace base
+#include "net/base/net_export.h"
namespace net {
-// SocketPerformanceWatcher is the base class for recording and aggregating
-// socket statistics.
-class NET_EXPORT_PRIVATE SocketPerformanceWatcher {
- public:
- // |socket_performance_watcher_factory| is the factory that constructed
- // |this| watcher.
- SocketPerformanceWatcher(
- const SocketPerformanceWatcherFactory::Protocol protocol,
- SocketPerformanceWatcherFactory* socket_performance_watcher_factory);
-
- virtual ~SocketPerformanceWatcher();
-
- // Called when updated transport layer RTT information is available. This
- // must be the transport layer RTT from this device to the remote transport
- // layer endpoint. This method is called immediately after the observation is
- // made, hence no timestamp.
- void OnUpdatedRTTAvailable(const base::TimeDelta& rtt) const;
-
- private:
- // Transport layer protocol used by the socket that |this| is watching.
- const SocketPerformanceWatcherFactory::Protocol protocol_;
-
- // |socket_performance_watcher_factory_| is the factory that created
- // |this| watcher.
- SocketPerformanceWatcherFactory* socket_performance_watcher_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(SocketPerformanceWatcher);
+enum {
+ kDafsaNotFound = -1, // key is not in set
+ kDafsaFound = 0, // key is in set
+ // The following return values are used by the implementation of
+ // GetDomainAndRegistry() and are probably not generally useful.
+ kDafsaExceptionRule = 1, // key excluded from set via exception
+ kDafsaWildcardRule = 2, // key matched a wildcard rule
+ kDafsaPrivateRule = 4, // key matched a private rule
};
+// Looks up the string |key| with length |key_length| in a fixed set of
+// strings. The set of strings must be known at compile time. It is converted to
+// a graph structure named a DAFSA (Deterministic Acyclic Finite State
+// Automaton) by the script make_dafsa.py during compilation. This permits
+// efficient (in time and space) lookup. The graph generated by make_dafsa.py
+// takes the form of a constant byte array which should be supplied via the
+// |graph| and |length| parameters. The return value is kDafsaNotFound,
+// kDafsaFound, or a bitmap consisting of one or more of kDafsaExceptionRule,
+// kDafsaWildcardRule and kDafsaPrivateRule ORed together.
+NET_EXPORT int LookupStringInFixedSet(const unsigned char* graph,
+ size_t length,
+ const char* key,
+ size_t key_length);
+
} // namespace net
-#endif // NET_BASE_SOCKET_PERFORMANCE_WATCHER_H_
+#endif // NET_BASE_LOOKUP_STRING_IN_FIXED_SET_H_
« no previous file with comments | « no previous file | net/base/lookup_string_in_fixed_set.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698