OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_PRECACHE_CORE_FETCHER_POOL_H_ | 5 #ifndef COMPONENTS_PRECACHE_CORE_FETCHER_POOL_H_ |
6 #define COMPONENTS_PRECACHE_CORE_FETCHER_POOL_H_ | 6 #define COMPONENTS_PRECACHE_CORE_FETCHER_POOL_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <unordered_map> | 9 #include <unordered_map> |
10 | 10 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 // Deletes all the elements in the pool. | 61 // Deletes all the elements in the pool. |
62 void DeleteAll() { elements_.clear(); } | 62 void DeleteAll() { elements_.clear(); } |
63 | 63 |
64 // Returns true iff the pool is empty. | 64 // Returns true iff the pool is empty. |
65 bool IsEmpty() const { return elements_.empty(); } | 65 bool IsEmpty() const { return elements_.empty(); } |
66 | 66 |
67 // Returns true iff the pool can accept a new element. | 67 // Returns true iff the pool can accept a new element. |
68 bool IsAvailable() const { return max_size_ > elements_.size(); } | 68 bool IsAvailable() const { return max_size_ > elements_.size(); } |
69 | 69 |
| 70 const std::unordered_map<const T*, std::unique_ptr<T>>& elements() const { |
| 71 return elements_; |
| 72 } |
| 73 |
70 private: | 74 private: |
71 const size_t max_size_; | 75 const size_t max_size_; |
72 std::unordered_map<const T*, std::unique_ptr<T>> elements_; | 76 std::unordered_map<const T*, std::unique_ptr<T>> elements_; |
73 | 77 |
74 DISALLOW_COPY_AND_ASSIGN(FetcherPool); | 78 DISALLOW_COPY_AND_ASSIGN(FetcherPool); |
75 }; | 79 }; |
76 | 80 |
77 } // namespace precache | 81 } // namespace precache |
78 | 82 |
79 #endif // COMPONENTS_PRECACHE_CORE_FETCHER_POOL_H_ | 83 #endif // COMPONENTS_PRECACHE_CORE_FETCHER_POOL_H_ |
OLD | NEW |