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

Unified Diff: components/copresence/timed_map.h

Issue 813553002: Adding support for pre-sent messages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@state
Patch Set: Created 5 years, 11 months 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 | « components/copresence/rpc/rpc_handler_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/copresence/timed_map.h
diff --git a/components/copresence/timed_map.h b/components/copresence/timed_map.h
index 98e1517e73e92ac0c5a4bdff440386809637144d..bcd7149ba08b51d82d48b77d8bc54221fe60ffde 100644
--- a/components/copresence/timed_map.h
+++ b/components/copresence/timed_map.h
@@ -21,6 +21,7 @@ namespace copresence {
// TimedMap is a map with the added functionality of clearing any
// key/value pair after its specified lifetime is over.
+// TODO(ckehoe): Why is this interface so different from std::map?
template <typename KeyType, typename ValueType>
class TimedMap {
public:
@@ -52,6 +53,17 @@ class TimedMap {
return elt == map_.end() ? kEmptyValue : elt->second;
}
+ ValueType* GetMutableValue(const KeyType& key) {
+ ClearExpiredTokens();
+ auto elt = map_.find(key);
+ return elt == map_.end() ? nullptr : &(elt->second);
+ }
+
+ // TODO(ckehoe): Add a unit test for this.
+ size_t Erase(const KeyType& key) {
+ return map_.erase(key);
+ }
+
void set_clock_for_testing(scoped_ptr<base::TickClock> clock) {
clock_ = clock.Pass();
}
« no previous file with comments | « components/copresence/rpc/rpc_handler_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698