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

Unified Diff: components/copresence/timed_map.h

Issue 453203002: Fixing memory leak in TimedMap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Disabling broken test Created 6 years, 4 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
Index: components/copresence/timed_map.h
diff --git a/components/copresence/timed_map.h b/components/copresence/timed_map.h
index 909775201ce7c5e4619cda89ab3dd02824efa8fe..4367e59b65e658066785b9327f9ff371f07da585 100644
--- a/components/copresence/timed_map.h
+++ b/components/copresence/timed_map.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_COPRESENCE_TIMED_MAP_
-#define COMPONENTS_COPRESENCE_TIMED_MAP_
+#ifndef COMPONENTS_COPRESENCE_TIMED_MAP_H_
+#define COMPONENTS_COPRESENCE_TIMED_MAP_H_
#include <map>
#include <queue>
@@ -11,6 +11,7 @@
#include <vector>
#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
#include "base/time/default_tick_clock.h"
#include "base/time/tick_clock.h"
#include "base/time/time.h"
@@ -51,7 +52,9 @@ class TimedMap {
return elt == map_.end() ? kEmptyValue : elt->second;
}
- void set_clock_for_testing(base::TickClock* clock) { clock_ = clock; }
+ void set_clock_for_testing(scoped_ptr<base::TickClock> clock) {
+ clock_ = clock.Pass();
+ }
private:
void ClearExpiredTokens() {
@@ -80,7 +83,7 @@ class TimedMap {
const ValueType kEmptyValue;
- base::TickClock* clock_;
+ scoped_ptr<base::TickClock> clock_;
base::RepeatingTimer<TimedMap> timer_;
const base::TimeDelta lifetime_;
const size_t max_elements_;
@@ -94,4 +97,4 @@ class TimedMap {
} // namespace copresence
-#endif // COMPONENTS_COPRESENCE_TIMED_MAP_
+#endif // COMPONENTS_COPRESENCE_TIMED_MAP_H_

Powered by Google App Engine
This is Rietveld 408576698