Chromium Code Reviews| Index: components/copresence/timed_map.h |
| diff --git a/components/copresence/timed_map.h b/components/copresence/timed_map.h |
| index 909775201ce7c5e4619cda89ab3dd02824efa8fe..e89afa1620d9205341ba3787d2261b2389d730bd 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> |
| @@ -31,7 +31,9 @@ class TimedMap { |
| timer_.Start(FROM_HERE, lifetime_, this, &TimedMap::ClearExpiredTokens); |
| } |
| - ~TimedMap() {} |
| + ~TimedMap() { |
| + delete clock_; |
|
rkc
2014/08/09 06:41:42
No reason for this clock to not be a scoped_ptr. L
Charlie
2014/08/09 07:10:40
Done.
|
| + } |
| void Add(const KeyType& key, const ValueType& value) { |
| map_[key] = value; |
| @@ -51,7 +53,12 @@ class TimedMap { |
| return elt == map_.end() ? kEmptyValue : elt->second; |
| } |
| - void set_clock_for_testing(base::TickClock* clock) { clock_ = clock; } |
| + // TimedMap takes ownership of this clock. |
| + void set_clock_for_testing(base::TickClock* clock) { |
|
rkc
2014/08/09 06:41:41
Change the clock to a scoped_ptr, pass in a scoped
Charlie
2014/08/09 06:48:23
That's what I wrote first. But then how do you cal
rkc
2014/08/09 06:53:57
Retain a bare pointer in the test. It is the clean
Charlie
2014/08/09 07:10:40
Done.
|
| + DCHECK(clock); |
| + delete clock_; |
| + clock_ = clock; |
| + } |
| private: |
| void ClearExpiredTokens() { |
| @@ -94,4 +101,4 @@ class TimedMap { |
| } // namespace copresence |
| -#endif // COMPONENTS_COPRESENCE_TIMED_MAP_ |
| +#endif // COMPONENTS_COPRESENCE_TIMED_MAP_H_ |